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_iwrite_shared = PMPI_File_iwrite_shared
00015 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00016 #pragma _HP_SECONDARY_DEF PMPI_File_iwrite_shared MPI_File_iwrite_shared
00017 #elif defined(HAVE_PRAGMA_CRI_DUP)
00018 #pragma _CRI duplicate MPI_File_iwrite_shared as PMPI_File_iwrite_shared
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
00041 int MPI_File_iwrite_shared(MPI_File fh, void *buf, int count,
00042 MPI_Datatype datatype, MPIO_Request *request)
00043 {
00044 int error_code, bufsize, buftype_is_contig, filetype_is_contig;
00045 #ifndef PRINT_ERR_MSG
00046 static char myname[] = "MPI_FILE_IWRITE_SHARED";
00047 #endif
00048 int datatype_size, incr;
00049 ADIO_Status status;
00050 ADIO_Offset off, shared_fp;
00051
00052 #ifdef PRINT_ERR_MSG
00053 if ((fh <= (MPI_File) 0) || (fh->cookie != ADIOI_FILE_COOKIE)) {
00054 FPRINTF(stderr, "MPI_File_iwrite_shared: Invalid file handle\n");
00055 MPI_Abort(MPI_COMM_WORLD, 1);
00056 }
00057 #else
00058 ADIOI_TEST_FILE_HANDLE(fh, myname);
00059 #endif
00060
00061 if (count < 0) {
00062 #ifdef PRINT_ERR_MSG
00063 FPRINTF(stderr, "MPI_File_iwrite_shared: Invalid count argument\n");
00064 MPI_Abort(MPI_COMM_WORLD, 1);
00065 #else
00066 error_code = MPIR_Err_setmsg(MPI_ERR_ARG, MPIR_ERR_COUNT_ARG,
00067 myname, (char *) 0, (char *) 0);
00068 return ADIOI_Error(fh, error_code, myname);
00069 #endif
00070 }
00071
00072 if (datatype == MPI_DATATYPE_NULL) {
00073 #ifdef PRINT_ERR_MSG
00074 FPRINTF(stderr, "MPI_File_iwrite_shared: Invalid datatype\n");
00075 MPI_Abort(MPI_COMM_WORLD, 1);
00076 #else
00077 error_code = MPIR_Err_setmsg(MPI_ERR_TYPE, MPIR_ERR_TYPE_NULL,
00078 myname, (char *) 0, (char *) 0);
00079 return ADIOI_Error(fh, error_code, myname);
00080 #endif
00081 }
00082
00083 MPI_Type_size(datatype, &datatype_size);
00084
00085 if ((count*datatype_size) % fh->etype_size != 0) {
00086 #ifdef PRINT_ERR_MSG
00087 FPRINTF(stderr, "MPI_File_iwrite_shared: Only an integral number of etypes can be accessed\n");
00088 MPI_Abort(MPI_COMM_WORLD, 1);
00089 #else
00090 error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_ETYPE_FRACTIONAL,
00091 myname, (char *) 0, (char *) 0);
00092 return ADIOI_Error(fh, error_code, myname);
00093 #endif
00094 }
00095
00096 if ((fh->file_system == ADIO_PIOFS) || (fh->file_system == ADIO_PVFS)) {
00097 #ifdef PRINT_ERR_MSG
00098 FPRINTF(stderr, "MPI_File_iwrite_shared: Shared file pointer not supported on PIOFS and PVFS\n");
00099 MPI_Abort(MPI_COMM_WORLD, 1);
00100 #else
00101 error_code = MPIR_Err_setmsg(MPI_ERR_UNSUPPORTED_OPERATION,
00102 MPIR_ERR_NO_SHARED_FP, myname, (char *) 0, (char *) 0);
00103 return ADIOI_Error(fh, error_code, myname);
00104 #endif
00105 }
00106
00107 ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
00108 ADIOI_Datatype_iscontig(fh->filetype, &filetype_is_contig);
00109
00110 incr = (count*datatype_size)/fh->etype_size;
00111 ADIO_Get_shared_fp(fh, incr, &shared_fp, &error_code);
00112 if (error_code != MPI_SUCCESS) {
00113 FPRINTF(stderr, "MPI_File_iwrite_shared: Error! Could not access shared file pointer.\n");
00114 MPI_Abort(MPI_COMM_WORLD, 1);
00115 }
00116
00117
00118 if (buftype_is_contig && filetype_is_contig) {
00119
00120 bufsize = datatype_size * count;
00121 off = fh->disp + fh->etype_size * shared_fp;
00122 if (!(fh->atomicity))
00123 ADIO_IwriteContig(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00124 off, request, &error_code);
00125 else {
00126
00127
00128
00129 *request = ADIOI_Malloc_request();
00130 (*request)->optype = ADIOI_WRITE;
00131 (*request)->fd = fh;
00132 (*request)->datatype = datatype;
00133 (*request)->queued = 0;
00134 (*request)->handle = 0;
00135
00136 if (fh->file_system != ADIO_NFS)
00137 ADIOI_WRITE_LOCK(fh, off, SEEK_SET, bufsize);
00138
00139 ADIO_WriteContig(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET, off,
00140 &status, &error_code);
00141
00142 if (fh->file_system != ADIO_NFS)
00143 ADIOI_UNLOCK(fh, off, SEEK_SET, bufsize);
00144
00145 fh->async_count++;
00146
00147
00148 }
00149 }
00150 else
00151 ADIO_IwriteStrided(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00152 shared_fp, request, &error_code);
00153
00154 return error_code;
00155 }