int MPIR_File_iread_cdesc(MPI_File x0, CFI_cdesc_t* x1, int x2, MPI_Datatype x3, MPIO_Request * x4) { int err = MPI_SUCCESS; #ifdef MPI_MODE_RDONLY void *buf1 = x1->base_addr; int count1 = x2; MPI_Datatype dtype1 = x3; if (buf1 == &MPIR_F08_MPI_BOTTOM) { buf1 = MPI_BOTTOM; } if (x1->rank != 0 && !CFI_is_contiguous(x1)) { err = cdesc_create_datatype(x1, x2, x3, &dtype1); count1 = 1; } err = MPI_File_iread(x0, buf1, count1, dtype1, x4); if (dtype1 != x3) MPI_Type_free(&dtype1); #else err = MPI_ERR_INTERN; #endif return err; }
FORTRAN_API void FORT_CALL mpi_file_iread_(MPI_Fint *fh,void *buf,MPI_Fint *count, MPI_Datatype *datatype,MPI_Fint *request, MPI_Fint *ierr ) { MPI_File fh_c; MPIO_Request req_c; fh_c = MPI_File_f2c(*fh); *ierr = MPI_File_iread(fh_c,buf,*count,*datatype,&req_c); *request = MPIO_Request_c2f(req_c); }
void mpi_file_iread_(MPI_Fint *fh,void *buf,MPI_Fint *count, MPI_Fint *datatype,MPI_Fint *request, MPI_Fint *ierr ) { MPI_File fh_c; MPIO_Request req_c; MPI_Datatype datatype_c; datatype_c = MPI_Type_f2c(*datatype); fh_c = MPI_File_f2c(*fh); *ierr = MPI_File_iread(fh_c,buf,*count,datatype_c,&req_c); *request = MPIO_Request_c2f(req_c); }
JNIEXPORT jlong JNICALL Java_mpi_File_iRead( JNIEnv *env, jobject jthis, jlong fh, jobject buf, jint count, jlong type) { void *ptr = (*env)->GetDirectBufferAddress(env, buf); MPI_Request request; int rc = MPI_File_iread((MPI_File)fh, ptr, count, (MPI_Datatype)type, &request); ompi_java_exceptionCheck(env, rc); return (jlong)request; }
void ompi_file_iread_f(MPI_Fint *fh, char *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *request, MPI_Fint *ierr) { int c_ierr; MPI_File c_fh = MPI_File_f2c(*fh); MPI_Datatype c_type = MPI_Type_f2c(*datatype); MPI_Request c_request; c_ierr = MPI_File_iread(c_fh, OMPI_F2C_BOTTOM(buf), OMPI_FINT_2_INT(*count), c_type, &c_request); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); if (MPI_SUCCESS == c_ierr) { *request = MPI_Request_c2f(c_request); } }
int main(int argc, char **argv) { int *buf, i, rank, nints, len; char *filename, *tmp; int errs=0; MPI_File fh; MPI_Status statuses[NUMOPS]; MPI_Request requests[NUMOPS]; MTest_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* process 0 takes the file name as a command-line argument and broadcasts it to other processes */ if (!rank) { i = 1; while ((i < argc) && strcmp("-fname", *argv)) { i++; argv++; } if (i >= argc) { /* Use a default filename of testfile */ len = 8; filename = (char *)malloc(len + 10); strcpy( filename, "testfile" ); /* fprintf(stderr, "\n*# Usage: async_any -fname filename\n\n"); MPI_Abort(MPI_COMM_WORLD, 1); */ } else { argv++; len = (int)strlen(*argv); filename = (char *) malloc(len+10); strcpy(filename, *argv); } MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(filename, len+10, MPI_CHAR, 0, MPI_COMM_WORLD); } else { MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD); filename = (char *) malloc(len+10); MPI_Bcast(filename, len+10, MPI_CHAR, 0, MPI_COMM_WORLD); } buf = (int *) malloc(SIZE); nints = SIZE/sizeof(int); for (i=0; i<nints; i++) buf[i] = rank*100000 + i; /* each process opens a separate file called filename.'myrank' */ tmp = (char *) malloc(len+10); strcpy(tmp, filename); sprintf(filename, "%s.%d", tmp, rank); MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh); MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL); for (i=0; i < NUMOPS; i++) { MPI_File_iwrite(fh, buf, nints, MPI_INT, &(requests[i])); } MPI_Waitall(NUMOPS, requests, statuses); MPI_File_close(&fh); /* reopen the file and read the data back */ for (i=0; i<nints; i++) buf[i] = 0; MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh); MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL); for (i=0; i < NUMOPS; i++) { MPI_File_iread(fh, buf, nints, MPI_INT, &(requests[i])); } MPI_Waitall(NUMOPS, requests, statuses); MPI_File_close(&fh); /* check if the data read is correct */ for (i=0; i<nints; i++) { if (buf[i] != (rank*100000 + i)) { errs++; fprintf(stderr, "Process %d: error, read %d, should be %d\n", rank, buf[i], rank*100000+i); } } free(buf); free(filename); free(tmp); MTest_Finalize(errs); MPI_Finalize(); return 0; }
int main(int argc, char **argv) { int *buf, i, rank, nints, len; char *filename, *tmp; int errs=0, toterrs; MPI_File fh; MPI_Status status; MPIO_Request request; int errcode = 0; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* process 0 takes the file name as a command-line argument and broadcasts it to other processes */ if (!rank) { i = 1; while ((i < argc) && strcmp("-fname", *argv)) { i++; argv++; } if (i >= argc) { fprintf(stderr, "\n*# Usage: async -fname filename\n\n"); MPI_Abort(MPI_COMM_WORLD, 1); } argv++; len = strlen(*argv); filename = (char *) malloc(len+10); strcpy(filename, *argv); MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(filename, len+10, MPI_CHAR, 0, MPI_COMM_WORLD); } else { MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD); filename = (char *) malloc(len+10); MPI_Bcast(filename, len+10, MPI_CHAR, 0, MPI_COMM_WORLD); } buf = (int *) malloc(SIZE); nints = SIZE/sizeof(int); for (i=0; i<nints; i++) buf[i] = rank*100000 + i; /* each process opens a separate file called filename.'myrank' */ tmp = (char *) malloc(len+10); strcpy(tmp, filename); sprintf(filename, "%s.%d", tmp, rank); errcode = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh); if (errcode != MPI_SUCCESS) { handle_error(errcode, "MPI_File_open"); } MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, "native", MPI_INFO_NULL); errcode = MPI_File_iwrite(fh, buf, nints, MPI_INT, &request); if (errcode != MPI_SUCCESS) { handle_error(errcode, "MPI_File_iwrite"); } #ifdef MPIO_USES_MPI_REQUEST MPI_Wait( &request, &status ); #else MPIO_Wait(&request, &status); #endif MPI_File_close(&fh); /* reopen the file and read the data back */ for (i=0; i<nints; i++) buf[i] = 0; errcode = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh); if (errcode != MPI_SUCCESS) { handle_error(errcode, "MPI_File_open"); } MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, "native", MPI_INFO_NULL); errcode = MPI_File_iread(fh, buf, nints, MPI_INT, &request); if (errcode != MPI_SUCCESS) { handle_error(errcode, "MPI_File_open"); } #ifdef MPIO_USES_MPI_REQUEST MPI_Wait( &request, &status ); #else MPIO_Wait(&request, &status); #endif MPI_File_close(&fh); /* check if the data read is correct */ for (i=0; i<nints; i++) { if (buf[i] != (rank*100000 + i)) { errs++; fprintf(stderr, "Process %d: error, read %d, should be %d\n", rank, buf[i], rank*100000+i); } } MPI_Allreduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); if (rank == 0) { if( toterrs > 0) { fprintf( stderr, "Found %d errors\n", toterrs ); } else { fprintf( stdout, " No Errors\n" ); } } free(buf); free(filename); free(tmp); MPI_Finalize(); return 0; }