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