Skip to content

Instantly share code, notes, and snippets.

@shelling
Created June 15, 2010 09:50
Show Gist options
  • Select an option

  • Save shelling/438923 to your computer and use it in GitHub Desktop.

Select an option

Save shelling/438923 to your computer and use it in GitHub Desktop.
myrank = MPI::Comm::WORLD.rank()
csize = MPI::Comm::WORLD.size()
if myrank % 2 == 0 then
if myrank + 1 != csize then
hello = "Hello, I'm #{myrank}, you must be #{myrank+1}"
MPI::Comm::WORLD.send(hello, myrank + 1, 0)
end
else
msg, status = MPI::Comm::WORLD.recv(myrank - 1, 0)
puts "I'm #{myrank} and this message came from #{status.source} with tag #{status.tag}: '#{msg}'"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment