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_at = PMPI_File_iwrite_at
00015 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00016 #pragma _HP_SECONDARY_DEF PMPI_File_iwrite_at MPI_File_iwrite_at
00017 #elif defined(HAVE_PRAGMA_CRI_DUP)
00018 #pragma _CRI duplicate MPI_File_iwrite_at as PMPI_File_iwrite_at
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
00042
00043 int MPI_File_iwrite_at(MPI_File fh, MPI_Offset offset, void *buf,
00044 int count, MPI_Datatype datatype,
00045 MPIO_Request *request)
00046 {
00047 int error_code, bufsize, buftype_is_contig, filetype_is_contig;
00048 #ifndef PRINT_ERR_MSG
00049 static char myname[] = "MPI_FILE_IWRITE_AT";
00050 #endif
00051 int datatype_size;
00052 ADIO_Status status;
00053 ADIO_Offset off;
00054 #ifdef MPI_hpux
00055 int fl_xmpi;
00056
00057 HPMP_IO_START(fl_xmpi, BLKMPIFILEIWRITEAT, TRDTSYSTEM,
00058 fh, datatype, count);
00059 #endif
00060
00061 #ifdef PRINT_ERR_MSG
00062 if ((fh <= (MPI_File) 0) || (fh->cookie != ADIOI_FILE_COOKIE)) {
00063 FPRINTF(stderr, "MPI_File_iwrite_at: Invalid file handle\n");
00064 MPI_Abort(MPI_COMM_WORLD, 1);
00065 }
00066 #else
00067 ADIOI_TEST_FILE_HANDLE(fh, myname);
00068 #endif
00069
00070 if (offset < 0) {
00071 #ifdef PRINT_ERR_MSG
00072 FPRINTF(stderr, "MPI_File_iwrite_at: Invalid offset argument\n");
00073 MPI_Abort(MPI_COMM_WORLD, 1);
00074 #else
00075 error_code = MPIR_Err_setmsg(MPI_ERR_ARG, MPIR_ERR_OFFSET_ARG,
00076 myname, (char *) 0, (char *) 0);
00077 return ADIOI_Error(fh, error_code, myname);
00078 #endif
00079 }
00080
00081 if (count < 0) {
00082 #ifdef PRINT_ERR_MSG
00083 FPRINTF(stderr, "MPI_File_iwrite_at: Invalid count argument\n");
00084 MPI_Abort(MPI_COMM_WORLD, 1);
00085 #else
00086 error_code = MPIR_Err_setmsg(MPI_ERR_ARG, MPIR_ERR_COUNT_ARG,
00087 myname, (char *) 0, (char *) 0);
00088 return ADIOI_Error(fh, error_code, myname);
00089 #endif
00090 }
00091
00092 if (datatype == MPI_DATATYPE_NULL) {
00093 #ifdef PRINT_ERR_MSG
00094 FPRINTF(stderr, "MPI_File_iwrite_at: Invalid datatype\n");
00095 MPI_Abort(MPI_COMM_WORLD, 1);
00096 #else
00097 error_code = MPIR_Err_setmsg(MPI_ERR_TYPE, MPIR_ERR_TYPE_NULL,
00098 myname, (char *) 0, (char *) 0);
00099 return ADIOI_Error(fh, error_code, myname);
00100 #endif
00101 }
00102
00103 MPI_Type_size(datatype, &datatype_size);
00104
00105 if ((count*datatype_size) % fh->etype_size != 0) {
00106 #ifdef PRINT_ERR_MSG
00107 FPRINTF(stderr, "MPI_File_iwrite_at: Only an integral number of etypes can be accessed\n");
00108 MPI_Abort(MPI_COMM_WORLD, 1);
00109 #else
00110 error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_ETYPE_FRACTIONAL,
00111 myname, (char *) 0, (char *) 0);
00112 return ADIOI_Error(fh, error_code, myname);
00113 #endif
00114 }
00115
00116 if (fh->access_mode & MPI_MODE_SEQUENTIAL) {
00117 #ifdef PRINT_ERR_MSG
00118 FPRINTF(stderr, "MPI_File_iwrite_at: Can't use this function because file was opened with MPI_MODE_SEQUENTIAL\n");
00119 MPI_Abort(MPI_COMM_WORLD, 1);
00120 #else
00121 error_code = MPIR_Err_setmsg(MPI_ERR_UNSUPPORTED_OPERATION,
00122 MPIR_ERR_AMODE_SEQ, myname, (char *) 0, (char *) 0);
00123 return ADIOI_Error(fh, error_code, myname);
00124 #endif
00125 }
00126
00127 ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
00128 ADIOI_Datatype_iscontig(fh->filetype, &filetype_is_contig);
00129
00130
00131
00132 if (buftype_is_contig && filetype_is_contig) {
00133
00134 bufsize = datatype_size * count;
00135 off = fh->disp + fh->etype_size * offset;
00136 if (!(fh->atomicity))
00137 ADIO_IwriteContig(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00138 off, request, &error_code);
00139 else {
00140
00141
00142
00143 *request = ADIOI_Malloc_request();
00144 (*request)->optype = ADIOI_WRITE;
00145 (*request)->fd = fh;
00146 (*request)->datatype = datatype;
00147 (*request)->queued = 0;
00148 (*request)->handle = 0;
00149
00150 if ((fh->file_system != ADIO_PIOFS) &&
00151 (fh->file_system != ADIO_NFS) && (fh->file_system != ADIO_PVFS))
00152 ADIOI_WRITE_LOCK(fh, off, SEEK_SET, bufsize);
00153
00154 ADIO_WriteContig(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET, off,
00155 &status, &error_code);
00156
00157 if ((fh->file_system != ADIO_PIOFS) &&
00158 (fh->file_system != ADIO_NFS) && (fh->file_system != ADIO_PVFS))
00159 ADIOI_UNLOCK(fh, off, SEEK_SET, bufsize);
00160
00161 fh->async_count++;
00162
00163
00164
00165 }
00166 }
00167 else
00168 ADIO_IwriteStrided(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00169 offset, request, &error_code);
00170
00171 #ifdef MPI_hpux
00172 HPMP_IO_END(fl_xmpi, fh, datatype, count)
00173 #endif
00174 return error_code;
00175 }