00001
00002
00003
00004
00005
00006
00007
00008 #include "mpioimpl.h"
00009
00010 #ifdef HAVE_WEAK_SYMBOLS
00011
00012 #if defined(HAVE_PRAGMA_WEAK)
00013 #pragma weak MPI_File_iread = PMPI_File_iread
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPI_File_iread MPI_File_iread
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPI_File_iread as PMPI_File_iread
00018
00019 #endif
00020
00021
00022 #define MPIO_BUILD_PROFILING
00023 #include "mpioprof.h"
00024 #endif
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifdef HAVE_MPI_GREQUEST
00040 #include "mpiu_greq.h"
00041 #endif
00042
00043 int MPI_File_iread(MPI_File mpi_fh, void *buf, int count,
00044 MPI_Datatype datatype, MPI_Request *request)
00045 {
00046 int error_code=MPI_SUCCESS;
00047 static char myname[] = "MPI_FILE_IREAD";
00048 #ifdef MPI_hpux
00049 int fl_xmpi;
00050
00051 HPMP_IO_START(fl_xmpi, BLKMPIFILEIREAD, TRDTSYSTEM, mpi_fh, datatype,
00052 count);
00053 #endif
00054
00055 MPIU_THREAD_CS_ENTER(ALLFUNC,);
00056
00057 error_code = MPIOI_File_iread(mpi_fh, (MPI_Offset) 0, ADIO_INDIVIDUAL,
00058 buf, count, datatype, myname, request);
00059
00060
00061 if (error_code != MPI_SUCCESS)
00062 error_code = MPIO_Err_return_file(mpi_fh, error_code);
00063
00064
00065 #ifdef MPI_hpux
00066 HPMP_IO_END(fl_xmpi, mpi_fh, datatype, count);
00067 #endif
00068 MPIU_THREAD_CS_EXIT(ALLFUNC,);
00069
00070 return error_code;
00071 }
00072
00073
00074
00075 int MPIOI_File_iread(MPI_File mpi_fh,
00076 MPI_Offset offset,
00077 int file_ptr_type,
00078 void *buf,
00079 int count,
00080 MPI_Datatype datatype,
00081 char *myname,
00082 MPI_Request *request)
00083 {
00084 int error_code, bufsize, buftype_is_contig, filetype_is_contig;
00085 int datatype_size;
00086 ADIO_Status status;
00087 ADIO_File fh;
00088 ADIO_Offset off;
00089 MPI_Offset nbytes=0;
00090
00091 fh = MPIO_File_resolve(mpi_fh);
00092
00093
00094 MPIO_CHECK_FILE_HANDLE(fh, myname, error_code);
00095 MPIO_CHECK_COUNT(fh, count, myname, error_code);
00096 MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code);
00097
00098 if (file_ptr_type == ADIO_EXPLICIT_OFFSET && offset < 0) {
00099 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00100 myname, __LINE__, MPI_ERR_ARG,
00101 "**iobadoffset", 0);
00102 error_code = MPIO_Err_return_file(fh, error_code);
00103 goto fn_exit;
00104 }
00105
00106
00107 MPI_Type_size(datatype, &datatype_size);
00108
00109
00110 MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
00111 MPIO_CHECK_READABLE(fh, myname, error_code);
00112 MPIO_CHECK_NOT_SEQUENTIAL_MODE(fh, myname, error_code);
00113 MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
00114
00115
00116 ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
00117 ADIOI_Datatype_iscontig(fh->filetype, &filetype_is_contig);
00118
00119 ADIOI_TEST_DEFERRED(fh, myname, &error_code);
00120
00121 if (buftype_is_contig && filetype_is_contig) {
00122
00123 bufsize = datatype_size * count;
00124
00125 if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
00126 off = fh->disp + fh->etype_size * offset;
00127 }
00128 else {
00129 off = fh->fp_ind;
00130 }
00131
00132 if (!(fh->atomicity))
00133 ADIO_IreadContig(fh, buf, count, datatype, file_ptr_type,
00134 off, request, &error_code);
00135 else {
00136
00137
00138 if (ADIO_Feature(fh, ADIO_LOCKS))
00139 {
00140 ADIOI_WRITE_LOCK(fh, off, SEEK_SET, bufsize);
00141 }
00142
00143 ADIO_ReadContig(fh, buf, count, datatype, file_ptr_type,
00144 off, &status, &error_code);
00145
00146 if (ADIO_Feature(fh, ADIO_LOCKS))
00147 {
00148 ADIOI_UNLOCK(fh, off, SEEK_SET, bufsize);
00149 }
00150 if (error_code == MPI_SUCCESS) {
00151 nbytes = count*datatype_size;
00152 }
00153 MPIO_Completed_request_create(&fh, nbytes, &error_code, request);
00154 }
00155 }
00156 else ADIO_IreadStrided(fh, buf, count, datatype, file_ptr_type,
00157 offset, request, &error_code);
00158
00159 fn_exit:
00160
00161 return error_code;
00162 }
00163