SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
sion_internal.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2019 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** Copyright (c) 2019 **
8 ** DataDirect Networks **
9 ** **
10 ** See the file COPYRIGHT in the package base directory for details **
11 ****************************************************************************/
12 
17 #ifndef SION_SION_INTERNAL_H
18 #define SION_SION_INTERNAL_H
19 
20 #include <stdio.h>
21 
22 #ifdef _SION_CUDA
23 #include <cuda_runtime.h>
24 #endif
25 
26 #include "sion_const.h"
27 #include "sion_common.h"
28 #include "sion_datatypes.h"
29 #include "sion_filedesc.h"
30 
31 #define _SION_READ_MASTER_ONLY_OF_MULTI_FILES 0
32 #define _SION_READ_ALL_OF_MULTI_FILES 1
33 
34 #define _SION_SAFE_FREE(ptr, null) {if (ptr) {free(ptr); ptr = null;}}
35 
36 /* internal functions for serial open/close, will also be used by parallel APIs */
37 int _sion_open( const char *fname,
38  const char* file_mode,
39  int *ntasks,
40  int *nfiles,
41  sion_int64 **chunksizes,
42  sion_int32 *fsblksize,
43  int **globalranks,
44  FILE **fileptr);
45 
46 int _sion_open_rank( const char *fname,
47  const char *file_mode,
48  sion_int64 *chunksize,
49  sion_int32 *fsblksize,
50  int *rank,
51  FILE **fileptr);
52 
53 int _sion_open_write(const char *fname, sion_int64 file_mode_flags, int *ntasks, int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize, int **globalranks, FILE **fileptr);
54 int _sion_open_read(const char *fname, sion_int64 file_mode_flags, int read_all, int *ntasks, int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize, int **globalranks, FILE **fileptr);
55 int _sion_open_read_single(const char *fname, sion_int64 file_mode_flags, int *ntasks, int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize, int **globalranks, FILE **fileptr, _sion_filedesc *sion_filedesc);
56 int _sion_open_read_master(const char *fname, sion_int64 file_mode_flags, int *ntasks, int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize, int **globalranks, FILE **fileptr, _sion_filedesc *sion_filedesc);
57 
58 int _sion_close(_sion_filedesc *sion_filedesc);
59 
60 int _sion_create_new_block( _sion_filedesc *sion_filedesc );
61 int _sion_flush_block( _sion_filedesc *sion_filedesc );
62 int _sion_update_fileposition( _sion_filedesc *sion_filedesc );
64 
65 char * _sion_get_multi_filename(const char *fname, int filenumber);
66 
67 sion_int32 _sion_get_endianness_with_flags(sion_int64 flags);
68 
69  /* File mode flags */
70 #define _SION_FMODE_WRITE 1024
71 #define _SION_FMODE_READ 2048
72 #define _SION_FMODE_ANSI 1
73 #define _SION_FMODE_POSIX 2
74 #define _SION_FMODE_BUFFERED 4
75 #define _SION_FMODE_COMPRESS 8
76 #define _SION_FMODE_COLLECTIVE 16
77 #define _SION_FMODE_COLLECTIVE_MERGE 32
78 #define _SION_FMODE_KEYVAL 64
79 #define _SION_FMODE_KEYVAL_INLINE 4096
80 #define _SION_FMODE_KEYVAL_META 8192
81 #define _SION_FMODE_KEYVAL_HASH 16384
82 #define _SION_FMODE_KEYVAL_NONE 32768
83 #define _SION_FMODE_KEYVAL_UNKNOWN 65536
84 #define _SION_FMODE_ENDIANNESS_SET 131072
85 #define _SION_FMODE_ENDIANNESS_BIG 262144
86 #define _SION_FMODE_BUDDY 524288
87 
88 #if defined(_SION_SIONFWD)
89 #define _SION_FMODE_SIONFWD 1048576
90 #endif
91 
92 #ifdef _SION_IME_NATIVE
93 #define _SION_FMODE_IME_NATIVE 2097152
94 #endif
95 
96 char *_sion_getenv(const char *name);
97 
100 
101 #ifdef _SION_CUDA
102 #if CUDART_VERSION < 11000
103 #define _sion_cuda_ptr_is_device(attrs) (!attrs.isManaged && (attrs.memoryType == cudaMemoryTypeDevice))
104 #else
105 #define _sion_cuda_ptr_is_device(attrs) (attrs.type == cudaMemoryTypeDevice)
106 #endif
107 #endif
108 
109 #endif
int _sion_create_new_block(_sion_filedesc *sion_filedesc)
Create a new block for the internal data structure.
int _sion_open_write(const char *fname, sion_int64 file_mode_flags, int *ntasks, int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize, int **globalranks, FILE **fileptr)
internal sion serial open function for writing on one file
char * _sion_getenv(const char *name)
int _sion_free_io_info(sion_io_stat_t *p)
frees an io_info data structure
char * _sion_get_multi_filename(const char *fname, int filenumber)
generates the multi filename
int _sion_flush_block(_sion_filedesc *sion_filedesc)
Update the internal data structure.
int _sion_check_on_collective_mode(_sion_filedesc *sion_filedesc)
check if a collective operation are already called,
sion_int32 _sion_get_endianness_with_flags(sion_int64 flags)
Return endianness including possible choice via flags.
int _sion_open_read(const char *fname, sion_int64 file_mode_flags, int read_all, int *ntasks, int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize, int **globalranks, FILE **fileptr)
internal sion serial open function for reading on one or more files
int _sion_update_fileposition(_sion_filedesc *sion_filedesc)
Update the internal data structure (check fileposition)
sion_io_stat_t * _sion_alloc_io_info(int nfiles)
allocates an io_info data structure for nfiles files
Sion File Descriptor Structure.
Definition: sion_filedesc.h:79