int MPIO_Testsome(int count, MPIO_Request requests[], int *outcount, int indices[], MPI_Status *statuses) { int i, err; int flag; MPID_THREADPRIV_DECL; ROMIO_THREAD_CS_ENTER(); if (count == 1) { err = MPIO_Test( requests, &flag, statuses ); if (!err) { if (flag) { indices[0] = 0; *outcount = 1; } else { *outcount = 0; } } goto fn_exit; } /* Check for no active requests */ for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { break; } } if (i == count) { *outcount = MPI_UNDEFINED; err = MPI_SUCCESS; goto fn_exit; } err = MPI_SUCCESS; *outcount = 0; for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { err = MPIO_Test( &requests[i], &flag, statuses ); if (flag) { if (!err) { indices[0] = i; indices++; statuses++; *outcount = *outcount + 1; } } } } fn_exit: ROMIO_THREAD_CS_EXIT(); return err; }
int MPIO_Testany(int count, MPIO_Request requests[], int *index, int *flag, MPI_Status *status) { int i, err; MPID_CS_ENTER(); if (count == 1) { MPIR_Nest_incr(); err = MPIO_Test( requests, flag, status ); MPIR_Nest_decr(); if (!err) *index = 0; goto fn_exit; } /* Check for no active requests */ for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { break; } } if (i == count) { *index = MPI_UNDEFINED; #ifdef MPICH2 /* need to set empty status */ if (status != MPI_STATUS_IGNORE) { status->MPI_SOURCE = MPI_ANY_SOURCE; status->MPI_TAG = MPI_ANY_TAG; status->count = 0; status->cancelled = 0; } #endif err = MPI_SUCCESS; goto fn_exit; } err = MPI_SUCCESS; for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { MPIR_Nest_incr(); err = MPIO_Test( &requests[i], flag, status ); MPIR_Nest_decr(); if (*flag) { if (!err) *index = i; break; } } } fn_exit: MPID_CS_EXIT(); return err; }
int MPIO_Testany(int count, MPIO_Request requests[], int *index, int *flag, MPI_Status *status) { int i, err; ROMIO_THREAD_CS_ENTER(); if (count == 1) { err = MPIO_Test( requests, flag, status ); if (!err) *index = 0; goto fn_exit; } /* Check for no active requests */ for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { break; } } if (i == count) { *index = MPI_UNDEFINED; #ifdef MPICH /* need to set empty status */ if (status != MPI_STATUS_IGNORE) { status->MPI_SOURCE = MPI_ANY_SOURCE; status->MPI_TAG = MPI_ANY_TAG; MPIR_STATUS_SET_COUNT(*status, 0); MPIR_STATUS_SET_CANCEL_BIT(*status, 0); } #endif err = MPI_SUCCESS; goto fn_exit; } err = MPI_SUCCESS; for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { err = MPIO_Test( &requests[i], flag, status ); if (*flag) { if (!err) *index = i; break; } } } fn_exit: ROMIO_THREAD_CS_EXIT(); return err; }
FORTRAN_API void FORT_CALL mpio_test_(MPI_Fint *request,MPI_Fint *flag,MPI_Status *status, MPI_Fint *ierr ) { MPIO_Request req_c; req_c = MPIO_Request_f2c(*request); *ierr = MPIO_Test(&req_c,flag,status); *request = MPIO_Request_c2f(req_c); }
int MPIO_Testall(int count, MPIO_Request requests[], int *flag, MPI_Status statuses[]) { int done, i, err; MPIU_THREADPRIV_DECL; MPIU_THREAD_CS_ENTER(ALLFUNC,); if (count == 1) { err = MPIO_Test( requests, flag, statuses ); goto fn_exit; } /* This is actually very difficult to do. We can't use MPIO_Test, since we must change the requests only if *ALL* requests are complete */ /* FIXME: THIS IS NOT CORRECT (see above). But most applications won't care */ done = 1; for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { err = MPIO_Test( &requests[i], flag, &statuses[i] ); if (!*flag) done = 0; if (err) goto fn_exit; } else { #ifdef MPICH /* need to set empty status */ if (statuses != MPI_STATUSES_IGNORE) { statuses[i].MPI_SOURCE = MPI_ANY_SOURCE; statuses[i].MPI_TAG = MPI_ANY_TAG; statuses[i].count = 0; statuses[i].cancelled = 0; } #else ; #endif } } *flag = done; err = MPI_SUCCESS; fn_exit: MPIU_THREAD_CS_EXIT(ALLFUNC,); return err; }
int MPIO_Waitsome(int count, MPIO_Request requests[], int *outcount, int indices[], MPI_Status *statuses) { int i, flag, err; MPID_CS_ENTER(); if (count == 1) { MPIR_Nest_incr(); err = MPIO_Wait( requests, statuses ); MPIR_Nest_decr(); if (!err) { *outcount = 1; indices[0] = 0; } goto fn_exit; } /* Check for no active requests */ for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { break; } } if (i == count) { *outcount = MPI_UNDEFINED; err = MPI_SUCCESS; goto fn_exit; } err = MPI_SUCCESS; *outcount = 0; do { for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { err = MPIO_Test( &requests[i], &flag, statuses ); if (flag) { if (!err) { indices[0] = i; indices++; statuses++; *outcount = *outcount + 1; } } } } } while (*outcount == 0); fn_exit: MPID_CS_EXIT(); return err; }
int MPIO_Waitany(int count, MPIO_Request requests[], int *index, MPI_Status *status) { int i, flag, err; MPID_THREADPRIV_DECL; if (count == 1) { err = MPIO_Wait( requests, status ); if (!err) *index = 0; goto fn_exit; } /* Check for no active requests */ for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { break; } } if (i == count) { *index = MPI_UNDEFINED; #ifdef MPICH /* need to set empty status */ if (status != MPI_STATUS_IGNORE) { status->MPI_SOURCE = MPI_ANY_SOURCE; status->MPI_TAG = MPI_ANY_TAG; MPIR_STATUS_SET_COUNT(*status, 0); MPIR_STATUS_SET_CANCEL_BIT(*status, 0); } #endif err = MPI_SUCCESS; goto fn_exit; } err = MPI_SUCCESS; do { flag = 0; for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { err = MPIO_Test( &requests[i], &flag, status ); if (flag) { if (!err) *index = i; break; } } } } while (flag == 0); fn_exit: return err; }
int MPIO_Waitall( int count, MPIO_Request requests[], MPI_Status statuses[] ) { int notdone, i, flag, err; MPID_CS_ENTER(); if (count == 1) { MPIR_Nest_incr(); err = MPIO_Wait(requests, statuses); MPIR_Nest_decr(); goto fn_exit; } do { notdone = 0; for (i=0; i<count; i++) { if (requests[i] != MPIO_REQUEST_NULL) { MPIR_Nest_incr(); err = MPIO_Test( &requests[i], &flag, &statuses[i] ); MPIR_Nest_decr(); if (!flag) notdone = 1; if (err) goto fn_exit; } else { #ifdef MPICH2 /* need to set empty status */ if (statuses != MPI_STATUSES_IGNORE) { statuses[i].MPI_SOURCE = MPI_ANY_SOURCE; statuses[i].MPI_TAG = MPI_ANY_TAG; statuses[i].count = 0; statuses[i].cancelled = 0; } #else ; #endif } } } while (notdone); err = MPI_SUCCESS; fn_exit: MPID_CS_EXIT(); return err; }