10 #ifndef __PIO_INTERNAL__ 11 #define __PIO_INTERNAL__ 17 #ifdef OMPI_OFFSET_DATATYPE 19 #define MPI_OFFSET OMPI_OFFSET_DATATYPE 23 #define MPI_Offset long long 32 #if PIO_ENABLE_LOGGING 33 void pio_log(
int severity,
const char *fmt, ...);
34 #define LOG(e) pio_log e 40 ({ __typeof__ (a) _a = (a); \ 41 __typeof__ (b) _b = (b); \ 45 ({ __typeof__ (a) _a = (a); \ 46 __typeof__ (b) _b = (b); \ 49 #define MAX_GATHER_BLOCK_SIZE 0 50 #define PIO_REQUEST_ALLOC_CHUNK 16 52 #if defined(__cplusplus) 56 extern PIO_Offset PIO_BUFFER_SIZE_LIMIT;
57 extern bool PIO_Save_Decomps;
76 int pio_add_to_iodesc_list(
io_desc_t *iodesc);
77 io_desc_t *pio_get_iodesc_from_id(
int ioid);
78 int pio_delete_iodesc_from_list(
int ioid);
81 int pio_delete_file_from_list(
int ncid);
83 void pio_push_request(
file_desc_t *file,
int request);
89 int iotype_error(
const int iotype,
const char *fname,
const int line);
90 void piodie(
const char *msg,
const char *fname,
const int line);
91 void pioassert(
bool exp,
const char *msg,
const char *fname,
const int line);
92 int CalcStartandCount(
const int basetype,
const int ndims,
const int *gdims,
const int num_io_procs,
93 const int myiorank, PIO_Offset *start, PIO_Offset *kount);
94 void CheckMPIReturn(
const int ierr,
const char file[],
const int line);
95 int pio_fc_gather(
void *sendbuf,
const int sendcnt,
const MPI_Datatype sendtype,
96 void *recvbuf,
const int recvcnt,
const MPI_Datatype recvtype,
const int root,
97 MPI_Comm comm,
const int flow_cntl);
98 int pio_fc_gatherv(
void *sendbuf,
const int sendcnt,
const MPI_Datatype sendtype,
99 void *recvbuf,
const int recvcnts[],
const int recvdispl[],
const MPI_Datatype recvtype,
const int root,
100 MPI_Comm comm,
const int flow_cntl);
102 int pio_fc_gatherv(
void *sendbuf,
const int sendcnt,
const MPI_Datatype sendtype,
103 void *recvbuf,
const int recvcnts[],
const int rdispls[],
const MPI_Datatype recvtype,
const int root,
104 MPI_Comm comm,
const int flow_cntl);
106 int pio_swapm(
void *sndbuf,
int sndlths[],
int sdispls[], MPI_Datatype stypes[],
107 void *rcvbuf,
int rcvlths[],
int rdispls[], MPI_Datatype rtypes[],
108 MPI_Comm comm,
const bool handshake,
bool isend,
const int max_requests);
110 long long lgcd_array(
int nain,
long long*ain);
112 void PIO_Offset_size(MPI_Datatype *dtype,
int *tsize);
113 PIO_Offset GCDblocksize(
const int arrlen,
const PIO_Offset arr_in[]);
126 void *rbuf,
const int nvars);
127 int calcdisplace(
const int bsize,
const int numblocks,
const PIO_Offset map[],
int displace[]);
128 io_desc_t *malloc_iodesc(
const int piotype,
const int ndims);
133 io_region *alloc_region(
const int ndims);
135 int gcd(
int a,
int b);
136 long long lgcd (
long long a,
long long b );
137 int gcd_array(
int nain,
int *ain);
139 void gindex_to_coord(
const int ndims,
const PIO_Offset gindex,
const PIO_Offset gstride[], PIO_Offset *gcoord);
140 PIO_Offset
coord_to_lindex(
const int ndims,
const PIO_Offset lcoord[],
const PIO_Offset count[]);
142 int ceil2(
const int i);
143 int pair(
const int np,
const int p,
const int k);
147 const PIO_Offset mindex[],
const int mcount[],
int *mfrom, MPI_Datatype mtype[]);
151 const int gsize[],
const int ndims,
io_desc_t *iodesc);
152 void print_trace (FILE *fp);
157 void piomemerror(
iosystem_desc_t ios,
size_t req,
char *fname,
const int line);
163 void identity(MPI_Comm comm,
int *iotask);
164 void determineiotasks(
const MPI_Comm comm,
int *numiotasks,
int *base,
int *stride,
int *rearr,
169 #if defined(__cplusplus) 184 PIO_MSG_PUT_ATT_DOUBLE,
189 PIO_MSG_GET_ATT_TEXT,
190 PIO_MSG_GET_ATT_SHORT,
191 PIO_MSG_PUT_ATT_LONG,
196 PIO_MSG_PUT_ATT_SHORT,
197 PIO_MSG_PUT_ATT_TEXT,
199 PIO_MSG_GET_ATT_ULONGLONG,
200 PIO_MSG_GET_ATT_USHORT,
201 PIO_MSG_PUT_ATT_ULONGLONG,
202 PIO_MSG_GET_ATT_UINT,
203 PIO_MSG_GET_ATT_LONGLONG,
204 PIO_MSG_PUT_ATT_SCHAR,
205 PIO_MSG_PUT_ATT_FLOAT,
207 PIO_MSG_GET_ATT_LONG,
210 PIO_MSG_PUT_ATT_USHORT,
211 PIO_MSG_GET_ATT_FLOAT,
213 PIO_MSG_PUT_ATT_LONGLONG,
214 PIO_MSG_PUT_ATT_UINT,
215 PIO_MSG_GET_ATT_SCHAR,
219 PIO_MSG_GET_ATT_DOUBLE,
220 PIO_MSG_PUT_ATT_UCHAR,
221 PIO_MSG_GET_ATT_UCHAR,
222 PIO_MSG_PUT_VARS_UCHAR,
223 PIO_MSG_GET_VAR1_SCHAR,
224 PIO_MSG_GET_VARS_ULONGLONG,
225 PIO_MSG_GET_VARM_UCHAR,
226 PIO_MSG_GET_VARM_SCHAR,
227 PIO_MSG_GET_VARS_SHORT,
228 PIO_MSG_GET_VAR_DOUBLE,
229 PIO_MSG_GET_VARA_DOUBLE,
231 PIO_MSG_GET_VAR_USHORT,
232 PIO_MSG_PUT_VARS_USHORT,
233 PIO_MSG_GET_VARA_TEXT,
234 PIO_MSG_PUT_VARS_ULONGLONG,
235 PIO_MSG_GET_VARA_INT,
237 PIO_MSG_GET_VAR1_FLOAT,
238 PIO_MSG_GET_VAR1_SHORT,
239 PIO_MSG_GET_VARS_INT,
240 PIO_MSG_PUT_VARS_UINT,
241 PIO_MSG_GET_VAR_TEXT,
242 PIO_MSG_GET_VARM_DOUBLE,
243 PIO_MSG_PUT_VARM_UCHAR,
244 PIO_MSG_PUT_VAR_USHORT,
245 PIO_MSG_GET_VARS_SCHAR,
246 PIO_MSG_GET_VARA_USHORT,
247 PIO_MSG_PUT_VAR1_LONGLONG,
248 PIO_MSG_PUT_VARA_UCHAR,
249 PIO_MSG_PUT_VARM_SHORT,
250 PIO_MSG_PUT_VAR1_LONG,
251 PIO_MSG_PUT_VARS_LONG,
252 PIO_MSG_GET_VAR1_USHORT,
253 PIO_MSG_PUT_VAR_SHORT,
254 PIO_MSG_PUT_VARA_INT,
255 PIO_MSG_GET_VAR_FLOAT,
256 PIO_MSG_PUT_VAR1_USHORT,
257 PIO_MSG_PUT_VARA_TEXT,
258 PIO_MSG_PUT_VARM_TEXT,
259 PIO_MSG_GET_VARS_UCHAR,
261 PIO_MSG_PUT_VARM_USHORT,
262 PIO_MSG_GET_VAR1_LONGLONG,
263 PIO_MSG_GET_VARS_USHORT,
264 PIO_MSG_GET_VAR_LONG,
265 PIO_MSG_GET_VAR1_DOUBLE,
266 PIO_MSG_PUT_VAR_ULONGLONG,
268 PIO_MSG_GET_VARA_UINT,
269 PIO_MSG_PUT_VAR_LONGLONG,
270 PIO_MSG_GET_VARS_LONGLONG,
271 PIO_MSG_PUT_VAR_SCHAR,
272 PIO_MSG_PUT_VAR_UINT,
274 PIO_MSG_PUT_VARA_USHORT,
275 PIO_MSG_GET_VAR_LONGLONG,
276 PIO_MSG_GET_VARA_SHORT,
277 PIO_MSG_PUT_VARS_SHORT,
278 PIO_MSG_PUT_VARA_UINT,
279 PIO_MSG_PUT_VARA_SCHAR,
280 PIO_MSG_PUT_VARM_ULONGLONG,
281 PIO_MSG_PUT_VAR1_UCHAR,
282 PIO_MSG_PUT_VARM_INT,
283 PIO_MSG_PUT_VARS_SCHAR,
284 PIO_MSG_GET_VARA_LONG,
286 PIO_MSG_GET_VAR1_INT,
287 PIO_MSG_GET_VAR1_ULONGLONG,
288 PIO_MSG_GET_VAR_UCHAR,
289 PIO_MSG_PUT_VARA_FLOAT,
290 PIO_MSG_GET_VARA_UCHAR,
291 PIO_MSG_GET_VARS_FLOAT,
292 PIO_MSG_PUT_VAR1_FLOAT,
293 PIO_MSG_PUT_VARM_FLOAT,
294 PIO_MSG_PUT_VAR1_TEXT,
295 PIO_MSG_PUT_VARS_TEXT,
296 PIO_MSG_PUT_VARM_LONG,
297 PIO_MSG_GET_VARS_LONG,
298 PIO_MSG_PUT_VARS_DOUBLE,
300 PIO_MSG_GET_VAR_UINT,
301 PIO_MSG_PUT_VARA_LONGLONG,
303 PIO_MSG_PUT_VAR_DOUBLE,
304 PIO_MSG_GET_VARA_SCHAR,
305 PIO_MSG_PUT_VAR_FLOAT,
306 PIO_MSG_GET_VAR1_UINT,
307 PIO_MSG_GET_VARS_UINT,
308 PIO_MSG_PUT_VAR1_ULONGLONG,
309 PIO_MSG_PUT_VARM_UINT,
310 PIO_MSG_PUT_VAR1_UINT,
311 PIO_MSG_PUT_VAR1_INT,
312 PIO_MSG_GET_VARA_FLOAT,
313 PIO_MSG_GET_VARM_TEXT,
314 PIO_MSG_PUT_VARS_FLOAT,
315 PIO_MSG_GET_VAR1_TEXT,
316 PIO_MSG_PUT_VARA_SHORT,
317 PIO_MSG_PUT_VAR1_SCHAR,
318 PIO_MSG_PUT_VARA_ULONGLONG,
319 PIO_MSG_PUT_VARM_DOUBLE,
320 PIO_MSG_GET_VARM_INT,
322 PIO_MSG_PUT_VARA_LONG,
323 PIO_MSG_GET_VARM_UINT,
325 PIO_MSG_PUT_VAR1_DOUBLE,
326 PIO_MSG_GET_VARS_DOUBLE,
327 PIO_MSG_GET_VARA_LONGLONG,
328 PIO_MSG_GET_VAR_ULONGLONG,
329 PIO_MSG_PUT_VARM_SCHAR,
330 PIO_MSG_GET_VARA_ULONGLONG,
331 PIO_MSG_GET_VAR_SHORT,
332 PIO_MSG_GET_VARM_FLOAT,
333 PIO_MSG_PUT_VAR_TEXT,
334 PIO_MSG_PUT_VARS_INT,
335 PIO_MSG_GET_VAR1_LONG,
336 PIO_MSG_GET_VARM_LONG,
337 PIO_MSG_GET_VARM_USHORT,
338 PIO_MSG_PUT_VAR1_SHORT,
339 PIO_MSG_PUT_VARS_LONGLONG,
340 PIO_MSG_GET_VARM_LONGLONG,
341 PIO_MSG_GET_VARS_TEXT,
342 PIO_MSG_PUT_VARA_DOUBLE,
344 PIO_MSG_PUT_VAR_UCHAR,
345 PIO_MSG_GET_VAR1_UCHAR,
346 PIO_MSG_PUT_VAR_LONG,
348 PIO_MSG_GET_VARM_SHORT,
349 PIO_MSG_GET_VARM_ULONGLONG,
350 PIO_MSG_PUT_VARM_LONGLONG,
351 PIO_MSG_GET_VAR_SCHAR,
352 PIO_MSG_GET_ATT_UBYTE,
353 PIO_MSG_PUT_ATT_STRING,
354 PIO_MSG_GET_ATT_STRING,
355 PIO_MSG_PUT_ATT_UBYTE,
356 PIO_MSG_INQ_VAR_FILL,
357 PIO_MSG_DEF_VAR_FILL,
358 PIO_MSG_DEF_VAR_DEFLATE,
359 PIO_MSG_INQ_VAR_DEFLATE,
360 PIO_MSG_INQ_VAR_SZIP,
361 PIO_MSG_DEF_VAR_FLETCHER32,
362 PIO_MSG_INQ_VAR_FLETCHER32,
363 PIO_MSG_DEF_VAR_CHUNKING,
364 PIO_MSG_INQ_VAR_CHUNKING,
365 PIO_MSG_DEF_VAR_ENDIAN,
366 PIO_MSG_INQ_VAR_ENDIAN,
367 PIO_MSG_SET_CHUNK_CACHE,
368 PIO_MSG_GET_CHUNK_CACHE,
369 PIO_MSG_SET_VAR_CHUNK_CACHE,
370 PIO_MSG_GET_VAR_CHUNK_CACHE,
371 PIO_MSG_INITDECOMP_DOF,
374 PIO_MSG_SETERRORHANDLING,
IO system descriptor structure.
Definition: pio.h:140
void compute_maxaggregate_bytes(const iosystem_desc_t ios, io_desc_t *iodesc)
Compute the maximum aggregate number of bytes.
Definition: pio_darray.c:2148
void CheckMPIReturn(const int ierr, const char file[], const int line)
Wrapper for MPI calls to print the Error string on error.
Definition: pio_spmd.c:32
void pio_get_env(void)
Get PIO environment variables.
Definition: pioc_support.c:163
int pio_swapm(void *sndbuf, int sndlths[], int sdispls[], MPI_Datatype stypes[], void *rcvbuf, int rcvlths[], int rdispls[], MPI_Datatype rtypes[], MPI_Comm comm, const bool handshake, bool isend, const int max_requests)
Provides the functionality of MPI_Alltoallw with flow control options.
Definition: pio_spmd.c:241
PIO_Offset coord_to_lindex(const int ndims, const PIO_Offset lcoord[], const PIO_Offset count[])
Definition: pio_rearrange.c:130
int check_netcdf(file_desc_t *file, const int status, const char *fname, const int line)
Check the result of a netCDF API call.
Definition: pioc_support.c:304
int create_mpi_datatypes(const MPI_Datatype basetype, const int msgcnt, const PIO_Offset dlen, const PIO_Offset mindex[], const int mcount[], int *mfrom, MPI_Datatype mtype[])
Definition: pio_rearrange.c:187
int pio_fc_gather(void *sendbuf, const int sendcnt, const MPI_Datatype sendtype, void *recvbuf, const int recvcnt, const MPI_Datatype recvtype, const int root, MPI_Comm comm, const int flow_cntl)
Provides the functionality of MPI_Gather with flow control options.
Definition: pio_spmd.c:50
int pio_fc_gatherv(void *sendbuf, const int sendcnt, const MPI_Datatype sendtype, void *recvbuf, const int recvcnts[], const int recvdispl[], const MPI_Datatype recvtype, const int root, MPI_Comm comm, const int flow_cntl)
Provides the functionality of MPI_Gatherv with flow control options.
Definition: pio_spmd.c:137
struct pio_swapm_defaults pio_swapm_defaults
swapm defaults.
int compare_offsets(const void *a, const void *b)
Definition: pio_rearrange.c:1125
swapm defaults.
Definition: pio_internal.h:68
int pio_delete_iosystem_from_list(int piosysid)
Delete iosystem info from list.
Definition: pio_lists.c:88
PIO_MSG
These are the messages that can be sent over the intercomm when async is being used.
Definition: pio_internal.h:175
File descriptor structure.
Definition: pio.h:254
void compute_maxIObuffersize(MPI_Comm io_comm, io_desc_t *iodesc)
Definition: pio_rearrange.c:148
int define_iodesc_datatypes(const iosystem_desc_t ios, io_desc_t *iodesc)
Definition: pio_rearrange.c:278
void compute_buffer_init(iosystem_desc_t ios)
Initialize the compute buffer to size PIO_CNBUFFER_LIMIT.
Definition: pio_darray.c:56
int rearrange_comp2io(const iosystem_desc_t ios, io_desc_t *iodesc, void *sbuf, void *rbuf, const int nvars)
Definition: pio_rearrange.c:597
Used to sort map points in the subset rearranger.
Definition: pio_internal.h:60
struct mapsort mapsort
Used to sort map points in the subset rearranger.
int subset_rearrange_create(const iosystem_desc_t ios, const int maplen, PIO_Offset compmap[], const int gsize[], const int ndim, io_desc_t *iodesc)
Definition: pio_rearrange.c:1222
int ceil2(const int i)
Returns the smallest power of 2 greater than i.
Definition: pio_spmd.c:219
void flush_buffer(int ncid, wmulti_buffer *wmb, bool flushtodisk)
Flush the buffer.
Definition: pio_darray.c:2119
void cn_buffer_report(iosystem_desc_t ios, bool collective)
Print out info about the buffer for debug purposes.
Definition: pio_darray.c:2044
int check_mpi(file_desc_t *file, const int mpierr, const char *filename, const int line)
Handle MPI errors.
Definition: pioc_support.c:274
int rearrange_io2comp(const iosystem_desc_t ios, io_desc_t *iodesc, void *sbuf, void *rbuf)
Definition: pio_rearrange.c:762
int pair(const int np, const int p, const int k)
Given integers p and k between 0 and np-1, if (p+1)^k <= np-1 then return (p+1)^k else -1...
Definition: pio_spmd.c:231
multi buffer.
Definition: pio.h:237
int box_rearrange_create(const iosystem_desc_t ios, const int maplen, const PIO_Offset compmap[], const int gsize[], const int ndim, io_desc_t *iodesc)
Definition: pio_rearrange.c:966
void free_cn_buffer_pool(iosystem_desc_t ios)
Free the buffer pool.
Definition: pio_darray.c:2097
int flush_output_buffer(file_desc_t *file, bool force, PIO_Offset addsize)
Flush the output buffer.
Definition: pio_darray.c:1912
IO region structure.
Definition: pio.h:76
IO descriptor structure.
Definition: pio.h:90
Public headers for the PIO C interface.
void pio_add_to_file_list(file_desc_t *file)
Add a new entry to the global list of open files.
Definition: pio_lists.c:17