00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ADIOI_INCLUDE
00026 #define ADIOI_INCLUDE
00027
00028
00029 typedef struct ADIOI_Async {
00030 ADIO_Request *request;
00031 struct ADIOI_Async *prev, *next;
00032 } ADIOI_Async_node;
00033
00034
00035
00036 typedef struct ADIOI_Malloc_async_ptr {
00037 ADIOI_Async_node *ptr;
00038 struct ADIOI_Malloc_async_ptr *next;
00039 } ADIOI_Malloc_async;
00040
00041
00042 typedef struct ADIOI_Req_n {
00043 struct ADIOI_RequestD reqd;
00044 struct ADIOI_Req_n *next;
00045 } ADIOI_Req_node;
00046
00047
00048 typedef struct ADIOI_Malloc_req_ptr {
00049 ADIOI_Req_node *ptr;
00050 struct ADIOI_Malloc_req_ptr *next;
00051 } ADIOI_Malloc_req;
00052
00053
00054
00055
00056
00057
00058 struct ADIOI_Hints_struct {
00059 int initialized;
00060 int cb_read;
00061 int cb_write;
00062 int cb_nodes;
00063 int cb_buffer_size;
00064 int ds_read;
00065 int ds_write;
00066 int no_indep_rw;
00067 int ind_rd_buffer_size;
00068 int ind_wr_buffer_size;
00069 char *cb_config_list;
00070 int *ranklist;
00071 union {
00072 struct {
00073 int listio_read;
00074 int listio_write;
00075 } pvfs;
00076 } fs_hints;
00077
00078 };
00079
00080
00081
00082
00083
00084
00085 enum {
00086 ADIOI_HINT_AUTO = 0,
00087 ADIOI_HINT_ENABLE = 1,
00088 ADIOI_HINT_DISABLE = 2
00089 };
00090
00091
00092
00093
00094
00095 typedef struct ADIOI_Fl_node {
00096 MPI_Datatype type;
00097 int count;
00098 int *blocklens;
00099
00100 ADIO_Offset *indices;
00101 struct ADIOI_Fl_node *next;
00102 } ADIOI_Flatlist_node;
00103
00104
00105 struct ADIOI_Fns_struct {
00106 void (*ADIOI_xxx_Open) (ADIO_File fd, int *error_code);
00107 void (*ADIOI_xxx_ReadContig) (ADIO_File fd, void *buf, int count,
00108 MPI_Datatype datatype, int file_ptr_type,
00109 ADIO_Offset offset, ADIO_Status *status, int *error_code);
00110 void (*ADIOI_xxx_WriteContig) (ADIO_File fd, void *buf, int count,
00111 MPI_Datatype datatype, int file_ptr_type,
00112 ADIO_Offset offset, ADIO_Status *status, int *error_code);
00113 void (*ADIOI_xxx_ReadStridedColl) (ADIO_File fd, void *buf, int count,
00114 MPI_Datatype datatype, int file_ptr_type,
00115 ADIO_Offset offset, ADIO_Status *status, int *error_code);
00116 void (*ADIOI_xxx_WriteStridedColl) (ADIO_File fd, void *buf, int count,
00117 MPI_Datatype datatype, int file_ptr_type,
00118 ADIO_Offset offset, ADIO_Status *status, int *error_code);
00119 ADIO_Offset (*ADIOI_xxx_SeekIndividual) (ADIO_File fd, ADIO_Offset offset,
00120 int whence, int *error_code);
00121 void (*ADIOI_xxx_Fcntl) (ADIO_File fd, int flag,
00122 ADIO_Fcntl_t *fcntl_struct, int *error_code);
00123 void (*ADIOI_xxx_SetInfo) (ADIO_File fd, MPI_Info users_info,
00124 int *error_code);
00125 void (*ADIOI_xxx_ReadStrided) (ADIO_File fd, void *buf, int count,
00126 MPI_Datatype datatype, int file_ptr_type,
00127 ADIO_Offset offset, ADIO_Status *status, int *error_code);
00128 void (*ADIOI_xxx_WriteStrided) (ADIO_File fd, void *buf, int count,
00129 MPI_Datatype datatype, int file_ptr_type,
00130 ADIO_Offset offset, ADIO_Status *status, int *error_code);
00131 void (*ADIOI_xxx_Close) (ADIO_File fd, int *error_code);
00132 void (*ADIOI_xxx_IreadContig) (ADIO_File fd, void *buf, int count,
00133 MPI_Datatype datatype, int file_ptr_type,
00134 ADIO_Offset offset, ADIO_Request *request, int *error_code);
00135 void (*ADIOI_xxx_IwriteContig) (ADIO_File fd, void *buf, int count,
00136 MPI_Datatype datatype, int file_ptr_type,
00137 ADIO_Offset offset, ADIO_Request *request, int *error_code);
00138 int (*ADIOI_xxx_ReadDone) (ADIO_Request *request, ADIO_Status *status,
00139 int *error_code);
00140 int (*ADIOI_xxx_WriteDone) (ADIO_Request *request, ADIO_Status *status,
00141 int *error_code);
00142 void (*ADIOI_xxx_ReadComplete) (ADIO_Request *request, ADIO_Status *status,
00143 int *error_code);
00144 void (*ADIOI_xxx_WriteComplete) (ADIO_Request *request, ADIO_Status *status,
00145 int *error_code);
00146 void (*ADIOI_xxx_IreadStrided) (ADIO_File fd, void *buf, int count,
00147 MPI_Datatype datatype, int file_ptr_type,
00148 ADIO_Offset offset, ADIO_Request *request, int *error_code);
00149 void (*ADIOI_xxx_IwriteStrided) (ADIO_File fd, void *buf, int count,
00150 MPI_Datatype datatype, int file_ptr_type,
00151 ADIO_Offset offset, ADIO_Request *request, int *error_code);
00152 void (*ADIOI_xxx_Flush) (ADIO_File fd, int *error_code);
00153 void (*ADIOI_xxx_Resize) (ADIO_File fd, ADIO_Offset size, int *error_code);
00154 void (*ADIOI_xxx_Delete) (char *filename, int *error_code);
00155 };
00156
00157
00158 #define ADIOI_READ 26
00159 #define ADIOI_WRITE 27
00160
00161 #define ADIOI_MIN(a, b) ((a) < (b) ? (a) : (b))
00162 #define ADIOI_MAX(a, b) ((a) > (b) ? (a) : (b))
00163
00164 #define ADIOI_PREALLOC_BUFSZ 4194304
00165
00166
00167
00168
00169
00170 #define ADIOI_CB_BUFFER_SIZE_DFLT "4194304"
00171
00172 #define ADIOI_IND_RD_BUFFER_SIZE_DFLT "4194304"
00173
00174
00175
00176
00177 #define ADIOI_IND_WR_BUFFER_SIZE_DFLT "524288"
00178
00179 #define ADIOI_CB_CONFIG_LIST_DFLT "*:1"
00180
00181
00182
00183
00184 #define ADIO_ReadContig(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
00185 (*(fd->fns->ADIOI_xxx_ReadContig))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
00186
00187 #define ADIO_WriteContig(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
00188 (*(fd->fns->ADIOI_xxx_WriteContig))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
00189
00190 #define ADIO_SeekIndividual(fd,offset,whence,error_code) \
00191 (*(fd->fns->ADIOI_xxx_SeekIndividual))(fd,offset,whence,error_code)
00192
00193 #define ADIO_Fcntl(fd,flag,fcntl_struct,error_code) \
00194 (*(fd->fns->ADIOI_xxx_Fcntl))(fd,flag,fcntl_struct,error_code)
00195
00196 #define ADIO_IreadContig(fd,buf,count,datatype,file_ptr_type,offset,request,error_code) \
00197 (*(fd->fns->ADIOI_xxx_IreadContig))(fd,buf,count,datatype,file_ptr_type,offset,request,error_code)
00198
00199 #define ADIO_IwriteContig(fd,buf,count,datatype,file_ptr_type,offset,request,error_code) \
00200 (*(fd->fns->ADIOI_xxx_IwriteContig))(fd,buf,count,datatype,file_ptr_type,offset,request,error_code)
00201
00202
00203 #define ADIO_ReadDone(request,status,error_code) \
00204 (*((*(request))->fd->fns->ADIOI_xxx_ReadDone))(request,status,error_code)
00205
00206 #define ADIO_WriteDone(request,status,error_code) \
00207 (*((*(request))->fd->fns->ADIOI_xxx_WriteDone))(request,status,error_code)
00208
00209 #define ADIO_ReadIcomplete(request,status,error_code) \
00210 (*((*(request))->fd->fns->ADIOI_xxx_ReadIcomplete))(request,status,error_code)
00211
00212 #define ADIO_WriteIcomplete(request,status,error_code) \
00213 (*((*(request))->fd->fns->ADIOI_xxx_WriteIcomplete))(request,status,error_code)
00214
00215 #define ADIO_ReadComplete(request,status,error_code) \
00216 (*((*(request))->fd->fns->ADIOI_xxx_ReadComplete))(request,status,error_code)
00217
00218 #define ADIO_WriteComplete(request,status,error_code) \
00219 (*((*(request))->fd->fns->ADIOI_xxx_WriteComplete))(request,status,error_code)
00220
00221 #define ADIO_ReadStrided(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
00222 (*(fd->fns->ADIOI_xxx_ReadStrided))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
00223
00224 #define ADIO_WriteStrided(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
00225 (*(fd->fns->ADIOI_xxx_WriteStrided))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
00226
00227 #define ADIO_ReadStridedColl(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
00228 (*(fd->fns->ADIOI_xxx_ReadStridedColl))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
00229
00230 #define ADIO_WriteStridedColl(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
00231 (*(fd->fns->ADIOI_xxx_WriteStridedColl))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
00232
00233 #define ADIO_IreadStrided(fd,buf,count,datatype,file_ptr_type,offset,request,error_code) \
00234 (*(fd->fns->ADIOI_xxx_IreadStrided))(fd,buf,count,datatype,file_ptr_type,offset,request,error_code)
00235
00236 #define ADIO_IwriteStrided(fd,buf,count,datatype,file_ptr_type,offset,request,error_code) \
00237 (*(fd->fns->ADIOI_xxx_IwriteStrided))(fd,buf,count,datatype,file_ptr_type,offset,request,error_code)
00238
00239 #define ADIO_Flush(fd,error_code) (*(fd->fns->ADIOI_xxx_Flush))(fd,error_code)
00240
00241 #define ADIO_Resize(fd,size,error_code) \
00242 (*(fd->fns->ADIOI_xxx_Resize))(fd,size,error_code)
00243
00244 #define ADIO_Delete(filename,error_code) \
00245 (*(fd->fns->ADIOI_xxx_Delete))(filename,error_code)
00246
00247 #define ADIO_SetInfo(fd, users_info, error_code) \
00248 (*(fd->fns->ADIOI_xxx_SetInfo))(fd, users_info, error_code)
00249
00250
00251
00252
00253
00254 typedef struct {
00255 ADIO_Offset *offsets;
00256 int *lens;
00257 MPI_Aint *mem_ptrs;
00258
00259
00260 int count;
00261 } ADIOI_Access;
00262
00263
00264
00265
00266 void ADIOI_SetFunctions(ADIO_File fd);
00267 void ADIOI_Flatten_datatype(MPI_Datatype type);
00268 void ADIOI_Flatten(MPI_Datatype type, ADIOI_Flatlist_node *flat,
00269 ADIO_Offset st_offset, int *curr_index);
00270 void ADIOI_Delete_flattened(MPI_Datatype datatype);
00271 int ADIOI_Count_contiguous_blocks(MPI_Datatype type, int *curr_index);
00272 ADIOI_Async_node *ADIOI_Malloc_async_node(void);
00273 void ADIOI_Free_async_node(ADIOI_Async_node *node);
00274 void ADIOI_Add_req_to_list(ADIO_Request *request);
00275 void ADIOI_Complete_async(int *error_code);
00276 void ADIOI_Del_req_from_list(ADIO_Request *request);
00277 struct ADIOI_RequestD *ADIOI_Malloc_request(void);
00278 void ADIOI_Free_request(ADIOI_Req_node *node);
00279 void *ADIOI_Malloc_fn(size_t size, int lineno, char *fname);
00280 void *ADIOI_Calloc_fn(size_t nelem, size_t elsize, int lineno, char *fname);
00281 void *ADIOI_Realloc_fn(void *ptr, size_t size, int lineno, char *fname);
00282 void ADIOI_Free_fn(void *ptr, int lineno, char *fname);
00283 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag);
00284 void ADIOI_Get_position(ADIO_File fd, ADIO_Offset *offset);
00285 void ADIOI_Get_eof_offset(ADIO_File fd, ADIO_Offset *eof_offset);
00286 void ADIOI_Get_byte_offset(ADIO_File fd, ADIO_Offset offset, ADIO_Offset *disp);
00287
00288 void ADIOI_GEN_Flush(ADIO_File fd, int *error_code);
00289 void ADIOI_GEN_Delete(char *filename, int *error_code);
00290
00291 void ADIOI_GEN_ReadStrided(ADIO_File fd, void *buf, int count,
00292 MPI_Datatype datatype, int file_ptr_type,
00293 ADIO_Offset offset, ADIO_Status *status, int
00294 *error_code);
00295 void ADIOI_GEN_ReadStrided_naive(ADIO_File fd, void *buf, int count,
00296 MPI_Datatype buftype, int file_ptr_type,
00297 ADIO_Offset offset, ADIO_Status *status, int
00298 *error_code);
00299 void ADIOI_GEN_WriteStrided(ADIO_File fd, void *buf, int count,
00300 MPI_Datatype datatype, int file_ptr_type,
00301 ADIO_Offset offset, ADIO_Status *status, int
00302 *error_code);
00303 void ADIOI_GEN_ReadStridedColl(ADIO_File fd, void *buf, int count,
00304 MPI_Datatype datatype, int file_ptr_type,
00305 ADIO_Offset offset, ADIO_Status *status, int
00306 *error_code);
00307 void ADIOI_GEN_WriteStridedColl(ADIO_File fd, void *buf, int count,
00308 MPI_Datatype datatype, int file_ptr_type,
00309 ADIO_Offset offset, ADIO_Status *status, int
00310 *error_code);
00311 void ADIOI_Calc_my_off_len(ADIO_File fd, int bufcount, MPI_Datatype
00312 datatype, int file_ptr_type, ADIO_Offset
00313 offset, ADIO_Offset **offset_list_ptr, int
00314 **len_list_ptr, ADIO_Offset *start_offset_ptr,
00315 ADIO_Offset *end_offset_ptr, int
00316 *contig_access_count_ptr);
00317 void ADIOI_Calc_file_domains(ADIO_Offset *st_offsets, ADIO_Offset
00318 *end_offsets, int nprocs, int nprocs_for_coll,
00319 ADIO_Offset *min_st_offset_ptr,
00320 ADIO_Offset **fd_start_ptr, ADIO_Offset
00321 **fd_end_ptr, ADIO_Offset *fd_size_ptr);
00322 int ADIOI_Calc_aggregator(ADIO_File fd,
00323 ADIO_Offset off,
00324 ADIO_Offset min_off,
00325 ADIO_Offset *len,
00326 ADIO_Offset fd_size,
00327 ADIO_Offset *fd_start,
00328 ADIO_Offset *fd_end);
00329 void ADIOI_Calc_my_req(ADIO_File fd, ADIO_Offset *offset_list,
00330 int *len_list, int
00331 contig_access_count, ADIO_Offset
00332 min_st_offset, ADIO_Offset *fd_start,
00333 ADIO_Offset *fd_end, ADIO_Offset fd_size,
00334 int nprocs,
00335 int *count_my_req_procs_ptr,
00336 int **count_my_req_per_proc_ptr,
00337 ADIOI_Access **my_req_ptr,
00338 int **buf_idx_ptr);
00339 void ADIOI_Calc_others_req(ADIO_File fd, int count_my_req_procs,
00340 int *count_my_req_per_proc,
00341 ADIOI_Access *my_req,
00342 int nprocs, int myrank,
00343 int *count_others_req_procs_ptr,
00344 ADIOI_Access **others_req_ptr);
00345 ADIO_Offset ADIOI_GEN_SeekIndividual(ADIO_File fd, ADIO_Offset offset,
00346 int whence, int *error_code);
00347 void ADIOI_GEN_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code);
00348 void ADIOI_Shfp_fname(ADIO_File fd, int rank);
00349 int ADIOI_Error(ADIO_File fd, int error_code, char *string);
00350 int MPIR_Err_setmsg( int, int, const char *, const char *, const char *, ...);
00351 int ADIOI_End_call(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state);
00352 int MPIR_Status_set_bytes(MPI_Status *status, MPI_Datatype datatype, int nbytes);
00353 int ADIOI_Uses_generic_read(ADIO_File fd);
00354 int ADIOI_Uses_generic_write(ADIO_File fd);
00355
00356
00357
00358
00359 #if (defined(HFS) || defined(XFS))
00360
00361 # define ADIOI_WRITE_LOCK(fd, offset, whence, len) \
00362 if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
00363 ADIOI_Set_lock64((fd)->fd_sys, F_SETLKW64, F_WRLCK, offset, whence, len);\
00364 else ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_WRLCK, offset, whence, len)
00365
00366 # define ADIOI_READ_LOCK(fd, offset, whence, len) \
00367 if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
00368 ADIOI_Set_lock64((fd)->fd_sys, F_SETLKW64, F_RDLCK, offset, whence, len);\
00369 else ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_RDLCK, offset, whence, len)
00370
00371 # define ADIOI_UNLOCK(fd, offset, whence, len) \
00372 if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
00373 ADIOI_Set_lock64((fd)->fd_sys, F_SETLK64, F_UNLCK, offset, whence, len); \
00374 else ADIOI_Set_lock((fd)->fd_sys, F_SETLK, F_UNLCK, offset, whence, len)
00375
00376 #elif (defined(ROMIO_NTFS))
00377
00378 #define ADIOI_LOCK_CMD 0
00379 #define ADIOI_UNLOCK_CMD 1
00380
00381 # define ADIOI_WRITE_LOCK(fd, offset, whence, len) \
00382 ADIOI_Set_lock((fd)->fd_sys, ADIOI_LOCK_CMD, LOCKFILE_EXCLUSIVE_LOCK, offset, whence, len)
00383 # define ADIOI_READ_LOCK(fd, offset, whence, len) \
00384 ADIOI_Set_lock((fd)->fd_sys, ADIOLOCK, 0, offset, whence, len)
00385 # define ADIOI_UNLOCK(fd, offset, whence, len) \
00386 ADIOI_Set_lock((fd)->fd_sys, ADIOI_UNLOCK_CMD, LOCKFILE_FAIL_IMMEDIATELY, offset, whence, len)
00387
00388 #else
00389
00390 # define ADIOI_WRITE_LOCK(fd, offset, whence, len) \
00391 ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_WRLCK, offset, whence, len)
00392 # define ADIOI_READ_LOCK(fd, offset, whence, len) \
00393 ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_RDLCK, offset, whence, len)
00394 # define ADIOI_UNLOCK(fd, offset, whence, len) \
00395 ADIOI_Set_lock((fd)->fd_sys, F_SETLK, F_UNLCK, offset, whence, len)
00396
00397 #endif
00398
00399 int ADIOI_Set_lock(FDTYPE fd_sys, int cmd, int type, ADIO_Offset offset, int whence, ADIO_Offset len);
00400 int ADIOI_Set_lock64(FDTYPE fd_sys, int cmd, int type, ADIO_Offset offset, int whence, ADIO_Offset len);
00401
00402 #define ADIOI_Malloc(a) ADIOI_Malloc_fn(a,__LINE__,__FILE__)
00403 #define ADIOI_Calloc(a,b) ADIOI_Calloc_fn(a,b,__LINE__,__FILE__)
00404 #define ADIOI_Realloc(a,b) ADIOI_Realloc_fn(a,b,__LINE__,__FILE__)
00405 #define ADIOI_Free(a) ADIOI_Free_fn(a,__LINE__,__FILE__)
00406
00407 #define FPRINTF fprintf
00408
00409 #ifndef HAVE_STRERROR
00410 # ifdef HAVE_SYSERRLIST
00411 extern char *sys_errlist[];
00412 # define strerror(n) sys_errlist[n]
00413 # else
00414 # define PRINT_ERR_MSG
00415 # endif
00416 #endif
00417
00418 #include "adioi_error.h"
00419
00420 #endif
00421