File: adio.h

package info (click to toggle)
openmpi 5.0.8-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 201,684 kB
  • sloc: ansic: 613,078; makefile: 42,353; sh: 11,194; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,179; python: 1,859; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (444 lines) | stat: -rw-r--r-- 18,745 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */

/* main include file for ADIO.
   contains general definitions, declarations, and macros independent
   of the underlying file system */

/* Functions and datataypes that are "internal" to the ADIO implementation
   prefixed ADIOI_. Functions and datatypes that are part of the
   "externally visible" (documented) ADIO interface are prefixed ADIO_.

   An implementation of MPI-IO, or any other high-level interface, should
   not need to use any of the ADIOI_ functions/datatypes.
   Only someone implementing ADIO on a new file system, or modifying
   an existing ADIO implementation, would need to use the ADIOI_
   functions/datatypes. */

#ifndef ADIO_H_INCLUDED
#define ADIO_H_INCLUDED

#ifdef SPPUX
#define _POSIX_SOURCE
#endif

#ifdef USE_FORT_STDCALL
#define FORT_CALL __stdcall
#elif defined (USE_FORT_CDECL)
#define FORT_CALL __cdecl
#else
#define FORT_CALL
#endif

#ifdef USE_FORT_MIXED_STR_LEN
#define FORT_MIXED_LEN_DECL   , int
#define FORT_END_LEN_DECL
#define FORT_MIXED_LEN(a)     , int a
#define FORT_END_LEN(a)
#else
#define FORT_MIXED_LEN_DECL
#define FORT_END_LEN_DECL     , int
#define FORT_MIXED_LEN(a)
#define FORT_END_LEN(a)       , int a
#endif


#ifdef HAVE_FORTRAN_API
#ifdef FORTRAN_EXPORTS
#define FORTRAN_API __declspec(dllexport)
#else
#define FORTRAN_API __declspec(dllimport)
#endif
#else
#define FORTRAN_API
#endif

/* Include romioconf.h if we haven't already (some include files may
   need to include romioconf before some system includes) */
#ifndef ROMIOCONF_H_INCLUDED
#include "romioconf.h"
#define ROMIOCONF_H_INCLUDED
#endif

#include "mpi.h"
#include "mpio.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#ifdef SPPUX
#include <sys/cnx_fcntl.h>
#endif

#ifdef ROMIO_NTFS
#include <winsock2.h>
#include <windows.h>
#define FDTYPE HANDLE
#else
#define FDTYPE int
#ifdef ROMIO_QUOBYTEFS
#include "quobyte.h"
#endif
#endif

typedef MPI_Offset ADIO_Offset;
#ifdef MPI_OFFSET_IS_INT
#define ADIO_OFFSET MPI_INT
#elif defined(HAVE_LONG_LONG_64)
#ifdef HAVE_MPI_LONG_LONG_INT
#define ADIO_OFFSET MPI_LONG_LONG_INT
#else
#define ADIO_OFFSET MPI_DOUBLE
#endif
#elif defined(HAVE_INT64)
#define ADIO_OFFSET MPI_DOUBLE
#else
#define ADIO_OFFSET MPI_LONG
#endif

#define ADIO_Status MPI_Status

#ifndef MPIO_INCLUDE
#ifdef NEEDS_MPI_FINT
typedef int MPI_Fint;
#endif
#endif

#if (!defined(HAVE_MPI_INFO) && !defined(MPIO_INCLUDE))
typedef struct MPIR_Info *MPI_Info;
#define MPI_INFO_NULL 0
#define MPI_MAX_INFO_VAL      1024

int MPI_Info_create(MPI_Info * info);
int MPI_Info_set(MPI_Info info, char *key, char *value);
int MPI_Info_delete(MPI_Info info, char *key);
int MPI_Info_get(MPI_Info info, char *key, int valuelen, char *value, int *flag);
int MPI_Info_get_valuelen(MPI_Info info, char *key, int *valuelen, int *flag);
int MPI_Info_get_nkeys(MPI_Info info, int *nkeys);
int MPI_Info_get_nthkey(MPI_Info info, int n, char *key);
int MPI_Info_dup(MPI_Info info, MPI_Info * newinfo);
int MPI_Info_free(MPI_Info * info);

#ifdef MPI_Info_f2c
#undef MPI_Info_f2c
#endif
#ifdef MPI_Info_c2f
#undef MPI_Info_c2f
#endif
/* above needed for some versions of mpi.h in MPICH!! */
MPI_Fint MPI_Info_c2f(MPI_Info info);
MPI_Info MPI_Info_f2c(MPI_Fint info);

int PMPI_Info_create(MPI_Info * info);
int PMPI_Info_set(MPI_Info info, char *key, char *value);
int PMPI_Info_delete(MPI_Info info, char *key);
int PMPI_Info_get(MPI_Info info, char *key, int valuelen, char *value, int *flag);
int PMPI_Info_get_valuelen(MPI_Info info, char *key, int *valuelen, int *flag);
int PMPI_Info_get_nkeys(MPI_Info info, int *nkeys);
int PMPI_Info_get_nthkey(MPI_Info info, int n, char *key);
int PMPI_Info_dup(MPI_Info info, MPI_Info * newinfo);
int PMPI_Info_free(MPI_Info * info);

MPI_Fint PMPI_Info_c2f(MPI_Info info);
MPI_Info PMPI_Info_f2c(MPI_Fint info);

#endif

/* style: allow:strdup:1 sig:0 */

#if defined(HAVE_STRDUP) && defined(NEEDS_STRDUP_DECL) && !defined(strdup)
char *strdup(const char *s);
#endif
#if defined(HAVE_READLINK) && defined(NEEDS_READLINK_DECL) && !defined(readlink)
ssize_t readlink(const char *path, char *buf, size_t bufsiz);
#endif
#if defined(HAVE_LSTAT) && defined(NEEDS_LSTAT_DECL) && !defined(lstat)
int lstat(const char *file_name, struct stat *buf);
#endif
#if defined(HAVE_FSYNC) && defined(NEEDS_FSYNC_DECL) && !defined(fsync)
int fsync(int fd);
#endif
#if defined(HAVE_FTRUNCATE) && defined(NEEDS_FTRUNCATE_DECL) && !defined(ftruncate)
int ftruncate(int fd, off_t length);
#endif


typedef struct ADIOI_Fns_struct ADIOI_Fns;
typedef struct ADIOI_Hints_struct ADIOI_Hints;

typedef struct ADIOI_FileD {
    int cookie;                 /* for error checking */
    FDTYPE fd_sys;              /* system file descriptor */
    FDTYPE null_fd;             /* the null-device file descriptor: debug only (obviously) */
    int fd_direct;              /* On XFS, this is used for direct I/O;
                                 * fd_sys is used for buffered I/O */
    int direct_read;            /* flag; 1 means use direct read */
    int direct_write;           /* flag; 1 means use direct write  */
    /* direct I/O attributes */
    unsigned d_mem;             /* data buffer memory alignment */
    unsigned d_miniosz;         /* min xfer size, xfer size multiple,
                                 * and file seek offset alignment */
    long blksize;               /* some optimizations benefit from knowing
                                 * underlying block size */
    ADIO_Offset fp_ind;         /* individual file pointer in MPI-IO (in bytes) */
    ADIO_Offset fp_sys_posn;    /* current location of the system file-pointer
                                 * in bytes */
    ADIOI_Fns *fns;             /* struct of I/O functions to use */
    MPI_Comm comm;              /* communicator indicating who called open */
    int is_open;                /* deferred open: 0: not open yet 1: is open */
    int is_agg;                 /* bool: if I am an aggregator */
    char *filename;
    int file_system;            /* type of file system */
    int access_mode;            /* Access mode (sequential, append, etc.),
                                 * possibly modified to deal with
                                 * data sieving or deferred open */
    int orig_access_mode;       /* Access mode provided by user: unmodified */
    ADIO_Offset disp;           /* reqd. for MPI-IO */
    MPI_Datatype etype;         /* reqd. for MPI-IO */
    MPI_Datatype filetype;      /* reqd. for MPI-IO */
    MPI_Count etype_size;       /* in bytes */
    ADIOI_Hints *hints;         /* structure containing fs-indep. info values */
    MPI_Info info;

    /* The following support the split collective operations */
    int split_coll_count;       /* count of outstanding split coll. ops. */
    MPI_Status split_status;    /* status used for split collectives */
    MPI_Datatype split_datatype;        /* datatype used for split collectives */

    /* The following support the shared file operations */
    char *shared_fp_fname;      /* name of file containing shared file pointer */
    struct ADIOI_FileD *shared_fp_fd;   /* file handle of file
                                         * containing shared fp */
    int async_count;            /* count of outstanding nonblocking operations */
    int perm;
    int atomicity;              /* true=atomic, false=nonatomic */
    int fortran_handle;         /* handle for Fortran interface if needed */
    MPI_Errhandler err_handler;
    void *fs_ptr;               /* file-system specific information */

    /* Two phase collective I/O support */
    ADIO_Offset *file_realm_st_offs;    /* file realm starting offsets */
    MPI_Datatype *file_realm_types;     /* file realm datatypes */
    int my_cb_nodes_index;      /* my index into cb_config_list. -1 if N/A */
    char *io_buf;               /* two-phase buffer allocated out of i/o path */
    MPI_Win io_buf_window;      /* Window over the io_buf to support one-sided aggregation */
    int io_buf_put_amounts;     /* the amount of data mpi_put into the io_buf
                                 * during the same round of one-sided write aggregation */
    MPI_Win io_buf_put_amounts_window;  /* Window over the io_buf_put_amounts */
    /* External32 */
    int is_external32;          /* bool:  0 means native view */
#ifdef ROMIO_QUOBYTEFS
    struct quobyte_fh *file_handle;     /* file handle for quobytefs */
#endif
} ADIOI_FileD;

typedef struct ADIOI_FileD *ADIO_File;

typedef MPI_Request ADIO_Request;

/* fcntl structure */
typedef struct {
    ADIO_Offset disp;
    MPI_Datatype etype;
    MPI_Datatype filetype;
    MPI_Info info;
    int atomicity;
    ADIO_Offset fsize;          /* for get_fsize only */
    ADIO_Offset diskspace;      /* for file preallocation */
} ADIO_Fcntl_t;                 /* should contain more stuff */


/* access modes */
#define ADIO_CREATE              1
#define ADIO_RDONLY              2
#define ADIO_WRONLY              4
#define ADIO_RDWR                8
#define ADIO_DELETE_ON_CLOSE     16
#define ADIO_UNIQUE_OPEN         32
#define ADIO_EXCL                64
#define ADIO_APPEND             128
#define ADIO_SEQUENTIAL         256

#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)

/* file-pointer types */
#define ADIO_EXPLICIT_OFFSET     100
#define ADIO_INDIVIDUAL          101
#define ADIO_SHARED              102

#define ADIO_REQUEST_NULL        ((ADIO_Request) 0)
#define ADIO_FILE_NULL           ((ADIO_File) 0)

/* file systems:
 * the numbering is slightly strange because we have deleted file
 * systems over time */
#define ADIO_NFS                 150
#define ADIO_UFS                 152    /* Unix file system */
#define ADIO_XFS                 154    /* SGI */
#define ADIO_TESTFS              159    /* fake file system for testing */
#define ADIO_PVFS2               160    /* PVFS2: 2nd generation PVFS */
#define ADIO_PANFS               161    /* Panasas FS */
#define ADIO_LUSTRE              163    /* Lustre */
#define ADIO_GPFS                168
#define ADIO_IME                 169    /* IME burst buffer */
#define ADIO_DAOS                170
#define ADIO_QUOBYTEFS           171    /* Quobyte FS */

#define ADIO_SEEK_SET            SEEK_SET
#define ADIO_SEEK_CUR            SEEK_CUR
#define ADIO_SEEK_END            SEEK_END

#define ADIO_FCNTL_SET_ATOMICITY 180
#define ADIO_FCNTL_SET_DISKSPACE 188
#define ADIO_FCNTL_GET_FSIZE     200

/* file system feature tests */
#define ADIO_LOCKS               300    /* file system supports fcntl()-style locking */
#define ADIO_SHARED_FP           301    /* file system supports shared file pointers */
#define ADIO_ATOMIC_MODE         302    /* file system supports atomic mode */
#define ADIO_DATA_SIEVING_WRITES 303    /* file system supports data sieving for writes */
#define ADIO_SCALABLE_OPEN       304    /* one process can open the file and
                                         * broadcast result to all other
                                         * processors */
#define ADIO_UNLINK_AFTER_CLOSE  305    /* supports posix semantic of keeping a
                                         * deleted file around until all
                                         * processors have closed it */
#define ADIO_TWO_PHASE           306    /* file system implements some version of
                                         * two-phase collective buffering with
                                         * aggregation */
#define ADIO_SCALABLE_RESIZE     307    /* file system supports resizing from one
                                         * processor (nfs, e.g. does not) */

/* for default file permissions */
#define ADIO_PERM_NULL           -1

#define ADIOI_FILE_COOKIE 2487376
#define ADIOI_REQ_COOKIE 3493740

/* ADIO function prototypes */
/* all these may not be necessary, as many of them are macro replaced to
   function pointers that point to the appropriate functions for each
   different file system (in adioi.h), but anyway... */

void ADIO_Init(int *argc, char ***argv, int *error_code);
void ADIO_End(int *error_code);
MPI_File ADIO_Open(MPI_Comm orig_comm, MPI_Comm comm, const char *filename,
                   int file_system, ADIOI_Fns * ops,
                   int access_mode, ADIO_Offset disp, MPI_Datatype etype,
                   MPI_Datatype filetype, MPI_Info info, int perm, int *error_code);
void ADIOI_OpenColl(ADIO_File fd, int rank, int acces_mode, int *error_code);
void ADIO_ImmediateOpen(ADIO_File fd, int *error_code);
void ADIO_Close(ADIO_File fd, int *error_code);
void ADIO_ReadContig(ADIO_File fd, void *buf, int count, MPI_Datatype datatype,
                     int file_ptr_type, ADIO_Offset offset, ADIO_Status * status, int *error_code);
void ADIO_WriteContig(ADIO_File fd, void *buf, int count,
                      MPI_Datatype datatype, int file_ptr_type,
                      ADIO_Offset offset, int *bytes_written, int
                      *error_code);
void ADIO_IwriteContig(ADIO_File fd, void *buf, int count,
                       MPI_Datatype datatype, int file_ptr_type,
                       ADIO_Offset offset, ADIO_Request * request, int
                       *error_code);
void ADIO_IreadContig(ADIO_File fd, void *buf, int count,
                      MPI_Datatype datatype, int file_ptr_type,
                      ADIO_Offset offset, ADIO_Request * request, int
                      *error_code);
int ADIO_ReadDone(ADIO_Request * request, ADIO_Status * status, int *error_code);
int ADIO_WriteDone(ADIO_Request * request, ADIO_Status * status, int *error_code);
int ADIO_ReadIcomplete(ADIO_Request * request, ADIO_Status * status, int
                       *error_code);
int ADIO_WriteIcomplete(ADIO_Request * request, ADIO_Status * status, int *error_code);
void ADIO_ReadComplete(ADIO_Request * request, ADIO_Status * status, int
                       *error_code);
void ADIO_WriteComplete(ADIO_Request * request, ADIO_Status * status, int *error_code);
void ADIO_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t * fcntl_struct, int
                *error_code);
void ADIO_ReadStrided(ADIO_File fd, void *buf, int count,
                      MPI_Datatype datatype, int file_ptr_type,
                      ADIO_Offset offset, ADIO_Status * status, int
                      *error_code);
void ADIO_WriteStrided(ADIO_File fd, const void *buf, int count,
                       MPI_Datatype datatype, int file_ptr_type,
                       ADIO_Offset offset, ADIO_Status * status, int
                       *error_code);
void ADIO_ReadStridedColl(ADIO_File fd, void *buf, int count,
                          MPI_Datatype datatype, int file_ptr_type,
                          ADIO_Offset offset, ADIO_Status * status, int
                          *error_code);
void ADIO_WriteStridedColl(ADIO_File fd, void *buf, int count,
                           MPI_Datatype datatype, int file_ptr_type,
                           ADIO_Offset offset, ADIO_Status * status, int
                           *error_code);
void ADIO_IreadStrided(ADIO_File fd, void *buf, int count,
                       MPI_Datatype datatype, int file_ptr_type,
                       ADIO_Offset offset, ADIO_Request * request, int
                       *error_code);
void ADIO_IwriteStrided(ADIO_File fd, void *buf, int count,
                        MPI_Datatype datatype, int file_ptr_type,
                        ADIO_Offset offset, ADIO_Request * request, int
                        *error_code);
void ADIO_IreadStridedColl(ADIO_File fd, void *buf, int count,
                           MPI_Datatype datatype, int file_ptr_type,
                           ADIO_Offset offset, ADIO_Request * request, int *error_code);
void ADIO_IwriteStridedColl(ADIO_File fd, void *buf, int count,
                            MPI_Datatype datatype, int file_ptr_type,
                            ADIO_Offset offset, ADIO_Request * request, int *error_code);
ADIO_Offset ADIO_SeekIndividual(ADIO_File fd, ADIO_Offset offset, int whence, int *error_code);
void ADIO_Delete(char *filename, int *error_code);
void ADIO_Flush(ADIO_File fd, int *error_code);
void ADIO_Resize(ADIO_File fd, ADIO_Offset size, int *error_code);
void ADIO_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code);
void ADIO_ResolveFileType(MPI_Comm comm, const char *filename, int *fstype,
                          ADIOI_Fns ** ops, int *error_code);
void ADIO_Get_shared_fp(ADIO_File fd, ADIO_Offset size, ADIO_Offset * shared_fp, int *error_code);
void ADIO_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, int *error_code);
void ADIO_Set_view(ADIO_File fd, ADIO_Offset disp, MPI_Datatype etype,
                   MPI_Datatype filetype, MPI_Info info, int *error_code);
int ADIO_Feature(ADIO_File fd, int flag);

/* functions to help deal with the array datatypes */
int ADIO_Type_create_subarray(int ndims,
                              int *array_of_sizes,
                              int *array_of_subsizes,
                              int *array_of_starts,
                              int order, MPI_Datatype oldtype, MPI_Datatype * newtype);
int ADIO_Type_create_darray(int size, int rank, int ndims,
                            int *array_of_gsizes, int *array_of_distribs,
                            int *array_of_dargs, int *array_of_psizes,
                            int order, MPI_Datatype oldtype, MPI_Datatype * newtype);

/* MPI_File management functions (in mpio_file.c) */
MPI_File MPIO_File_create(int size);
ADIO_File MPIO_File_resolve(MPI_File mpi_fh);
void MPIO_File_free(MPI_File * mpi_fh);
MPI_File MPIO_File_f2c(MPI_Fint fh);
MPI_Fint MPIO_File_c2f(MPI_File fh);
int MPIO_Err_create_code(int lastcode, int fatal, const char fcname[],
                         int line, int error_class, const char generic_msg[],
                         const char specific_msg[], ...);
int MPIO_Err_return_file(MPI_File mpi_fh, int error_code);
int MPIO_Err_return_comm(MPI_Comm mpi_comm, int error_code);

/* request managment helper functions */
void MPIO_Completed_request_create(MPI_File * fh, MPI_Offset nbytes,
                                   int *error_code, MPI_Request * request);

#include "adioi.h"
#include "adioi_fs_proto.h"
#include "mpio_error.h"
#include "mpipr.h"

/* these two defines don't appear to be in any other header file */
#define MPIR_ERR_FATAL 1
#define MPIR_ERR_RECOVERABLE 0

#endif /* ADIO_H_INCLUDED */