93 提供公平性 |
作为一个替代
#define large 128 MPI_Request requests[large]; MPI_Status statuses[large]; int indices[large]; int buf[large]; for (i=1; i<size; i++) MPI_Irecv( buf+i, 1, MPI_INT, i, MPI_ANY_TAG, MPI_COMM_WORLD, &requests[i-1] ); while(not done) { MPI_Waitsome( size-1, requests, &ndone, indices, statuses ); for (i=0; i<ndone; i++) { j = indices[i]; printf( "Msg from %d with tag %d\n", statuses[i].MPI_SOURCE, statuses[i].MPI_TAG ); MPI_Irecv( buf+j, 1, MPI_INT, j, MPI_ANY_TAG, MPI_COMM_WORLD, &requests[j] ); } }
Copyright: NPACT |