c++ - What is equivalent of socket programming's select() in MPI? -
in socket programming, have select() function allows simultaneously check multiple sockets. want know there such feature available in mpi library well?
in first loop of following code, sending multiple nonblocking send , receive requests 1 every other node. in second loop instead of waiting each node in sequential order, want start processing data of node sends data first. want know there way that?
for(id=0; id<numtasks; id++){ if(id == taskid) continue; if(sendcount[id] != 0) mpi_isend(sendbuffer[id], n*sendcount[id], mpi_double, id, tag, mpi_comm_world, &reqs[id]); if(recvcount[id] != 0) mpi_irecv(recvbuffer[id], n*recvcount[id], mpi_double, id, tag, mpi_comm_world, &reqs[id]); } for(id=0; id<numtasks; id++){ if(id == taskid) continue; if(recvcount[id] != 0){ mpi_wait(&reqs[id], &status); for(i=0; i<recvcount[id]; i++) splitdata(n, recvbuffer[id] + n*i, u[torecv[id][i]]); } }
according given answers, have tried modify code still getting segmentation fault error during run time. please me figure out error.
for(id=0; id<numtasks; id++){ if(id == taskid) continue; if(sendcount[id] != 0) mpi_isend(sendbuffer[id], n*sendcount[id], mpi_double, id, tag, mpi_comm_world, &reqs[id]); if(recvcount[id] != 0) mpi_irecv(recvbuffer[id], n*recvcount[id], mpi_double, id, tag, mpi_comm_world, &reqs[id]); } reqs[taskid] = reqs[numtasks-1]; for(i=0; i<numtasks-1; i++){ mpi_waitany(numtasks-1, reqs, &id, &status); if(id == taskid) id = numtasks-1; for(i=0; i<recvcount[id]; i++) splitdata(n, recvbuffer[id] + n*i, u[torecv[id][i]]); }
the closest equivalent mpi_waitsome
, provide list of requests , returns @ least 1 request completed. however, there no timeout in select
. there mpi_waitany
, mpi_waitall
mpi_testany
, mpi_testall
, mpi_testsome
.
the any
, some
variants differ in way interface informs 1 or multiple completed requests.
edit: need use separate requests each operation, send , receive operations.
Comments
Post a Comment