from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
next_proc = (rank + 1) % size
prev_proc = (rank + size - 1) % size
tag = 2
message = 10
if 0 == rank:
comm.send(message, dest=next_proc, tag=tag)
while(1):
message = comm.recv(message, source=prev_proc, tag=tag)
comm.Recv_init
if 0 == rank:
message = message - 1
print "Process %d decremented value: %d\n" %(rank, message)
comm.send(message, dest=next_proc, tag=tag)
if 0 == message:
print "Process %d exiting\n" %(rank)
break;
if 0 == rank:
message = comm.recv(message, source=prev_proc, tag=tag)
mpiexec -n 10 python ring_py.py
Process 0 decremented value: 9
Process 0 decremented value: 8
Process 0 decremented value: 7
Process 0 decremented value: 6
Process 0 decremented value: 5
Process 0 decremented value: 4
Traceback (most recent call last):
File "ring_py.py", line 20, in <module>
message = comm.recv(message, source=prev_proc, tag=tag)
File "MPI/Comm.pyx", line 1192, in mpi4py.MPI.Comm.recv (src/mpi4py.MPI.c:106889)
File "MPI/msgpickle.pxi", line 287, in mpi4py.MPI.PyMPI_recv (src/mpi4py.MPI.c:42965)
mpi4py.MPI.Exception: MPI_ERR_TRUNCATE: message truncated
mpirun --version
mpirun (Open MPI) 2.0.1
--
You received this message because you are subscribed to the Google Groups "mpi4py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpi4py+un...@googlegroups.com.
To post to this group, send email to mpi...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpi4py.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpi4py/606c44fa-4501-4a88-8604-22fee6b2c115%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mpi4py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpi4py+unsubscribe@googlegroups.com.
To post to this group, send email to mpi...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpi4py.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpi4py/606c44fa-4501-4a88-8604-22fee6b2c115%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Okay I understand. The message will eventually "hit" each process as they wait in the ring.(Also reading Lisandro's post, let me chew on that for a bit).
To unsubscribe from this group and stop receiving emails from it, send an email to mpi4py+unsubscribe@googlegroups.com.
To post to this group, send email to mpi...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpi4py.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpi4py/606c44fa-4501-4a88-8604-22fee6b2c115%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mpi4py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpi4py+unsubscribe@googlegroups.com.
To post to this group, send email to mpi...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpi4py.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpi4py/CAPhiW4htBYOV0PdcOOPU-OST9upaFxF%3DYwfMnC5svEW1THVwdQ%40mail.gmail.com.
What about issuing the warning if the message is truncated by the buf argument? I'm not sure there's a good argument for honoring the buf kwarg in the lowercase receive method.
--
You received this message because you are subscribed to the Google Groups "mpi4py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpi4py+un...@googlegroups.com.
To post to this group, send email to mpi...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpi4py.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpi4py/CAEcYPwCTMk7EMtL4M2dc8zvDtG3O2BSNK7xcbmc60hiYdE2GHw%40mail.gmail.com.
Okay, I understand. Yes, I'd suggest deprecating the 'buf' kwarg here, since it's been superceded in MPI 3.
Of course, we could probably fix this just by improving the documentation on the recv method :)