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