File: narray_offset.rb

package info (click to toggle)
ruby-mpi 0.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 408 kB
  • sloc: ansic: 1,500; ruby: 808; makefile: 8
file content (32 lines) | stat: -rw-r--r-- 434 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require "mpi"
if defined?(NumRu::NArray)
  include NumRu
end

MPI.Init


world = MPI::Comm::WORLD

if world.size == 1
  print "Size is one, so do nothing\n"
  exit
end

rank = world.rank
size = world.size

length = 2
if rank == 0
  a = NArray.float(length,size-1)
  (size-1).times do |i|
    world.Recv(a, i+1, 1, length, i*length)
  end
  p a
else
  a = NArray.float(length).indgen + rank*10
  world.Send(a, 0, 1)
end


MPI.Finalize