00001
00002
00003
00004
00005
00006
00007
00008 #include "adio.h"
00009 #include "adio_extern.h"
00010 #include "ad_pvfs2.h"
00011 #include "ad_pvfs2_io.h"
00012 #include "ad_pvfs2_common.h"
00013
00014 void ADIOI_PVFS2_ReadContig(ADIO_File fd, void *buf, int count,
00015 MPI_Datatype datatype, int file_ptr_type,
00016 ADIO_Offset offset, ADIO_Status *status,
00017 int *error_code)
00018 {
00019 int ret, datatype_size, len;
00020 PVFS_Request file_req, mem_req;
00021 PVFS_sysresp_io resp_io;
00022 ADIOI_PVFS2_fs *pvfs_fs;
00023 static char myname[] = "ADIOI_PVFS2_READCONTIG";
00024
00025 pvfs_fs = (ADIOI_PVFS2_fs*)fd->fs_ptr;
00026
00027 MPI_Type_size(datatype, &datatype_size);
00028 len = datatype_size * count;
00029
00030 ret = PVFS_Request_contiguous(len, PVFS_BYTE, &mem_req);
00031
00032 if (ret != 0) {
00033 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00034 MPIR_ERR_RECOVERABLE,
00035 myname, __LINE__,
00036 ADIOI_PVFS2_error_convert(ret),
00037 "Error in pvfs_request_contig (memory)", 0);
00038 return;
00039 }
00040
00041
00042 ret = PVFS_Request_contiguous(len, PVFS_BYTE, &file_req);
00043
00044 if (ret != 0) {
00045 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00046 MPIR_ERR_RECOVERABLE,
00047 myname, __LINE__,
00048 ADIOI_PVFS2_error_convert(ret),
00049 "Error in pvfs_request_contig (file)", 0);
00050 return;
00051 }
00052
00053
00054 if (file_ptr_type == ADIO_INDIVIDUAL) {
00055
00056 offset = fd->fp_ind;
00057 }
00058
00059 #ifdef ADIOI_MPE_LOGGING
00060 MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
00061 #endif
00062 ret = PVFS_sys_read(pvfs_fs->object_ref, file_req, offset, buf,
00063 mem_req, &(pvfs_fs->credentials), &resp_io);
00064 #ifdef ADIOI_MPE_LOGGING
00065 MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
00066 #endif
00067
00068 if (ret != 0 ) {
00069 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00070 MPIR_ERR_RECOVERABLE,
00071 myname, __LINE__,
00072 ADIOI_PVFS2_error_convert(ret),
00073 "Error in PVFS_sys_read", 0);
00074 goto fn_exit;
00075 }
00076
00077
00078 if (file_ptr_type == ADIO_INDIVIDUAL) {
00079 fd->fp_ind += (int) resp_io.total_completed;
00080
00081 }
00082 fd->fp_sys_posn = offset + (int)resp_io.total_completed;
00083
00084 #ifdef HAVE_STATUS_SET_BYTES
00085 MPIR_Status_set_bytes(status, datatype, (int)resp_io.total_completed);
00086 #endif
00087
00088 *error_code = MPI_SUCCESS;
00089 fn_exit:
00090 PVFS_Request_free(&mem_req);
00091 PVFS_Request_free(&file_req);
00092 return;
00093 }
00094
00095 static int ADIOI_PVFS2_ReadStridedListIO(ADIO_File fd, void *buf, int count,
00096 MPI_Datatype datatype, int file_ptr_type,
00097 ADIO_Offset offset, ADIO_Status *status,
00098 int *error_code)
00099 {
00100 return ADIOI_PVFS2_StridedListIO(fd, buf, count,
00101 datatype, file_ptr_type,
00102 offset, status,
00103 error_code, READ);
00104 }
00105
00106 static int ADIOI_PVFS2_ReadStridedDtypeIO(ADIO_File fd, void *buf, int count,
00107 MPI_Datatype datatype, int file_ptr_type,
00108 ADIO_Offset offset, ADIO_Status *status,
00109 int *error_code)
00110 {
00111 return ADIOI_PVFS2_StridedDtypeIO(fd, buf, count,
00112 datatype, file_ptr_type,
00113 offset, status, error_code,
00114 READ);
00115 }
00116
00117 void ADIOI_PVFS2_ReadStrided(ADIO_File fd, void *buf, int count,
00118 MPI_Datatype datatype, int file_ptr_type,
00119 ADIO_Offset offset, ADIO_Status *status, int
00120 *error_code)
00121 {
00122
00123
00124
00125
00126
00127
00128
00129
00130 int ret = -1;
00131
00132 if (fd->hints->fs_hints.pvfs2.posix_read == ADIOI_HINT_ENABLE) {
00133 ADIOI_GEN_ReadStrided(fd, buf, count, datatype,
00134 file_ptr_type, offset, status, error_code);
00135 return;
00136 }
00137 if (fd->hints->fs_hints.pvfs2.dtype_read == ADIOI_HINT_ENABLE) {
00138 ret = ADIOI_PVFS2_ReadStridedDtypeIO(fd, buf, count,
00139 datatype, file_ptr_type,
00140 offset, status, error_code);
00141
00142
00143 if (ret != 0)
00144 {
00145 fprintf(stderr,
00146 "Falling back to list I/O since datatype I/O failed\n");
00147 ret = ADIOI_PVFS2_ReadStridedListIO(fd, buf, count,
00148 datatype, file_ptr_type,
00149 offset, status, error_code);
00150 }
00151 return;
00152 }
00153 if (fd->hints->fs_hints.pvfs2.listio_read == ADIOI_HINT_ENABLE) {
00154 ret = ADIOI_PVFS2_ReadStridedListIO(fd, buf, count, datatype,
00155 file_ptr_type, offset, status, error_code);
00156 return;
00157 }
00158
00159
00160 ADIOI_PVFS2_OldReadStrided(fd, buf, count, datatype,
00161 file_ptr_type, offset, status, error_code);
00162 return;
00163 }
00164
00165
00166
00167
00168