root/ompi/mca/io/romio321/romio/adio/include/adioi.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 
   9 /* contains general definitions, declarations, and macros internal to
  10    the ADIO implementation, though independent of the underlying file
  11    system. This file is included in adio.h */ 
  12 
  13 /* Functions and datataypes that are "internal" to the ADIO implementation 
  14    prefixed ADIOI_. Functions and datatypes that are part of the
  15    "externally visible" (documented) ADIO interface are prefixed ADIO_.
  16 
  17    An implementation of MPI-IO, or any other high-level interface, should
  18    not need to use any of the ADIOI_ functions/datatypes. 
  19    Only someone implementing ADIO on a new file system, or modifying 
  20    an existing ADIO implementation, would need to use the ADIOI_
  21    functions/datatypes. */
  22 
  23 
  24 #ifndef ADIOI_INCLUDE
  25 #define ADIOI_INCLUDE
  26 /* used to keep track of hint/info values.
  27  * Note that there are a lot of int-sized values in here...they are
  28  * used as int-sized entities other places as well.  This would be a 
  29  * problem on 32-bit systems using > 2GB files in some cases...
  30  */
  31 struct ADIOI_Hints_struct {
  32     int initialized;
  33     int striping_factor;
  34     int striping_unit;
  35     int cb_read;
  36     int cb_write;
  37     int cb_nodes;
  38     int cb_buffer_size;
  39     int cb_pfr;
  40     int cb_fr_type;
  41     int cb_fr_alignment;
  42     int cb_ds_threshold;
  43     int cb_alltoall;
  44     int ds_read;
  45     int ds_write;
  46     int no_indep_rw;
  47     int ind_rd_buffer_size;
  48     int ind_wr_buffer_size;
  49     int deferred_open;
  50     int min_fdomain_size;
  51     char *cb_config_list;
  52     int *ranklist;
  53     union {
  54             struct {
  55                     int listio_read;
  56                     int listio_write;
  57             } pvfs;
  58             struct {
  59                     int debugmask;
  60                     int posix_read;
  61                     int posix_write;
  62                     int listio_read;
  63                     int listio_write;
  64                     int dtype_read;
  65                     int dtype_write;
  66             } pvfs2;
  67             struct {
  68                     int start_iodevice;
  69                     int co_ratio;
  70                     int coll_threshold;
  71                     int ds_in_coll;
  72             } lustre;
  73                 struct {
  74                         unsigned read_chunk_sz; /* chunk size for direct reads */
  75                         unsigned write_chunk_sz; /* chunk size for direct writes */
  76                 } xfs;
  77         struct {
  78             int *bridgelist; /* list of all bride ranks */
  79             int *bridgelistnum; /* each entry here is the number of aggregators
  80                                    associated with the bridge rank of the same
  81                                    index in bridgelist */
  82             int numbridges; /* total number of bridges */
  83         } bg;
  84     } fs_hints;
  85 
  86 };
  87 
  88 typedef struct ADIOI_Datarep {
  89     char *name;
  90     void *state;
  91     MPI_Datarep_extent_function *extent_fn;
  92     MPI_Datarep_conversion_function *read_conv_fn;
  93     MPI_Datarep_conversion_function *write_conv_fn;
  94     struct ADIOI_Datarep *next; /* pointer to next datarep */
  95 } ADIOI_Datarep;
  96 
  97 /* Values for use with cb_read, cb_write, ds_read, and ds_write 
  98  * and some fs-specific hints
  99    (IBM xlc, Compaq Tru64 compilers object to a comma after the last item)
 100    (that's just wrong)
 101  */
 102 enum {
 103     ADIOI_HINT_AUTO    = 0,
 104     ADIOI_HINT_ENABLE  = 1,
 105     ADIOI_HINT_DISABLE = 2
 106 };
 107 
 108 /* flattened datatypes. Each datatype is stored as a node of a
 109    globally accessible linked list. Once attribute caching on a
 110    datatype is available (in MPI-2), that should be used instead. */  
 111 
 112 typedef struct ADIOI_Fl_node {  
 113     MPI_Datatype type;
 114     MPI_Count count;                   /* no. of contiguous blocks */
 115     ADIO_Offset *blocklens;      /* array of contiguous block lengths (bytes)*/
 116     ADIO_Offset *indices;        /* array of byte offsets of each block */
 117     /* the type processing code in ROMIO loops through the flattened
 118      * representation to tile file views.  so, we cannot simply indicate a
 119      * lower bound and upper bound with entries here -- those are instead
 120      * indicated by offset-length pairs with zero length.  In order to deal
 121      * with repeatedly resetting the LB and UB though (as in resized of
 122      * resized, or struct of resized, perhaps?), indicate where in the
 123      * tuple-stream the lb and ub parts are kept
 124      * (-1 indicates "not explicitly set") */
 125     ADIO_Offset lb_idx;
 126     ADIO_Offset ub_idx;
 127     struct ADIOI_Fl_node *next;  /* pointer to next node */
 128 } ADIOI_Flatlist_node;
 129 
 130 #ifdef ROMIO_PVFS2
 131 #include <pvfs2.h>
 132 #endif
 133 typedef struct ADIOI_AIO_req_str {
 134         /* very wierd: if this MPI_Request is a pointer, some C++ compilers
 135          * will clobber it when the MPICH C++ bindings are used */
 136         MPI_Request req;
 137         MPI_Offset nbytes;
 138         /* should probably make this a union */
 139 #ifdef ROMIO_HAVE_WORKING_AIO
 140         struct aiocb *aiocbp;
 141 #endif
 142 #ifdef ROMIO_PVFS2
 143         PVFS_sys_op_id op_id;
 144         PVFS_sysresp_io resp_io;
 145         PVFS_Request file_req;
 146         PVFS_Request mem_req;
 147 #endif
 148 #ifdef ROMIO_NTFS
 149     /* Ptr to Overlapped struct */
 150     LPOVERLAPPED    lpOvl;
 151     /* Ptr to file handle */
 152         HANDLE fd;
 153 #endif
 154 } ADIOI_AIO_Request;
 155 
 156 struct ADIOI_Fns_struct {
 157     void (*ADIOI_xxx_Open) (ADIO_File fd, int *error_code);
 158     void (*ADIOI_xxx_OpenColl) (ADIO_File fd, int rank, 
 159                     int access_mode, int *error_code);
 160     void (*ADIOI_xxx_ReadContig) (ADIO_File fd, void *buf, int count,
 161                    MPI_Datatype datatype, int file_ptr_type,
 162                    ADIO_Offset offset, ADIO_Status *status, int *error_code);
 163     void (*ADIOI_xxx_WriteContig) (ADIO_File fd, const void *buf, int count,
 164                    MPI_Datatype datatype, int file_ptr_type,
 165                    ADIO_Offset offset, ADIO_Status *status, int *error_code);  
 166     void (*ADIOI_xxx_ReadStridedColl) (ADIO_File fd, void *buf, int count,
 167                MPI_Datatype datatype, int file_ptr_type,
 168                ADIO_Offset offset, ADIO_Status *status, int *error_code);
 169     void (*ADIOI_xxx_WriteStridedColl) (ADIO_File fd, const void *buf, int count,
 170                MPI_Datatype datatype, int file_ptr_type,
 171                ADIO_Offset offset, ADIO_Status *status, int *error_code);
 172     ADIO_Offset (*ADIOI_xxx_SeekIndividual) (ADIO_File fd, ADIO_Offset offset, 
 173                        int whence, int *error_code);
 174     void (*ADIOI_xxx_Fcntl) (ADIO_File fd, int flag, 
 175                              ADIO_Fcntl_t *fcntl_struct, int *error_code); 
 176     void (*ADIOI_xxx_SetInfo) (ADIO_File fd, MPI_Info users_info, 
 177                                int *error_code);
 178     void (*ADIOI_xxx_ReadStrided) (ADIO_File fd, void *buf, int count,
 179                MPI_Datatype datatype, int file_ptr_type,
 180                ADIO_Offset offset, ADIO_Status *status, int *error_code);
 181     void (*ADIOI_xxx_WriteStrided) (ADIO_File fd, const void *buf, int count,
 182                MPI_Datatype datatype, int file_ptr_type,
 183                ADIO_Offset offset, ADIO_Status *status, int *error_code);
 184     void (*ADIOI_xxx_Close) (ADIO_File fd, int *error_code);
 185     void (*ADIOI_xxx_IreadContig) (ADIO_File fd, void *buf, int count, 
 186                    MPI_Datatype datatype, int file_ptr_type, 
 187                    ADIO_Offset offset, ADIO_Request *request, int *error_code);
 188     void (*ADIOI_xxx_IwriteContig) (ADIO_File fd, const void *buf, int count,
 189                    MPI_Datatype datatype, int file_ptr_type,
 190                    ADIO_Offset offset, ADIO_Request *request, int *error_code);
 191     int (*ADIOI_xxx_ReadDone) (ADIO_Request *request, ADIO_Status *status, 
 192                int *error_code); 
 193     int (*ADIOI_xxx_WriteDone) (ADIO_Request *request, ADIO_Status *status, 
 194                int *error_code);
 195     void (*ADIOI_xxx_ReadComplete) (ADIO_Request *request, ADIO_Status *status, 
 196                int *error_code); 
 197     void (*ADIOI_xxx_WriteComplete) (ADIO_Request *request, ADIO_Status *status,
 198                int *error_code); 
 199     void (*ADIOI_xxx_IreadStrided) (ADIO_File fd, void *buf, int count,
 200                MPI_Datatype datatype, int file_ptr_type,
 201                ADIO_Offset offset, ADIO_Request *request, int *error_code);
 202     void (*ADIOI_xxx_IwriteStrided) (ADIO_File fd, const void *buf, int count,
 203                MPI_Datatype datatype, int file_ptr_type,
 204                ADIO_Offset offset, ADIO_Request *request, int *error_code);
 205     void (*ADIOI_xxx_Flush) (ADIO_File fd, int *error_code); 
 206     void (*ADIOI_xxx_Resize) (ADIO_File fd, ADIO_Offset size, int *error_code);
 207     void (*ADIOI_xxx_Delete) (const char *filename, int *error_code);
 208     int  (*ADIOI_xxx_Feature) (ADIO_File fd, int flag);
 209     const char *fsname;
 210     void (*ADIOI_xxx_IreadStridedColl) (ADIO_File fd, void *buf, int count,
 211            MPI_Datatype datatype, int file_ptr_type,
 212            ADIO_Offset offset, ADIO_Request *request, int *error_code);
 213     void (*ADIOI_xxx_IwriteStridedColl) (ADIO_File fd, const void *buf,
 214            int count, MPI_Datatype datatype, int file_ptr_type,
 215            ADIO_Offset offset, ADIO_Request *request, int *error_code);
 216 };
 217 
 218 /* optypes for ADIO_RequestD */
 219 #define ADIOI_READ                26
 220 #define ADIOI_WRITE               27
 221 
 222 #define ADIOI_MIN(a, b) ((a) < (b) ? (a) : (b))
 223 #define ADIOI_MAX(a, b) ((a) > (b) ? (a) : (b))
 224 /* thanks stackoverflow:
 225  * http://stackoverflow.com/questions/3982348/implement-generic-swap-macro-in-c */
 226 #define ADIOI_SWAP(x, y, T) do { T temp##x##y = x; x = y; y = temp##x##y; } while (0);
 227 
 228 #define ADIOI_PREALLOC_BUFSZ      16777216    /* buffer size used to 
 229                                                 preallocate disk space */
 230 
 231 
 232 /* default values for some hints */
 233     /* buffer size for collective I/O = 16 MB */
 234 #define ADIOI_CB_BUFFER_SIZE_DFLT         "16777216"
 235     /* buffer size for data sieving in independent reads = 4MB */
 236 #define ADIOI_IND_RD_BUFFER_SIZE_DFLT     "4194304"
 237     /* buffer size for data sieving in independent writes = 512KB. default is
 238        smaller than for reads, because write requires read-modify-write
 239        with file locking. If buffer size is large there is more contention 
 240        for locks. */
 241 #define ADIOI_IND_WR_BUFFER_SIZE_DFLT     "524288"
 242     /* use one process per processor name by default */
 243 #define ADIOI_CB_CONFIG_LIST_DFLT "*:1"
 244 
 245 
 246 /* some of the ADIO functions are macro-replaced */
 247 
 248 #define ADIOI_OpenColl(fd, rank, access_mode, error_code) \
 249         (*(fd->fns->ADIOI_xxx_OpenColl))(fd, rank, access_mode, error_code)
 250 
 251 #define ADIO_ReadContig(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
 252         (*(fd->fns->ADIOI_xxx_ReadContig))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
 253 
 254 #define ADIO_WriteContig(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
 255         (*(fd->fns->ADIOI_xxx_WriteContig))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
 256 
 257 #define ADIO_SeekIndividual(fd,offset,whence,error_code) \
 258         (*(fd->fns->ADIOI_xxx_SeekIndividual))(fd,offset,whence,error_code)
 259 
 260 #define ADIO_Fcntl(fd,flag,fcntl_struct,error_code) \
 261         (*(fd->fns->ADIOI_xxx_Fcntl))(fd,flag,fcntl_struct,error_code)
 262 
 263 #define ADIO_IreadContig(fd,buf,count,datatype,file_ptr_type,offset,request,error_code) \
 264         (*(fd->fns->ADIOI_xxx_IreadContig))(fd,buf,count,datatype,file_ptr_type,offset,request,error_code)
 265 
 266 #define ADIO_IwriteContig(fd,buf,count,datatype,file_ptr_type,offset,request,error_code) \
 267         (*(fd->fns->ADIOI_xxx_IwriteContig))(fd,buf,count,datatype,file_ptr_type,offset,request,error_code)
 268 
 269 /* in these routines a pointer to request is passed */
 270 #define ADIO_ReadDone(request,status,error_code) \
 271         (*((*(request))->fd->fns->ADIOI_xxx_ReadDone))(request,status,error_code)
 272 
 273 #define ADIO_WriteDone(request,status,error_code) \
 274         (*((*(request))->fd->fns->ADIOI_xxx_WriteDone))(request,status,error_code)
 275 
 276 #define ADIO_ReadIcomplete(request,status,error_code) \
 277         (*((*(request))->fd->fns->ADIOI_xxx_ReadIcomplete))(request,status,error_code)
 278 
 279 #define ADIO_WriteIcomplete(request,status,error_code) \
 280         (*((*(request))->fd->fns->ADIOI_xxx_WriteIcomplete))(request,status,error_code)
 281 
 282 #define ADIO_ReadComplete(request,status,error_code) \
 283         (*((*(request))->fd->fns->ADIOI_xxx_ReadComplete))(request,status,error_code)
 284 
 285 #define ADIO_WriteComplete(request,status,error_code) \
 286         (*((*(request))->fd->fns->ADIOI_xxx_WriteComplete))(request,status,error_code)
 287 
 288 #define ADIO_ReadStrided(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
 289         (*(fd->fns->ADIOI_xxx_ReadStrided))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
 290 
 291 #define ADIO_WriteStrided(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
 292         (*(fd->fns->ADIOI_xxx_WriteStrided))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
 293 
 294 #define ADIO_ReadStridedColl(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
 295         (*(fd->fns->ADIOI_xxx_ReadStridedColl))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
 296 
 297 #define ADIO_WriteStridedColl(fd,buf,count,datatype,file_ptr_type,offset,status,error_code) \
 298         (*(fd->fns->ADIOI_xxx_WriteStridedColl))(fd,buf,count,datatype,file_ptr_type,offset,status,error_code)
 299 
 300 #define ADIO_IreadStrided(fd,buf,count,datatype,file_ptr_type,offset,request,error_code) \
 301         (*(fd->fns->ADIOI_xxx_IreadStrided))(fd,buf,count,datatype,file_ptr_type,offset,request,error_code)
 302 
 303 #define ADIO_IwriteStrided(fd,buf,count,datatype,file_ptr_type,offset,request,error_code) \
 304         (*(fd->fns->ADIOI_xxx_IwriteStrided))(fd,buf,count,datatype,file_ptr_type,offset,request,error_code)
 305 
 306 #define ADIO_IreadStridedColl(fd,buf,count,datatype,file_ptr_type,offset,request,error_code) \
 307         (*(fd->fns->ADIOI_xxx_IreadStridedColl))(fd,buf,count,datatype,file_ptr_type,offset,request,error_code)
 308 
 309 #define ADIO_IwriteStridedColl(fd,buf,count,datatype,file_ptr_type,offset,request,error_code) \
 310         (*(fd->fns->ADIOI_xxx_IwriteStridedColl))(fd,buf,count,datatype,file_ptr_type,offset,request,error_code)
 311 
 312 #define ADIO_Flush(fd,error_code) (*(fd->fns->ADIOI_xxx_Flush))(fd,error_code)
 313 
 314 #define ADIO_Resize(fd,size,error_code) \
 315         (*(fd->fns->ADIOI_xxx_Resize))(fd,size,error_code)
 316 
 317 #define ADIO_Delete(filename,error_code) \
 318         (*(fd->fns->ADIOI_xxx_Delete))(filename,error_code)
 319 
 320 #define ADIO_SetInfo(fd, users_info, error_code) \
 321         (*(fd->fns->ADIOI_xxx_SetInfo))(fd, users_info, error_code)
 322 
 323 #define ADIO_Feature(fd, flag) \
 324         (*(fd->fns->ADIOI_xxx_Feature))(fd, flag)
 325 
 326 
 327 /* structure for storing access info of this process's request 
 328    from the file domain of other processes, and vice-versa. used 
 329    as array of structures indexed by process number. */
 330 typedef struct {
 331     ADIO_Offset *offsets;   /* array of offsets */
 332     ADIO_Offset *lens;      /* array of lengths */
 333     MPI_Aint *mem_ptrs;     /* array of pointers. used in the read/write
 334                                phase to indicate where the data
 335                                is stored in memory */
 336     int count;             /* size of above arrays */
 337 } ADIOI_Access;
 338 
 339 /* structure for storing generic offset/length pairs.  used to describe
 340    file realms among other things */
 341 typedef struct {
 342     ADIO_Offset *offsets; /* array of offsets */
 343     ADIO_Offset *lens;    /* array of lengths */
 344     int count;            /* size of above arrays */
 345 } ADIOI_Offlen;
 346 
 347 /* prototypes for ADIO internal functions */
 348 
 349 
 350 int ADIOI_Type_get_envelope (MPI_Datatype datatype, int *num_integers,
 351                              int *num_addresses, int *num_datatypes, int *combiner);
 352 int ADIOI_Type_get_contents (MPI_Datatype datatype, int max_integers,
 353                              int max_addresses, int max_datatypes, int array_of_integers[],
 354                              MPI_Aint array_of_addresses[], MPI_Datatype array_of_datatypes[]);
 355 void ADIOI_SetFunctions(ADIO_File fd);
 356 void ADIOI_Flatten_datatype(MPI_Datatype type);
 357 void ADIOI_Flatten(MPI_Datatype type, ADIOI_Flatlist_node *flat,
 358                   ADIO_Offset st_offset, MPI_Count *curr_index);
 359 void ADIOI_Delete_flattened(MPI_Datatype datatype);
 360 ADIOI_Flatlist_node * ADIOI_Flatten_and_find(MPI_Datatype);
 361 MPI_Count ADIOI_Count_contiguous_blocks(MPI_Datatype type, MPI_Count *curr_index);
 362 void ADIOI_Complete_async(int *error_code);
 363 void *ADIOI_Malloc_fn(size_t size, int lineno, const char *fname);
 364 void *ADIOI_Calloc_fn(size_t nelem, size_t elsize, int lineno, const char *fname);
 365 void *ADIOI_Realloc_fn(void *ptr, size_t size, int lineno, const char *fname);
 366 void ADIOI_Free_fn(void *ptr, int lineno, const char *fname);
 367 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag);
 368 void ADIOI_Get_position(ADIO_File fd, ADIO_Offset *offset);
 369 void ADIOI_Get_eof_offset(ADIO_File fd, ADIO_Offset *eof_offset);
 370 void ADIOI_Get_byte_offset(ADIO_File fd, ADIO_Offset offset,
 371                            ADIO_Offset *disp);
 372 void ADIOI_process_system_hints(ADIO_File fd, MPI_Info info);
 373 void ADIOI_incorporate_system_hints(MPI_Info info, MPI_Info sysinfo, 
 374                 MPI_Info *new_info);
 375 void ADIOI_Info_print_keyvals(MPI_Info info);
 376 
 377 
 378 void ADIOI_GEN_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct,
 379                      int *error_code);
 380 void ADIOI_GEN_Flush(ADIO_File fd, int *error_code);
 381 void ADIOI_GEN_OpenColl(ADIO_File fd, int rank, 
 382                 int access_mode, int *error_code);
 383 void ADIOI_SCALEABLE_OpenColl(ADIO_File fd, int rank, 
 384                 int access_mode, int *error_code);
 385 void ADIOI_FAILSAFE_OpenColl(ADIO_File fd, int rank, 
 386                 int access_mode, int *error_code);
 387 void ADIOI_GEN_Delete(const char *filename, int *error_code);
 388 void ADIOI_GEN_ReadContig(ADIO_File fd, void *buf, int count, 
 389                           MPI_Datatype datatype, int file_ptr_type,
 390                           ADIO_Offset offset, ADIO_Status *status,
 391                           int *error_code);
 392 int ADIOI_GEN_aio(ADIO_File fd, void *buf, int len, ADIO_Offset offset,
 393                   int wr, MPI_Request *request);
 394 void ADIOI_GEN_IreadContig(ADIO_File fd, void *buf, int count, 
 395                            MPI_Datatype datatype, int file_ptr_type,
 396                            ADIO_Offset offset, ADIO_Request *request,
 397                            int *error_code);
 398 void ADIOI_GEN_WriteContig(ADIO_File fd, const void *buf, int count,
 399                            MPI_Datatype datatype, int file_ptr_type,
 400                            ADIO_Offset offset, ADIO_Status *status,
 401                            int *error_code);
 402 void ADIOI_GEN_IwriteContig(ADIO_File fd, const void *buf, int count,
 403                             MPI_Datatype datatype, int file_ptr_type,
 404                             ADIO_Offset offset, ADIO_Request *request,
 405                             int *error_code);
 406 void ADIOI_GEN_ReadStrided(ADIO_File fd, void *buf, int count,
 407                            MPI_Datatype datatype, int file_ptr_type,
 408                            ADIO_Offset offset, ADIO_Status *status, int
 409                            *error_code);
 410 void ADIOI_GEN_IreadStrided(ADIO_File fd, void *buf, int count,
 411                             MPI_Datatype datatype, int file_ptr_type,
 412                             ADIO_Offset offset, ADIO_Request *request, int
 413                             *error_code);
 414 void ADIOI_GEN_IwriteStrided(ADIO_File fd, const void *buf, int count,
 415                              MPI_Datatype datatype, int file_ptr_type,
 416                              ADIO_Offset offset, ADIO_Request *request, int
 417                              *error_code);
 418 int ADIOI_GEN_IODone(ADIO_Request *request, ADIO_Status *status,
 419                      int *error_code);
 420 void ADIOI_GEN_IOComplete(ADIO_Request *request, ADIO_Status *status,
 421                           int *error_code);
 422 int ADIOI_GEN_aio_poll_fn(void *extra_state, ADIO_Status *status);
 423 int ADIOI_GEN_aio_wait_fn(int count, void **array_of_states, double timeout, 
 424                 ADIO_Status *status);
 425 int ADIOI_GEN_aio_query_fn(void *extra_state, ADIO_Status *status);
 426 int ADIOI_GEN_aio_free_fn(void *extra_state);
 427 int ADIOI_GEN_Feature(ADIO_File fd, int feature);
 428 
 429 void ADIOI_GEN_ReadStrided_naive(ADIO_File fd, void *buf, int count,
 430                        MPI_Datatype buftype, int file_ptr_type,
 431                        ADIO_Offset offset, ADIO_Status *status, int
 432                        *error_code);
 433 void ADIOI_GEN_WriteStrided(ADIO_File fd, const void *buf, int count,
 434                        MPI_Datatype datatype, int file_ptr_type,
 435                        ADIO_Offset offset, ADIO_Status *status, int
 436                        *error_code);
 437 void ADIOI_GEN_WriteStrided_naive(ADIO_File fd, const void *buf, int count,
 438                        MPI_Datatype datatype, int file_ptr_type,
 439                        ADIO_Offset offset, ADIO_Status *status, int
 440                        *error_code);
 441 void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, const void *buf, int count,
 442                        MPI_Datatype datatype, int file_ptr_type,
 443                        ADIO_Offset offset, ADIO_Status *status, int
 444                        *error_code);
 445 void ADIOI_GEN_ReadStridedColl(ADIO_File fd, void *buf, int count,
 446                        MPI_Datatype datatype, int file_ptr_type,
 447                        ADIO_Offset offset, ADIO_Status *status, int
 448                        *error_code);
 449 #ifdef HAVE_MPI_GREQUEST_EXTENSIONS
 450 void ADIOI_GEN_IreadStridedColl(ADIO_File fd, void *buf, int count,
 451                        MPI_Datatype datatype, int file_ptr_type,
 452                        ADIO_Offset offset, MPI_Request *request,
 453                        int *error_code);
 454 #else
 455 #define ADIOI_GEN_IreadStridedColl NULL
 456 #endif
 457 void ADIOI_GEN_WriteStridedColl(ADIO_File fd, const void *buf, int count,
 458                        MPI_Datatype datatype, int file_ptr_type,
 459                        ADIO_Offset offset, ADIO_Status *status, int
 460                        *error_code);
 461 #ifdef HAVE_MPI_GREQUEST_EXTENSIONS
 462 void ADIOI_GEN_IwriteStridedColl(ADIO_File fd, const void *buf, int count,
 463                        MPI_Datatype datatype, int file_ptr_type,
 464                        ADIO_Offset offset, MPI_Request *request,
 465                        int *error_code);
 466 #else
 467 #define ADIOI_GEN_IwriteStridedColl NULL
 468 #endif
 469 void ADIOI_Calc_my_off_len(ADIO_File fd, int bufcount, MPI_Datatype
 470                             datatype, int file_ptr_type, ADIO_Offset 
 471                             offset, ADIO_Offset **offset_list_ptr, ADIO_Offset
 472                             **len_list_ptr, ADIO_Offset *start_offset_ptr,
 473                             ADIO_Offset *end_offset_ptr, int
 474                            *contig_access_count_ptr);
 475 void ADIOI_Calc_file_domains(ADIO_Offset *st_offsets, ADIO_Offset
 476                              *end_offsets, int nprocs, int nprocs_for_coll,
 477                              ADIO_Offset *min_st_offset_ptr,
 478                              ADIO_Offset **fd_start_ptr, ADIO_Offset 
 479                              **fd_end_ptr, int min_fd_size, 
 480                              ADIO_Offset *fd_size_ptr,
 481                              int striping_unit);
 482 int ADIOI_Calc_aggregator(ADIO_File fd,
 483                                  ADIO_Offset off,
 484                                  ADIO_Offset min_off,
 485                                  ADIO_Offset *len,
 486                                  ADIO_Offset fd_size,
 487                                  ADIO_Offset *fd_start,
 488                                  ADIO_Offset *fd_end);
 489 void ADIOI_Calc_my_req(ADIO_File fd, ADIO_Offset *offset_list, 
 490                             ADIO_Offset *len_list, int
 491                             contig_access_count, ADIO_Offset 
 492                             min_st_offset, ADIO_Offset *fd_start,
 493                             ADIO_Offset *fd_end, ADIO_Offset fd_size,
 494                             int nprocs,
 495                             int *count_my_req_procs_ptr,
 496                             int **count_my_req_per_proc_ptr,
 497                             ADIOI_Access **my_req_ptr,
 498                             int **buf_idx_ptr);
 499 void ADIOI_Calc_others_req(ADIO_File fd, int count_my_req_procs, 
 500                                 int *count_my_req_per_proc,
 501                                 ADIOI_Access *my_req, 
 502                                 int nprocs, int myrank,
 503                                 int *count_others_req_procs_ptr,
 504                                 ADIOI_Access **others_req_ptr);  
 505 
 506 
 507 /* Nonblocking Collective I/O internals */
 508 typedef enum {
 509     ADIOI_IRC_STATE_GEN_IREADSTRIDEDCOLL,
 510     ADIOI_IRC_STATE_GEN_IREADSTRIDEDCOLL_INDIO,
 511     ADIOI_IRC_STATE_ICALC_OTHERS_REQ,
 512     ADIOI_IRC_STATE_ICALC_OTHERS_REQ_MAIN,
 513     ADIOI_IRC_STATE_IREAD_AND_EXCH,
 514     ADIOI_IRC_STATE_IREAD_AND_EXCH_L1_BEGIN,
 515     ADIOI_IRC_STATE_R_IEXCHANGE_DATA,
 516     ADIOI_IRC_STATE_R_IEXCHANGE_DATA_RECV,
 517     ADIOI_IRC_STATE_R_IEXCHANGE_DATA_FILL,
 518     ADIOI_IRC_STATE_COMPLETE
 519 } ADIOI_IRC_State;
 520 
 521 typedef enum {
 522     ADIOI_IWC_STATE_GEN_IWRITESTRIDEDCOLL,
 523     ADIOI_IWC_STATE_GEN_IWRITESTRIDEDCOLL_INDIO,
 524     ADIOI_IWC_STATE_GEN_IWRITESTRIDEDCOLL_BCAST,
 525     ADIOI_IWC_STATE_ICALC_OTHERS_REQ,
 526     ADIOI_IWC_STATE_ICALC_OTHERS_REQ_MAIN,
 527     ADIOI_IWC_STATE_IEXCH_AND_WRITE,
 528     ADIOI_IWC_STATE_IEXCH_AND_WRITE_L1_BODY,
 529     ADIOI_IWC_STATE_W_IEXCHANGE_DATA,
 530     ADIOI_IWC_STATE_W_IEXCHANGE_DATA_HOLE,
 531     ADIOI_IWC_STATE_W_IEXCHANGE_DATA_SEND,
 532     ADIOI_IWC_STATE_W_IEXCHANGE_DATA_WAIT,
 533     ADIOI_IWC_STATE_COMPLETE
 534 } ADIOI_IWC_State;
 535 
 536 typedef struct ADIOI_NBC_Request                ADIOI_NBC_Request;
 537 
 538 typedef struct ADIOI_GEN_IreadStridedColl_vars  ADIOI_GEN_IreadStridedColl_vars;
 539 typedef struct ADIOI_Iread_and_exch_vars        ADIOI_Iread_and_exch_vars;
 540 typedef struct ADIOI_R_Iexchange_data_vars      ADIOI_R_Iexchange_data_vars;
 541 
 542 typedef struct ADIOI_GEN_IwriteStridedColl_vars ADIOI_GEN_IwriteStridedColl_vars;
 543 typedef struct ADIOI_Iexch_and_write_vars       ADIOI_Iexch_and_write_vars;
 544 typedef struct ADIOI_W_Iexchange_data_vars      ADIOI_W_Iexchange_data_vars;
 545 
 546 typedef struct ADIOI_Icalc_others_req_vars {
 547     /* requests */
 548     MPI_Request req1;
 549     MPI_Request *req2;
 550     int num_req2;
 551 
 552     /* parameters */
 553     ADIO_File fd;
 554     int count_my_req_procs;
 555     int *count_my_req_per_proc;
 556     ADIOI_Access *my_req;
 557     int nprocs;
 558     int myrank;
 559     int *count_others_req_procs_ptr;
 560     ADIOI_Access **others_req_ptr;
 561 
 562     /* stack variables */
 563     int *count_others_req_per_proc;
 564     int count_others_req_procs;
 565     ADIOI_Access *others_req;
 566 
 567     /* next function to be called */
 568     void (*next_fn)(ADIOI_NBC_Request *, int *);
 569 } ADIOI_Icalc_others_req_vars;
 570 
 571 struct ADIOI_NBC_Request {
 572     int rdwr;           /* ADIOI_READ or ADIOI_WRITE */
 573     MPI_Request req;    /* MPIX_Grequest */
 574     MPI_Count nbytes;   /* data read or written */
 575 
 576     union {
 577         struct {
 578             ADIOI_IRC_State state;      /* progress state */
 579             ADIOI_GEN_IreadStridedColl_vars *rsc_vars;
 580             ADIOI_Iread_and_exch_vars       *rae_vars;
 581             ADIOI_R_Iexchange_data_vars     *red_vars;
 582         } rd;
 583         struct {
 584             ADIOI_IWC_State state;      /* progress state */
 585             ADIOI_GEN_IwriteStridedColl_vars *wsc_vars;
 586             ADIOI_Iexch_and_write_vars       *eaw_vars;
 587             ADIOI_W_Iexchange_data_vars      *wed_vars;
 588         } wr;
 589     } data;
 590     ADIOI_Icalc_others_req_vars *cor_vars;
 591 };
 592 
 593 void ADIOI_Icalc_others_req(ADIOI_NBC_Request *nbc_req, int *error_code);
 594 void ADIOI_Icalc_others_req_main(ADIOI_NBC_Request *nbc_req, int *error_code);
 595 void ADIOI_Icalc_others_req_fini(ADIOI_NBC_Request *nbc_req, int *error_code);
 596 
 597 
 598 /* KC && AC - New Collective I/O internals*/
 599 
 600 #define TEMP_OFF 0
 601 #define REAL_OFF 1
 602 #define MAX_OFF_TYPE 2
 603 
 604 /* Communication Tags */
 605 #define DATA_TAG 30
 606 #define AMT_TAG 31
 607 
 608 /* cb_fr_type user size is non-zero */
 609 #define ADIOI_FR_AAR 0
 610 #define ADIOI_FR_FSZ -1
 611 #define ADIOI_FR_USR_REALMS -2
 612 
 613 typedef struct flatten_state
 614 {
 615     ADIO_Offset abs_off;
 616     ADIO_Offset cur_sz;
 617     ADIO_Offset idx;
 618     ADIO_Offset cur_reg_off;
 619 } flatten_state;
 620 
 621 typedef struct view_state
 622 {
 623     ADIO_Offset fp_ind;    /* file view params*/
 624     ADIO_Offset disp;      /* file view params*/
 625     ADIO_Offset byte_off;
 626     ADIO_Offset sz;
 627     ADIO_Offset ext;       /* preserved extent from MPI_Type_extent */
 628     ADIO_Offset type_sz;
 629 
 630     /* Current state */
 631     flatten_state cur_state;
 632     /* Scratch state for counting up ol pairs */
 633     flatten_state tmp_state;
 634 
 635     /* Preprocessed data amount and ol pairs */
 636     ADIO_Offset pre_sz;
 637     int pre_ol_ct;
 638     MPI_Aint *pre_disp_arr;
 639     int *pre_blk_arr;
 640     
 641     ADIOI_Flatlist_node *flat_type_p;
 642 } view_state;
 643 
 644 void ADIOI_Calc_bounds (ADIO_File fd, int count, MPI_Datatype buftype,
 645                         int file_ptr_type, ADIO_Offset offset,
 646                         ADIO_Offset *st_offset, ADIO_Offset *end_offset);
 647 int ADIOI_Agg_idx (int rank, ADIO_File fd);
 648 void ADIOI_Calc_file_realms (ADIO_File fd, ADIO_Offset min_st_offset,
 649                              ADIO_Offset max_end_offset);
 650 void ADIOI_IOFiletype(ADIO_File fd, void *buf, int count,
 651                       MPI_Datatype datatype, int file_ptr_type,
 652                       ADIO_Offset offset, MPI_Datatype custom_ftype,
 653                       int rdwr, ADIO_Status *status, int
 654                       *error_code);
 655 void ADIOI_IOStridedColl(ADIO_File fd, void *buf, int count, int rdwr,
 656                        MPI_Datatype datatype, int file_ptr_type,
 657                        ADIO_Offset offset, ADIO_Status *status, int
 658                        *error_code);
 659 void ADIOI_Print_flatlist_node(ADIOI_Flatlist_node *flatlist_node_p);
 660 ADIOI_Flatlist_node * ADIOI_Add_contig_flattened(MPI_Datatype contig_type);
 661 void ADIOI_Exch_file_views(int myrank, int nprocs, int file_ptr_type,
 662                            ADIO_File fd, int count,
 663                            MPI_Datatype datatype, ADIO_Offset off,
 664                            view_state *my_mem_view_state_arr,
 665                            view_state *agg_file_view_state_arr,
 666                            view_state *client_file_view_state_arr);
 667 int ADIOI_init_view_state(int file_ptr_type,
 668                     int nprocs, 
 669                     view_state *view_state_arr,
 670                     int op_type);
 671 int ADIOI_Build_agg_reqs(ADIO_File fd, int rw_type, int nprocs,
 672                          view_state *client_file_view_state_arr,
 673                          MPI_Datatype *client_comm_dtype_arr,
 674                          ADIO_Offset *client_comm_sz_arr,
 675                          ADIO_Offset *agg_dtype_offset_p,
 676                          MPI_Datatype *agg_dtype_p);
 677 int ADIOI_Build_client_reqs(ADIO_File fd, 
 678                             int nprocs,
 679                             view_state *my_mem_view_state_arr,
 680                             view_state *agg_file_view_state_arr,
 681                             ADIO_Offset *agg_comm_sz_arr,
 682                             MPI_Datatype *agg_comm_dtype_arr);
 683 int ADIOI_Build_client_pre_req(ADIO_File fd,
 684                                int agg_rank,
 685                                int agg_idx,
 686                                view_state *my_mem_view_state_p,
 687                                view_state *agg_file_view_state_p,
 688                                ADIO_Offset max_pre_req_sz,
 689                                int max_ol_ct);
 690 int ADIOI_Build_client_req(ADIO_File fd,
 691                            int agg_rank,
 692                            int agg_idx,
 693                            view_state *my_mem_view_state_p,
 694                            view_state *agg_file_view_state_p,
 695                            ADIO_Offset agg_comm_sz,
 696                            MPI_Datatype *agg_comm_dtype_p);
 697 
 698 void ADIOI_P2PContigWriteAggregation(ADIO_File fd,
 699                                      const void *buf,
 700                                      int *error_code,
 701                                      ADIO_Offset *st_offsets,
 702                                      ADIO_Offset *end_offset,
 703                                      ADIO_Offset *fd_start,
 704                                      ADIO_Offset *fd_end);
 705 
 706 void ADIOI_P2PContigReadAggregation(ADIO_File fd,
 707                                      const void *buf,
 708                                      int *error_code,
 709                                      ADIO_Offset *st_offsets,
 710                                      ADIO_Offset *end_offset,
 711                                      ADIO_Offset *fd_start,
 712                                      ADIO_Offset *fd_end);
 713 
 714 int ADIOI_OneSidedCleanup(ADIO_File fd);
 715 void ADIOI_OneSidedWriteAggregation(ADIO_File fd,
 716         ADIO_Offset *offset_list,
 717         ADIO_Offset *len_list,
 718         int contig_access_count,
 719         const void *buf,
 720         MPI_Datatype datatype,
 721         int *error_code,
 722         ADIO_Offset *st_offsets,
 723         ADIO_Offset *end_offsets,
 724         int numNonZeroDataOffsets,
 725         ADIO_Offset *fd_start,
 726         ADIO_Offset* fd_end,
 727         int *hole_found);
 728 void ADIOI_OneSidedReadAggregation(ADIO_File fd,
 729         ADIO_Offset *offset_list,
 730         ADIO_Offset *len_list,
 731         int contig_access_count,
 732         const void *buf,
 733         MPI_Datatype datatype,
 734         int *error_code,
 735         ADIO_Offset *st_offsets,
 736         ADIO_Offset *end_offsets,
 737         int numNonZeroDataOffsets,
 738         ADIO_Offset *fd_start,
 739         ADIO_Offset* fd_end);
 740 ADIO_Offset ADIOI_GEN_SeekIndividual(ADIO_File fd, ADIO_Offset offset, 
 741                                      int whence, int *error_code);
 742 void ADIOI_GEN_Resize(ADIO_File fd, ADIO_Offset size, int *error_code);
 743 void ADIOI_GEN_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code);
 744 void ADIOI_GEN_Close(ADIO_File fd, int *error_code);
 745 void ADIOI_Shfp_fname(ADIO_File fd, int rank, int *error_code);
 746 void ADIOI_GEN_Prealloc(ADIO_File fd, ADIO_Offset size, int *error_code);
 747 int ADIOI_Error(ADIO_File fd, int error_code, char *string);
 748 int MPIR_Err_setmsg( int, int, const char *, const char *, const char *, ... );
 749 int ADIOI_End_call(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state);
 750 int MPIR_Status_set_bytes(MPI_Status *status, MPI_Datatype datatype, MPI_Count nbytes);
 751 int ADIOI_Uses_generic_read(ADIO_File fd);
 752 int ADIOI_Uses_generic_write(ADIO_File fd);
 753 int ADIOI_Err_create_code(const char *myname, const char *filename, int my_errno);
 754 int ADIOI_Type_create_hindexed_x(int count,
 755                 const MPI_Count array_of_blocklengths[],
 756                 const MPI_Aint array_of_displacements[],
 757                 MPI_Datatype oldtype,
 758                 MPI_Datatype *newtype);
 759 
 760 
 761 int ADIOI_FAKE_IODone(ADIO_Request *request, ADIO_Status *status,
 762                       int *error_code);
 763 void ADIOI_FAKE_IreadContig(ADIO_File fd, void *buf, int count, 
 764                            MPI_Datatype datatype, int file_ptr_type,
 765                            ADIO_Offset offset, ADIO_Request *request,
 766                             int *error_code);
 767 void ADIOI_FAKE_IreadStrided(ADIO_File fd, void *buf, int count, 
 768                             MPI_Datatype datatype, int file_ptr_type,
 769                             ADIO_Offset offset, ADIO_Request *request,
 770                              int *error_code);
 771 void ADIOI_FAKE_IwriteContig(ADIO_File fd, const void *buf, int count,
 772                             MPI_Datatype datatype, int file_ptr_type,
 773                             ADIO_Offset offset, ADIO_Request *request,
 774                              int *error_code);
 775 void ADIOI_FAKE_IwriteStrided(ADIO_File fd, const void *buf, int count,
 776                              MPI_Datatype datatype, int file_ptr_type,
 777                              ADIO_Offset offset, ADIO_Request *request,
 778                               int *error_code);
 779 void ADIOI_FAKE_IOComplete(ADIO_Request *request, ADIO_Status *status,
 780                            int *error_code);
 781 
 782 
 783 /* File I/O common functionality */
 784 int MPIOI_File_read(MPI_File fh,
 785                     MPI_Offset offset,
 786                     int file_ptr_type,
 787                     void *buf,
 788                     int count,
 789                     MPI_Datatype datatype,
 790                     char *myname,
 791                     MPI_Status *status);
 792 int MPIOI_File_write(MPI_File fh,
 793                      MPI_Offset offset,
 794                      int file_ptr_type,
 795                      const void *buf,
 796                      int count,
 797                      MPI_Datatype datatype,
 798                      char *myname,
 799                      MPI_Status *status);
 800 int MPIOI_File_read_all(MPI_File fh,
 801                         MPI_Offset offset,
 802                         int file_ptr_type,
 803                         void *buf,
 804                         int count,
 805                         MPI_Datatype datatype,
 806                         char *myname,
 807                         MPI_Status *status);
 808 int MPIOI_File_write_all(MPI_File fh,
 809                          MPI_Offset offset,
 810                          int file_ptr_type,
 811                          const void *buf,
 812                          int count,
 813                          MPI_Datatype datatype,
 814                          char *myname,
 815                          MPI_Status *status);
 816 int MPIOI_File_read_all_begin(MPI_File fh,
 817                               MPI_Offset offset,
 818                               int file_ptr_type,
 819                               void *buf,
 820                               int count,
 821                               MPI_Datatype datatype,
 822                               char *myname);
 823 int MPIOI_File_write_all_begin(MPI_File fh,
 824                                MPI_Offset offset,
 825                                int file_ptr_type,
 826                                const void *buf,
 827                                int count,
 828                                MPI_Datatype datatype,
 829                                char *myname);
 830 int MPIOI_File_read_all_end(MPI_File fh,
 831                             void *buf,
 832                             char *myname,
 833                             MPI_Status *status);
 834 int MPIOI_File_write_all_end(MPI_File fh,
 835                              const void *buf,
 836                              char *myname,
 837                              MPI_Status *status);
 838 int MPIOI_File_iwrite(MPI_File fh,
 839                       MPI_Offset offset,
 840                       int file_ptr_type,
 841                       const void *buf,
 842                       int count,
 843                       MPI_Datatype datatype,
 844                       char *myname,
 845                       MPI_Request *request);
 846 int MPIOI_File_iread(MPI_File fh,
 847                      MPI_Offset offset,
 848                      int file_ptr_type,
 849                      void *buf,
 850                      int count,
 851                      MPI_Datatype datatype,
 852                      char *myname,
 853                      MPI_Request *request);
 854 int MPIOI_File_iwrite_all(MPI_File fh,
 855             MPI_Offset offset,
 856             int file_ptr_type,
 857             const void *buf,
 858             int count,
 859             MPI_Datatype datatype,
 860             char *myname,
 861             MPI_Request *request);
 862 int MPIOI_File_iread_all(MPI_File fh,
 863             MPI_Offset offset,
 864             int file_ptr_type,
 865             void *buf,
 866             int count,
 867             MPI_Datatype datatype,
 868             char *myname,
 869             MPI_Request *request);
 870 
 871 
 872 
 873 /* Unix-style file locking */
 874 
 875 #if (defined(ROMIO_HFS) || defined(ROMIO_XFS))
 876 
 877 # define ADIOI_WRITE_LOCK(fd, offset, whence, len) \
 878    do {if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
 879      ADIOI_Set_lock64((fd)->fd_sys, F_SETLKW64, F_WRLCK, offset, whence, len);\
 880    else ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_WRLCK, offset, whence, len); } while (0) 
 881 
 882 # define ADIOI_READ_LOCK(fd, offset, whence, len) \
 883    do {if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
 884      ADIOI_Set_lock64((fd)->fd_sys, F_SETLKW64, F_RDLCK, offset, whence, len);\
 885    else ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_RDLCK, offset, whence, len); }while (0)
 886 
 887 # define ADIOI_UNLOCK(fd, offset, whence, len) \
 888    do {if (((fd)->file_system == ADIO_XFS) || ((fd)->file_system == ADIO_HFS)) \
 889      ADIOI_Set_lock64((fd)->fd_sys, F_SETLK64, F_UNLCK, offset, whence, len); \
 890    else ADIOI_Set_lock((fd)->fd_sys, F_SETLK, F_UNLCK, offset, whence, len); }while (0)
 891 
 892 #elif (defined(ROMIO_NTFS))
 893 
 894 #define ADIOI_LOCK_CMD          0
 895 #define ADIOI_UNLOCK_CMD        1
 896 
 897 #   define ADIOI_WRITE_LOCK(fd, offset, whence, len) \
 898           ADIOI_Set_lock((fd)->fd_sys, ADIOI_LOCK_CMD, LOCKFILE_EXCLUSIVE_LOCK, offset, whence, len)
 899 #   define ADIOI_READ_LOCK(fd, offset, whence, len) \
 900           ADIOI_Set_lock((fd)->fd_sys, ADIOI_LOCK_CMD, 0, offset, whence, len)
 901 #   define ADIOI_UNLOCK(fd, offset, whence, len) \
 902           ADIOI_Set_lock((fd)->fd_sys, ADIOI_UNLOCK_CMD, LOCKFILE_FAIL_IMMEDIATELY, offset, whence, len)
 903 
 904 #else
 905 
 906 #ifdef ADIOI_MPE_LOGGING
 907 #   define ADIOI_WRITE_LOCK(fd, offset, whence, len) do { \
 908         MPE_Log_event( ADIOI_MPE_writelock_a, 0, NULL ); \
 909         ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_WRLCK, offset, whence, len); \
 910         MPE_Log_event( ADIOI_MPE_writelock_b, 0, NULL ); } while( 0 )
 911 #   define ADIOI_READ_LOCK(fd, offset, whence, len) \
 912         MPE_Log_event( ADIOI_MPE_readlock_a, 0, NULL ); do { \
 913         ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_RDLCK, offset, whence, len); \
 914         MPE_Log_event( ADIOI_MPE_readlock_b, 0, NULL ); } while( 0 )
 915 #   define ADIOI_UNLOCK(fd, offset, whence, len) do { \
 916         MPE_Log_event( ADIOI_MPE_unlock_a, 0, NULL ); \
 917         ADIOI_Set_lock((fd)->fd_sys, F_SETLK, F_UNLCK, offset, whence, len); \
 918         MPE_Log_event( ADIOI_MPE_unlock_b, 0, NULL ); } while( 0 )
 919 #else
 920 #   define ADIOI_WRITE_LOCK(fd, offset, whence, len) \
 921           ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_WRLCK, offset, whence, len)
 922 #   define ADIOI_READ_LOCK(fd, offset, whence, len) \
 923           ADIOI_Set_lock((fd)->fd_sys, F_SETLKW, F_RDLCK, offset, whence, len)
 924 #   define ADIOI_UNLOCK(fd, offset, whence, len) \
 925           ADIOI_Set_lock((fd)->fd_sys, F_SETLK, F_UNLCK, offset, whence, len)
 926 #endif
 927 
 928 #endif
 929 
 930 int ADIOI_Set_lock(FDTYPE fd_sys, int cmd, int type, ADIO_Offset offset, int whence, ADIO_Offset len);
 931 int ADIOI_Set_lock64(FDTYPE fd_sys, int cmd, int type, ADIO_Offset offset, int whence, ADIO_Offset len);
 932 
 933 #define ADIOI_Malloc(a) ADIOI_Malloc_fn(a,__LINE__,__FILE__)
 934 #define ADIOI_Calloc(a,b) ADIOI_Calloc_fn(a,b,__LINE__,__FILE__)
 935 #define ADIOI_Realloc(a,b) ADIOI_Realloc_fn(a,b,__LINE__,__FILE__)
 936 #define ADIOI_Free(a) ADIOI_Free_fn(a,__LINE__,__FILE__)
 937 
 938 int ADIOI_Strncpy( char *outstr, const char *instr, size_t maxlen );
 939 int ADIOI_Strnapp( char *, const char *, size_t );
 940 char *ADIOI_Strdup( const char * );
 941 
 942 /* the current MPI standard is not const-correct, and modern compilers warn
 943  * about the following sort of code:
 944  *
 945  *   MPI_Info_set(info, "key", "val");
 946  *
 947  * reminding us that "key" and "val" are const.  We use the following macros to
 948  * cast away the const and suppress the warning. */
 949 #define ADIOI_Info_set(info_,key_str_,val_) \
 950     MPI_Info_set((info_),((char*)key_str_),(char*)(val_))
 951 #define ADIOI_Info_get(info_,key_str_,val_len_,val_,flag_) \
 952     MPI_Info_get((info_),((char*)key_str_),(val_len_),(val_),(flag_))
 953 #define ADIOI_Info_get_valuelen(info_,key_str_,val_len_,flag_) \
 954     MPI_Info_get_valuelen((info_),((char*)key_str_),(val_len_),(flag_))
 955 #define ADIOI_Info_delete(info_,key_str_) \
 956     MPI_Info_delete((info_),((char*)key_str_))
 957 
 958 
 959 /* Provide a fallback snprintf for systems that do not have one */
 960 /* Define attribute as empty if it has no definition */
 961 #ifndef ATTRIBUTE
 962 #ifdef HAVE_GCC_ATTRIBUTE
 963 #define ATTRIBUTE(a) __attribute__(a)
 964 #else
 965 #define ATTRIBUTE(a)
 966 #endif
 967 #endif
 968 
 969 /* style: allow:snprintf:1 sig:0 */
 970 
 971 #ifdef HAVE_SNPRINTF
 972 #define ADIOI_Snprintf snprintf
 973 /* Sometimes systems don't provide prototypes for snprintf */
 974 #ifdef NEEDS_SNPRINTF_DECL
 975 extern int snprintf( char *, size_t, const char *, ... ) ATTRIBUTE((format(printf,3,4)));
 976 #endif
 977 #else
 978 int ADIOI_Snprintf( char *str, size_t size, const char *format, ... ) 
 979      ATTRIBUTE((format(printf,3,4)));
 980 #endif /* HAVE_SNPRINTF */
 981 
 982 #define FPRINTF fprintf
 983 
 984 #ifndef HAVE_STRERROR
 985 #  ifdef HAVE_SYSERRLIST
 986       extern char *sys_errlist[];
 987 #     define strerror(n) sys_errlist[n]
 988 #  else 
 989 #     define PRINT_ERR_MSG
 990 #  endif
 991 #endif
 992 
 993 #include "adioi_error.h"
 994 
 995 /*  MPE logging variables  */
 996 
 997 #ifdef ADIOI_MPE_LOGGING
 998 #include "mpe.h"
 999 
1000 int  ADIOI_MPE_open_a;
1001 int  ADIOI_MPE_open_b;
1002 int  ADIOI_MPE_read_a;
1003 int  ADIOI_MPE_read_b;
1004 int  ADIOI_MPE_write_a;
1005 int  ADIOI_MPE_write_b;
1006 int  ADIOI_MPE_lseek_a;
1007 int  ADIOI_MPE_lseek_b;
1008 int  ADIOI_MPE_close_a;
1009 int  ADIOI_MPE_close_b;
1010 int  ADIOI_MPE_writelock_a;
1011 int  ADIOI_MPE_writelock_b;
1012 int  ADIOI_MPE_readlock_a;
1013 int  ADIOI_MPE_readlock_b;
1014 int  ADIOI_MPE_unlock_a;
1015 int  ADIOI_MPE_unlock_b;
1016 int  ADIOI_MPE_postwrite_a;
1017 int  ADIOI_MPE_postwrite_b;
1018 int  ADIOI_MPE_openinternal_a;
1019 int  ADIOI_MPE_openinternal_b;
1020 int  ADIOI_MPE_stat_a;
1021 int  ADIOI_MPE_stat_b;
1022 int  ADIOI_MPE_iread_a;
1023 int  ADIOI_MPE_iread_b;
1024 int  ADIOI_MPE_iwrite_a;
1025 int  ADIOI_MPE_iwrite_b;
1026 #endif
1027 
1028 #ifdef ROMIO_INSIDE_MPICH
1029 /* Assert that this MPI_Aint value can be cast to a ptr value without problem.*/
1030 /* Basic idea is the value should be unchanged after casting 
1031    (no loss of (meaningful) high order bytes in 8 byte MPI_Aint 
1032       to (possible) 4 byte ptr cast)                              */
1033 /* Should work even on 64bit or old 32bit configs                 */
1034   /* Use MPIU_Ensure_Aint_fits_in_pointer from mpiutil.h and 
1035          MPIU_AINT_CAST_TO_VOID_PTR from configure (mpi.h) */
1036   #include "glue_romio.h"
1037 
1038   #define ADIOI_AINT_CAST_TO_VOID_PTR (void*)(MPIU_Pint)
1039   /* The next two casts are only used when you don't want sign extension
1040      when casting a (possible 4 byte) aint to a (8 byte) long long or offset */
1041   #define ADIOI_AINT_CAST_TO_LONG_LONG (long long)
1042   #define ADIOI_AINT_CAST_TO_OFFSET ADIOI_AINT_CAST_TO_LONG_LONG
1043 
1044   #define ADIOI_ENSURE_AINT_FITS_IN_PTR(aint_value) MPIR_Ext_ensure_Aint_fits_in_pointer(aint_value)
1045   #define ADIOI_Assert MPIR_Ext_assert
1046 #else
1047   #include <assert.h>
1048   #define ADIOI_AINT_CAST_TO_VOID_PTR (void*)
1049   #define ADIOI_AINT_CAST_TO_LONG_LONG (long long)
1050   #define ADIOI_AINT_CAST_TO_OFFSET ADIOI_AINT_CAST_TO_LONG_LONG
1051   #define ADIOI_ENSURE_AINT_FITS_IN_PTR(aint_value) 
1052   #define ADIOI_Assert assert
1053   #define MPIU_Upint unsigned long
1054   #define MPID_THREADPRIV_DECL
1055 #endif
1056 
1057 #ifdef USE_DBG_LOGGING    /*todo fix dependency on mpich?*/
1058 /* DBGT_FPRINTF terse level printing */
1059 #define DBGT_FPRINTF if (MPIR_Ext_dbg_romio_verbose_enabled) fprintf(stderr,"%s:%d:",__FILE__,__LINE__); \
1060 if (MPIR_Ext_dbg_romio_terse_enabled) fprintf
1061 /* DBG_FPRINTF default (typical level) printing */
1062 #define DBG_FPRINTF if (MPIR_Ext_dbg_romio_verbose_enabled) fprintf(stderr,"%s:%d:",__FILE__,__LINE__); \
1063 if (MPIR_Ext_dbg_romio_typical_enabled) fprintf
1064 /* DBGV_FPRINTF verbose level printing */
1065 #define DBGV_FPRINTF if (MPIR_Ext_dbg_romio_verbose_enabled) fprintf(stderr,"%s:%d:",__FILE__,__LINE__); \
1066  if (MPIR_Ext_dbg_romio_verbose_enabled) fprintf
1067 #else /* compile it out */
1068 #define DBGT_FPRINTF if (0) fprintf
1069 #define DBG_FPRINTF if (0) fprintf
1070 #define DBGV_FPRINTF if (0) fprintf
1071 #endif
1072 
1073 /* declarations for threaded I/O */
1074 /* i/o thread data structure (bgmpio_pthreadwc) */
1075 typedef struct wcThreadFuncData {
1076     ADIO_File fd;
1077     int io_kind;
1078     char *buf;
1079     int size;
1080     ADIO_Offset offset;
1081     ADIO_Status *status;
1082     int error_code;
1083 } ADIOI_IO_ThreadFuncData;
1084 
1085 void *ADIOI_IO_Thread_Func(void *vptr_args);
1086 
1087 
1088 #ifdef HAVE_LIMITS_H
1089 #include <limits.h>
1090 #endif
1091 
1092 #ifndef PATH_MAX
1093 #define PATH_MAX 65535
1094 #endif
1095 
1096 #if (HAVE_DECL_PWRITE == 0)
1097 #include <sys/types.h>
1098 #include <unistd.h>
1099 ssize_t pread(int fd, void *buf, size_t count, off_t offset);
1100 ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
1101 
1102 #endif
1103 
1104 #endif  /* ADIOI_INCLUDE */

/* [<][>][^][v][top][bottom][index][help] */