00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include "mpioimpl.h"
00009 
00010 #ifdef HAVE_WEAK_SYMBOLS
00011 
00012 #if defined(HAVE_PRAGMA_WEAK)
00013 #pragma weak MPIO_Waitsome = PMPIO_Waitsome
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPIO_Waitsome MPIO_Waitsome
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPIO_Waitsome as PMPIO_Waitsome
00018 
00019 #endif
00020 
00021 
00022 #define MPIO_BUILD_PROFILING
00023 #include "mpioprof.h"
00024 #endif
00025 
00026 
00027 
00028 
00029 
00030 
00031 int MPIO_Waitsome(int count, MPIO_Request requests[], int *outcount,
00032           int indices[], MPI_Status *statuses)
00033 {
00034     int i, flag, err; 
00035     MPIU_THREADPRIV_DECL;
00036 
00037     MPIU_THREAD_CS_ENTER(ALLFUNC,);
00038 
00039     if (count == 1) {
00040     err = MPIO_Wait( requests, statuses );
00041     if (!err) {
00042         *outcount = 1;
00043         indices[0] = 0;
00044     }
00045     goto fn_exit;
00046     }
00047 
00048     
00049     for (i=0; i<count; i++) {
00050     if (requests[i] != MPIO_REQUEST_NULL) {
00051         break;
00052     }
00053     }
00054     if (i == count) {
00055     *outcount = MPI_UNDEFINED;
00056     err = MPI_SUCCESS;
00057     goto fn_exit;
00058     }
00059 
00060     err = MPI_SUCCESS;
00061     *outcount = 0;
00062     do {
00063     for (i=0; i<count; i++) {
00064         if (requests[i] != MPIO_REQUEST_NULL) {
00065         err = MPIO_Test( &requests[i], &flag, statuses );
00066         if (flag) {
00067             if (!err) {
00068             indices[0] = i;
00069             indices++;
00070             statuses++;
00071             *outcount = *outcount + 1;
00072             }
00073         }
00074         }
00075     }
00076     } while (*outcount == 0);
00077 
00078 fn_exit:
00079     MPIU_THREAD_CS_EXIT(ALLFUNC,);
00080     return err;
00081 }