00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "mpioimpl.h"
00010
00011 #ifdef HAVE_WEAK_SYMBOLS
00012
00013 #if defined(HAVE_PRAGMA_WEAK)
00014 #pragma weak MPI_File_write_ordered_begin = PMPI_File_write_ordered_begin
00015 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00016 #pragma _HP_SECONDARY_DEF PMPI_File_write_ordered_begin MPI_File_write_ordered_begin
00017 #elif defined(HAVE_PRAGMA_CRI_DUP)
00018 #pragma _CRI duplicate MPI_File_write_ordered_begin as PMPI_File_write_ordered_begin
00019
00020 #endif
00021
00022
00023 #define MPIO_BUILD_PROFILING
00024 #include "mpioprof.h"
00025 #endif
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 int MPI_File_write_ordered_begin(MPI_File fh, void *buf, int count,
00041 MPI_Datatype datatype)
00042 {
00043 int error_code, datatype_size, nprocs, myrank, i, incr;
00044 #ifndef PRINT_ERR_MSG
00045 static char myname[] = "MPI_FILE_WRITE_ORDERED_BEGIN";
00046 #endif
00047 ADIO_Offset shared_fp;
00048 MPI_Status status;
00049
00050 #ifdef PRINT_ERR_MSG
00051 if ((fh <= (MPI_File) 0) || (fh->cookie != ADIOI_FILE_COOKIE)) {
00052 FPRINTF(stderr, "MPI_File_write_ordered_begin: Invalid file handle\n");
00053 MPI_Abort(MPI_COMM_WORLD, 1);
00054 }
00055 #else
00056 ADIOI_TEST_FILE_HANDLE(fh, myname);
00057 #endif
00058
00059 if (count < 0) {
00060 #ifdef PRINT_ERR_MSG
00061 FPRINTF(stderr, "MPI_File_write_ordered_begin: Invalid count argument\n");
00062 MPI_Abort(MPI_COMM_WORLD, 1);
00063 #else
00064 error_code = MPIR_Err_setmsg(MPI_ERR_ARG, MPIR_ERR_COUNT_ARG,
00065 myname, (char *) 0, (char *) 0);
00066 return ADIOI_Error(fh, error_code, myname);
00067 #endif
00068 }
00069
00070 if (datatype == MPI_DATATYPE_NULL) {
00071 #ifdef PRINT_ERR_MSG
00072 FPRINTF(stderr, "MPI_File_write_ordered_begin: Invalid datatype\n");
00073 MPI_Abort(MPI_COMM_WORLD, 1);
00074 #else
00075 error_code = MPIR_Err_setmsg(MPI_ERR_TYPE, MPIR_ERR_TYPE_NULL,
00076 myname, (char *) 0, (char *) 0);
00077 return ADIOI_Error(fh, error_code, myname);
00078 #endif
00079 }
00080
00081 if (fh->split_coll_count) {
00082 #ifdef PRINT_ERR_MSG
00083 FPRINTF(stderr, "MPI_File_write_ordered_begin: Only one active split collective I/O operation allowed per file handle\n");
00084 MPI_Abort(MPI_COMM_WORLD, 1);
00085 #else
00086 error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_MULTIPLE_SPLIT_COLL,
00087 myname, (char *) 0, (char *) 0);
00088 return ADIOI_Error(fh, error_code, myname);
00089 #endif
00090 }
00091
00092 fh->split_coll_count = 1;
00093
00094 MPI_Type_size(datatype, &datatype_size);
00095 if ((count*datatype_size) % fh->etype_size != 0) {
00096 #ifdef PRINT_ERR_MSG
00097 FPRINTF(stderr, "MPI_File_write_ordered_begin: Only an integral number of etypes can be accessed\n");
00098 MPI_Abort(MPI_COMM_WORLD, 1);
00099 #else
00100 error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_ETYPE_FRACTIONAL,
00101 myname, (char *) 0, (char *) 0);
00102 return ADIOI_Error(fh, error_code, myname);
00103 #endif
00104 }
00105
00106 if ((fh->file_system == ADIO_PIOFS) || (fh->file_system == ADIO_PVFS)) {
00107 #ifdef PRINT_ERR_MSG
00108 FPRINTF(stderr, "MPI_File_write_ordered_begin: Shared file pointer not supported on PIOFS and PVFS\n");
00109 MPI_Abort(MPI_COMM_WORLD, 1);
00110 #else
00111 error_code = MPIR_Err_setmsg(MPI_ERR_UNSUPPORTED_OPERATION,
00112 MPIR_ERR_NO_SHARED_FP, myname, (char *) 0, (char *) 0);
00113 return ADIOI_Error(fh, error_code, myname);
00114 #endif
00115 }
00116
00117 MPI_Comm_size(fh->comm, &nprocs);
00118 MPI_Comm_rank(fh->comm, &myrank);
00119
00120 incr = (count*datatype_size)/fh->etype_size;
00121 for (i=0; i<nprocs; i++) {
00122 if (i == myrank) {
00123 ADIO_Get_shared_fp(fh, incr, &shared_fp, &error_code);
00124 if (error_code != MPI_SUCCESS) {
00125 FPRINTF(stderr, "MPI_File_write_ordered_begin: Error! Could not access shared file pointer.\n");
00126 MPI_Abort(MPI_COMM_WORLD, 1);
00127 }
00128 }
00129
00130 MPI_Barrier(fh->comm);
00131 }
00132
00133 ADIO_WriteStridedColl(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00134 shared_fp, &status, &error_code);
00135
00136 return error_code;
00137 }