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

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

INCLUDED FROM


   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *   Copyright (C) 1997 University of Chicago. 
   4  *   See COPYRIGHT notice in top-level directory.
   5  */
   6 
   7 /* main include file for ADIO.
   8    contains general definitions, declarations, and macros independent 
   9    of the underlying file system */
  10 
  11 /* Functions and datataypes that are "internal" to the ADIO implementation 
  12    prefixed ADIOI_. Functions and datatypes that are part of the
  13    "externally visible" (documented) ADIO interface are prefixed ADIO_.
  14 
  15    An implementation of MPI-IO, or any other high-level interface, should
  16    not need to use any of the ADIOI_ functions/datatypes. 
  17    Only someone implementing ADIO on a new file system, or modifying 
  18    an existing ADIO implementation, would need to use the ADIOI_
  19    functions/datatypes. */
  20 
  21 #ifndef ADIO_INCLUDE
  22 #define ADIO_INCLUDE
  23 
  24 #ifdef SPPUX
  25 #define _POSIX_SOURCE
  26 #endif
  27 
  28 #ifdef USE_FORT_STDCALL
  29 #define FORT_CALL __stdcall
  30 #elif defined (USE_FORT_CDECL)
  31 #define FORT_CALL __cdecl
  32 #else
  33 #define FORT_CALL
  34 #endif
  35 
  36 #ifdef USE_FORT_MIXED_STR_LEN
  37 #define FORT_MIXED_LEN_DECL   , int
  38 #define FORT_END_LEN_DECL
  39 #define FORT_MIXED_LEN(a)     , int a
  40 #define FORT_END_LEN(a)
  41 #else
  42 #define FORT_MIXED_LEN_DECL
  43 #define FORT_END_LEN_DECL     , int
  44 #define FORT_MIXED_LEN(a)
  45 #define FORT_END_LEN(a)       , int a
  46 #endif
  47 
  48 #ifdef HAVE_FORTRAN_API
  49 # ifdef FORTRAN_EXPORTS
  50 #  define FORTRAN_API __declspec(dllexport)
  51 # else
  52 #  define FORTRAN_API __declspec(dllimport)
  53 # endif
  54 #else
  55 # define FORTRAN_API
  56 #endif
  57 
  58 /* Use this macro for each parameter to a function that is not referenced in the body of the function */
  59 #ifdef HAVE_WINDOWS_H
  60 #define ADIOI_UNREFERENCED_ARG(a) a
  61 #else
  62 #define ADIOI_UNREFERENCED_ARG(a)
  63 #endif
  64 
  65 /* Include romioconf.h if we haven't already (some include files may
  66    need to include romioconf before some system includes) */
  67 #ifndef ROMIOCONF_H_INCLUDED
  68 #include "romioconf.h"
  69 #define ROMIOCONF_H_INCLUDED
  70 #endif
  71 
  72 #include "mpi.h"
  73 #include "mpio.h"
  74 #ifdef HAVE_FCNTL_H
  75 #include <fcntl.h>
  76 #endif
  77 #ifdef HAVE_SYS_TYPES_H
  78 #include <sys/types.h>
  79 #endif
  80 #include <sys/stat.h>
  81 #include <string.h>
  82 #include <stdio.h>
  83 #include <stdlib.h>
  84 #include <errno.h>
  85 #ifdef SPPUX
  86 #include <sys/cnx_fcntl.h>
  87 #endif
  88 
  89 #ifdef ROMIO_NTFS
  90 #include <winsock2.h>
  91 #include <windows.h>
  92 #define FDTYPE HANDLE
  93 #else
  94 #define FDTYPE int
  95 #endif
  96 
  97 #ifdef MPI_OFFSET_IS_INT
  98    typedef int ADIO_Offset;
  99    typedef unsigned ADIO_Size;
 100 #  define ADIO_OFFSET MPI_INT
 101 #elif defined(HAVE_LONG_LONG_64)
 102    typedef long long ADIO_Offset;
 103    typedef unsigned long long ADIO_Size;
 104 #  ifdef HAVE_MPI_LONG_LONG_INT
 105 #     define ADIO_OFFSET MPI_LONG_LONG_INT
 106 #  else
 107 #     define ADIO_OFFSET MPI_DOUBLE
 108 #  endif
 109 #elif defined(HAVE_INT64)
 110    typedef __int64 ADIO_Offset;
 111    typedef unsigned __int64 ADIO_Size;
 112 #  define ADIO_OFFSET MPI_DOUBLE
 113 #else
 114    typedef long ADIO_Offset;
 115    typedef unsigned long ADIO_Size;
 116 #  define ADIO_OFFSET MPI_LONG
 117 #endif
 118 
 119 #define ADIO_Status MPI_Status   
 120 
 121 #ifndef MPIO_INCLUDE
 122 #  ifdef NEEDS_MPI_FINT
 123       typedef int MPI_Fint; 
 124 #  endif
 125 #endif
 126 
 127 #if (!defined(HAVE_MPI_INFO) && !defined(MPIO_INCLUDE))
 128    typedef struct MPIR_Info *MPI_Info;
 129 #  define MPI_INFO_NULL 0
 130 #  define MPI_MAX_INFO_VAL      1024
 131 
 132 int MPI_Info_create(MPI_Info *info);
 133 int MPI_Info_set(MPI_Info info, char *key, char *value);
 134 int MPI_Info_delete(MPI_Info info, char *key);
 135 int MPI_Info_get(MPI_Info info, char *key, int valuelen, 
 136                          char *value, int *flag);
 137 int MPI_Info_get_valuelen(MPI_Info info, char *key, int *valuelen, int *flag);
 138 int MPI_Info_get_nkeys(MPI_Info info, int *nkeys);
 139 int MPI_Info_get_nthkey(MPI_Info info, int n, char *key);
 140 int MPI_Info_dup(MPI_Info info, MPI_Info *newinfo);
 141 int MPI_Info_free(MPI_Info *info);
 142 
 143 #ifdef MPI_Info_f2c
 144 #undef MPI_Info_f2c
 145 #endif
 146 #ifdef MPI_Info_c2f
 147 #undef MPI_Info_c2f
 148 #endif
 149 /* above needed for some versions of mpi.h in MPICH!! */
 150 MPI_Fint MPI_Info_c2f(MPI_Info info);
 151 MPI_Info MPI_Info_f2c(MPI_Fint info);
 152 
 153 int PMPI_Info_create(MPI_Info *info);
 154 int PMPI_Info_set(MPI_Info info, char *key, char *value);
 155 int PMPI_Info_delete(MPI_Info info, char *key);
 156 int PMPI_Info_get(MPI_Info info, char *key, int valuelen, 
 157                          char *value, int *flag);
 158 int PMPI_Info_get_valuelen(MPI_Info info, char *key, int *valuelen, int *flag);
 159 int PMPI_Info_get_nkeys(MPI_Info info, int *nkeys);
 160 int PMPI_Info_get_nthkey(MPI_Info info, int n, char *key);
 161 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo);
 162 int PMPI_Info_free(MPI_Info *info);
 163 
 164 MPI_Fint PMPI_Info_c2f(MPI_Info info);
 165 MPI_Info PMPI_Info_f2c(MPI_Fint info);
 166 
 167 #endif
 168 
 169 /* style: allow:strdup:1 sig:0 */
 170 
 171 #if defined(HAVE_STRDUP) && defined(NEEDS_STRDUP_DECL) && !defined(strdup)
 172 char *strdup(const char *s);
 173 # endif
 174 #if defined(HAVE_READLINK) && defined(NEEDS_READLINK_DECL) && !defined(readlink)
 175 ssize_t readlink(const char *path, char *buf, size_t bufsiz);
 176 # endif
 177 #if defined(HAVE_LSTAT) && defined(NEEDS_LSTAT_DECL) && !defined(lstat)
 178 int lstat(const char *file_name, struct stat *buf);
 179 # endif
 180 #if defined(HAVE_FSYNC) && defined(NEEDS_FSYNC_DECL) && !defined(fsync)
 181 int fsync(int fd);
 182 # endif
 183 #if defined(HAVE_FTRUNCATE) && defined(NEEDS_FTRUNCATE_DECL) && !defined(ftruncate)
 184 int ftruncate(int fd, off_t length);
 185 # endif
 186 
 187 
 188 typedef struct ADIOI_Fns_struct ADIOI_Fns;
 189 typedef struct ADIOI_Hints_struct ADIOI_Hints;
 190 
 191 typedef struct ADIOI_FileD {
 192     int cookie;              /* for error checking */
 193     FDTYPE fd_sys;              /* system file descriptor */
 194     FDTYPE null_fd;          /* the null-device file descriptor: debug only (obviously)*/
 195     int fd_direct;           /* On XFS, this is used for direct I/O; 
 196                                 fd_sys is used for buffered I/O */
 197     int direct_read;         /* flag; 1 means use direct read */
 198     int direct_write;        /* flag; 1 means use direct write  */
 199     /* direct I/O attributes */
 200     unsigned d_mem;          /* data buffer memory alignment */
 201     unsigned d_miniosz;      /* min xfer size, xfer size multiple,
 202                                 and file seek offset alignment */
 203     long blksize;            /* some optimizations benefit from knowing
 204                                 underlying block size */
 205     ADIO_Offset fp_ind;      /* individual file pointer in MPI-IO (in bytes)*/
 206     ADIO_Offset fp_sys_posn; /* current location of the system file-pointer
 207                                 in bytes */
 208     ADIOI_Fns *fns;          /* struct of I/O functions to use */
 209     MPI_Comm comm;           /* communicator indicating who called open */
 210     int is_open;            /* deferred open: 0: not open yet 1: is open */
 211     int is_agg;              /* bool: if I am an aggregator */
 212     char *filename;          
 213     int file_system;         /* type of file system */
 214     int access_mode;         /* Access mode (sequential, append, etc.),
 215                                 possibly modified to deal with
 216                                 data sieving or deferred open*/
 217     int orig_access_mode;    /* Access mode provided by user: unmodified */
 218     ADIO_Offset disp;        /* reqd. for MPI-IO */
 219     MPI_Datatype etype;      /* reqd. for MPI-IO */
 220     MPI_Datatype filetype;   /* reqd. for MPI-IO */
 221     MPI_Count etype_size;          /* in bytes */
 222     ADIOI_Hints *hints;      /* structure containing fs-indep. info values */
 223     MPI_Info info;
 224 
 225     /* The following support the split collective operations */
 226     int split_coll_count;    /* count of outstanding split coll. ops. */
 227     MPI_Status split_status; /* status used for split collectives */
 228     MPI_Datatype split_datatype; /* datatype used for split collectives */
 229 
 230     /* The following support the shared file operations */
 231     char *shared_fp_fname;   /* name of file containing shared file pointer */
 232     struct ADIOI_FileD *shared_fp_fd;  /* file handle of file 
 233                                          containing shared fp */
 234     int async_count;         /* count of outstanding nonblocking operations */
 235     int perm;
 236     int atomicity;          /* true=atomic, false=nonatomic */
 237     int fortran_handle;     /* handle for Fortran interface if needed */
 238     MPI_Errhandler err_handler;
 239     void *fs_ptr;            /* file-system specific information */
 240 
 241     /* Two phase collective I/O support */
 242     ADIO_Offset *file_realm_st_offs; /* file realm starting offsets */
 243     MPI_Datatype *file_realm_types;  /* file realm datatypes */
 244     int my_cb_nodes_index; /* my index into cb_config_list. -1 if N/A */
 245     char *io_buf;          /* two-phase buffer allocated out of i/o path */
 246     MPI_Win io_buf_window; /* Window over the io_buf to support one-sided aggregation */
 247     int *io_buf_put_amounts; /* array tracking the amount of data mpi_put into the io_buf
 248                                 during the same round of one-sided write aggregation */
 249     MPI_Win io_buf_put_amounts_window; /* Window over the io_buf_put_amounts */
 250     /* External32 */
 251     int is_external32;      /* bool:  0 means native view */
 252 
 253 } ADIOI_FileD;
 254 
 255 typedef struct ADIOI_FileD *ADIO_File;
 256 
 257 typedef MPI_Request ADIO_Request;
 258 
 259 /* fcntl structure */
 260 typedef struct {
 261     ADIO_Offset disp;
 262     MPI_Datatype etype;
 263     MPI_Datatype filetype;
 264     MPI_Info info;
 265     int atomicity;
 266     ADIO_Offset fsize;       /* for get_fsize only */
 267     ADIO_Offset diskspace;   /* for file preallocation */
 268 } ADIO_Fcntl_t;              /* should contain more stuff */
 269 
 270 
 271 /* access modes */
 272 #define ADIO_CREATE              1
 273 #define ADIO_RDONLY              2
 274 #define ADIO_WRONLY              4
 275 #define ADIO_RDWR                8
 276 #define ADIO_DELETE_ON_CLOSE     16
 277 #define ADIO_UNIQUE_OPEN         32
 278 #define ADIO_EXCL                64
 279 #define ADIO_APPEND             128
 280 #define ADIO_SEQUENTIAL         256
 281 
 282 #define ADIO_AMODE_NOMATCH  ~(ADIO_CREATE|ADIO_RDONLY|ADIO_WRONLY|ADIO_RDWR|ADIO_DELETE_ON_CLOSE|ADIO_UNIQUE_OPEN|ADIO_EXCL|ADIO_APPEND|ADIO_SEQUENTIAL)
 283 
 284 /* file-pointer types */
 285 #define ADIO_EXPLICIT_OFFSET     100
 286 #define ADIO_INDIVIDUAL          101
 287 #define ADIO_SHARED              102
 288 
 289 #define ADIO_REQUEST_NULL        ((ADIO_Request) 0)
 290 #define ADIO_FILE_NULL           ((ADIO_File) 0)
 291 
 292 /* file systems */
 293 #define ADIO_NFS                 150
 294 #define ADIO_PIOFS               151   /* IBM */
 295 #define ADIO_UFS                 152   /* Unix file system */
 296 #define ADIO_PFS                 153   /* Intel */
 297 #define ADIO_XFS                 154   /* SGI */
 298 #define ADIO_HFS                 155   /* HP/Convex */
 299 #define ADIO_SFS                 156   /* NEC */
 300 #define ADIO_PVFS                157   /* PVFS for Linux Clusters from Clemson Univ. */
 301 #define ADIO_NTFS                158   /* NTFS for Windows NT */
 302 #define ADIO_TESTFS              159   /* fake file system for testing */
 303 #define ADIO_PVFS2               160   /* PVFS2: 2nd generation PVFS */
 304 #define ADIO_PANFS               161   /* Panasas FS */
 305 #define ADIO_GRIDFTP             162   /* Globus GridFTP */
 306 #define ADIO_LUSTRE              163   /* Lustre */
 307 /* #define ADIO_BGL              164 */  /* IBM BGL */
 308 /* #define ADIO_BGLOCKLESS       165 */  /* IBM BGL (lock-free) */
 309 #define ADIO_ZOIDFS              167   /* ZoidFS: the I/O forwarding fs */
 310 /* #define ADIO_BG               168 */
 311 #define ADIO_GPFS                  168
 312 
 313 #define ADIO_SEEK_SET            SEEK_SET
 314 #define ADIO_SEEK_CUR            SEEK_CUR
 315 #define ADIO_SEEK_END            SEEK_END
 316 
 317 #define ADIO_FCNTL_SET_ATOMICITY 180
 318 #define ADIO_FCNTL_SET_DISKSPACE 188
 319 #define ADIO_FCNTL_GET_FSIZE     200
 320 
 321 /* file system feature tests */
 322 #define ADIO_LOCKS               300 /* file system supports fcntl()-style locking */
 323 #define ADIO_SHARED_FP           301 /* file system supports shared file pointers */
 324 #define ADIO_ATOMIC_MODE         302 /* file system supports atomic mode */
 325 #define ADIO_DATA_SIEVING_WRITES 303 /* file system supports data sieving for writes */
 326 #define ADIO_SCALABLE_OPEN       304 /* one process can open the file and
 327                                         broadcast result to all other
 328                                         processors */
 329 #define ADIO_UNLINK_AFTER_CLOSE  305 /* supports posix semantic of keeping a
 330                                         deleted file around until all
 331                                         processors have closed it */
 332 #define ADIO_TWO_PHASE           306 /* file system implements some version of
 333                                         two-phase collective buffering with
 334                                         aggregation */
 335 #define ADIO_SCALABLE_RESIZE     307 /* file system supports resizing from one
 336                                         processor (nfs, e.g. does not) */
 337 
 338 /* for default file permissions */
 339 #define ADIO_PERM_NULL           -1
 340 
 341 #define ADIOI_FILE_COOKIE 2487376
 342 #define ADIOI_REQ_COOKIE 3493740
 343 
 344 /* ADIO function prototypes */
 345 /* all these may not be necessary, as many of them are macro replaced to 
 346    function pointers that point to the appropriate functions for each
 347    different file system (in adioi.h), but anyway... */
 348 
 349 void ADIO_Init(int *argc, char ***argv, int *error_code);
 350 void ADIO_End(int *error_code);
 351 MPI_File ADIO_Open(MPI_Comm orig_comm, MPI_Comm comm, const char *filename,
 352                    int file_system, ADIOI_Fns *ops,
 353                    int access_mode, ADIO_Offset disp, MPI_Datatype etype,
 354                    MPI_Datatype filetype,
 355                    MPI_Info info, int perm, int *error_code);
 356 void ADIOI_OpenColl(ADIO_File fd, int rank, int acces_mode, int *error_code);
 357 void ADIO_ImmediateOpen(ADIO_File fd, int *error_code);
 358 void ADIO_Close(ADIO_File fd, int *error_code);
 359 void ADIO_ReadContig(ADIO_File fd, void *buf, int count, MPI_Datatype datatype,
 360                     int file_ptr_type,  ADIO_Offset offset, 
 361                     ADIO_Status *status, int *error_code);
 362 void ADIO_WriteContig(ADIO_File fd, void *buf, int count, 
 363                      MPI_Datatype datatype, int file_ptr_type,
 364                       ADIO_Offset offset, int *bytes_written, int
 365                       *error_code);
 366 void ADIO_IwriteContig(ADIO_File fd, void *buf, int count, 
 367                       MPI_Datatype datatype, int file_ptr_type,
 368                       ADIO_Offset offset, ADIO_Request *request, int
 369                       *error_code);   
 370 void ADIO_IreadContig(ADIO_File fd, void *buf, int count, 
 371                       MPI_Datatype datatype, int file_ptr_type,
 372                       ADIO_Offset offset, ADIO_Request *request, int
 373                       *error_code);   
 374 int ADIO_ReadDone(ADIO_Request *request, ADIO_Status *status, 
 375                int *error_code);
 376 int ADIO_WriteDone(ADIO_Request *request, ADIO_Status *status, 
 377                int *error_code);
 378 int ADIO_ReadIcomplete(ADIO_Request *request, ADIO_Status *status, int
 379                        *error_code); 
 380 int ADIO_WriteIcomplete(ADIO_Request *request, ADIO_Status *status,
 381                         int *error_code); 
 382 void ADIO_ReadComplete(ADIO_Request *request, ADIO_Status *status, int
 383                        *error_code); 
 384 void ADIO_WriteComplete(ADIO_Request *request, ADIO_Status *status,
 385                         int *error_code); 
 386 void ADIO_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int
 387                 *error_code); 
 388 void ADIO_ReadStrided(ADIO_File fd, void *buf, int count,
 389                        MPI_Datatype datatype, int file_ptr_type,
 390                        ADIO_Offset offset, ADIO_Status *status, int
 391                        *error_code);
 392 void ADIO_WriteStrided(ADIO_File fd, const void *buf, int count,
 393                        MPI_Datatype datatype, int file_ptr_type,
 394                        ADIO_Offset offset, ADIO_Status *status, int
 395                        *error_code);
 396 void ADIO_ReadStridedColl(ADIO_File fd, void *buf, int count,
 397                        MPI_Datatype datatype, int file_ptr_type,
 398                        ADIO_Offset offset, ADIO_Status *status, int
 399                        *error_code);
 400 void ADIO_WriteStridedColl(ADIO_File fd, void *buf, int count,
 401                        MPI_Datatype datatype, int file_ptr_type,
 402                        ADIO_Offset offset, ADIO_Status *status, int
 403                        *error_code);
 404 void ADIO_IreadStrided(ADIO_File fd, void *buf, int count,
 405                        MPI_Datatype datatype, int file_ptr_type,
 406                        ADIO_Offset offset, ADIO_Request *request, int
 407                        *error_code);
 408 void ADIO_IwriteStrided(ADIO_File fd, void *buf, int count,
 409                        MPI_Datatype datatype, int file_ptr_type,
 410                        ADIO_Offset offset, ADIO_Request *request, int
 411                        *error_code);
 412 void ADIO_IreadStridedColl(ADIO_File fd, void *buf, int count,
 413                MPI_Datatype datatype, int file_ptr_type,
 414                ADIO_Offset offset, ADIO_Request *request,
 415                int *error_code);
 416 void ADIO_IwriteStridedColl(ADIO_File fd, void *buf, int count,
 417                MPI_Datatype datatype, int file_ptr_type,
 418                ADIO_Offset offset, ADIO_Request *request,
 419                int *error_code);
 420 ADIO_Offset ADIO_SeekIndividual(ADIO_File fd, ADIO_Offset offset, 
 421                        int whence, int *error_code);
 422 void ADIO_Delete(char *filename, int *error_code);
 423 void ADIO_Flush(ADIO_File fd, int *error_code);
 424 void ADIO_Resize(ADIO_File fd, ADIO_Offset size, int *error_code);
 425 void ADIO_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code);
 426 void ADIO_ResolveFileType(MPI_Comm comm, const char *filename, int *fstype,
 427           ADIOI_Fns **ops, int *error_code);
 428 void ADIO_Get_shared_fp(ADIO_File fd, ADIO_Offset size, ADIO_Offset *shared_fp,
 429                          int *error_code);
 430 void ADIO_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, int *error_code);
 431 void ADIO_Set_view(ADIO_File fd, ADIO_Offset disp, MPI_Datatype etype, 
 432                 MPI_Datatype filetype, MPI_Info info,  int *error_code);
 433 int  ADIO_Feature(ADIO_File fd, int flag);
 434 
 435 /* functions to help deal with the array datatypes */
 436 int ADIO_Type_create_subarray(int ndims,
 437                               int *array_of_sizes,
 438                               int *array_of_subsizes,
 439                               int *array_of_starts,
 440                               int order,
 441                               MPI_Datatype oldtype,
 442                               MPI_Datatype *newtype);
 443 int ADIO_Type_create_darray(int size, int rank, int ndims, 
 444                             int *array_of_gsizes, int *array_of_distribs, 
 445                             int *array_of_dargs, int *array_of_psizes, 
 446                             int order, MPI_Datatype oldtype, 
 447                             MPI_Datatype *newtype);
 448 
 449 /* MPI_File management functions (in mpio_file.c) */
 450 MPI_File MPIO_File_create(int size);
 451 ADIO_File MPIO_File_resolve(MPI_File mpi_fh);
 452 void MPIO_File_free(MPI_File *mpi_fh);
 453 MPI_File MPIO_File_f2c(MPI_Fint fh);
 454 MPI_Fint MPIO_File_c2f(MPI_File fh);
 455 int MPIO_Err_create_code(int lastcode, int fatal, const char fcname[],
 456                          int line, int error_class, const char generic_msg[],
 457                          const char specific_msg[], ... );
 458 int MPIO_Err_return_file(MPI_File mpi_fh, int error_code);
 459 int MPIO_Err_return_comm(MPI_Comm mpi_comm, int error_code);
 460 
 461 /* request managment helper functions */
 462 void MPIO_Completed_request_create(MPI_File *fh, MPI_Offset nbytes,
 463                 int * error_code, MPI_Request *request);
 464 
 465 #include "adioi.h"
 466 #include "adioi_fs_proto.h"
 467 #include "mpio_error.h"
 468 #include "mpipr.h"
 469 
 470 /* these two defines don't appear to be in any other header file */
 471 #define MPIR_ERR_FATAL 1
 472 #define MPIR_ERR_RECOVERABLE 0
 473 
 474 #endif

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