Reputation: 310117
Is it possible to have a list of sources passed to an MPI_Recv (or equivalent) call? Currently, my code looks something like:
do i=nod1,nod2
call mpi_recv(tmp,n,MPI_REAL,MPI_ANY_SOURCE,tag,MPI_COMM_WORLD,status,ierr)
... do stuff with tmp here
call mpi_send(tmp,n,MPI_REAL,status(MPI_SOURCE),tag,MPI_COMM_WORLD,ierr)
enddo
Of course, this doesn't guarantee that it does what I want. (if nod1 sends two messages here before nod2 can send one message, then nod2's message is not recieved during this iteration, which would be bad.) In my application, that can't happen since nod1 and nod2 have other constraints which force them to be synchronized (enough) with each other ... but it got me wondering if there is way to specify a list of procs that are permitted to be recieved from.
Upvotes: 1
Views: 539
Reputation: 8273
Not as such. However, you can use MPI_Probe()
with MPI_ANY_SOURCE
, and then compare the MPI_SOURCE
field of the status
object against your list of processes you want to receive from. If there's a match, you can then proceed to receive from that source with a regular blocking receive.
Upvotes: 1