简体   繁体   中英

MPI_Recv with list of sources

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM