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