ParallelIO
Classes | Macros | Typedefs | Enumerations | Functions | Variables
pio_internal.h File Reference

Private headers and defines for the PIO C interface. More...

#include <pio.h>
#include <bget.h>
#include <limits.h>
#include <math.h>

Go to the source code of this file.

Classes

struct  mapsort
 Used to sort map points in the subset rearranger. More...
 
struct  pio_swapm_defaults
 swapm defaults. More...
 

Macros

#define MPI_Offset   long long
 
#define LOG(e)
 
#define max(a, b)
 
#define min(a, b)
 
#define MAX_GATHER_BLOCK_SIZE   0
 
#define PIO_REQUEST_ALLOC_CHUNK   16
 

Typedefs

typedef struct mapsort mapsort
 Used to sort map points in the subset rearranger. More...
 
typedef struct pio_swapm_defaults pio_swapm_defaults
 swapm defaults. More...
 

Enumerations

enum  PIO_MSG {
  PIO_MSG_OPEN_FILE, PIO_MSG_CREATE_FILE, PIO_MSG_INQ_ATT, PIO_MSG_INQ_FORMAT,
  PIO_MSG_INQ_VARID, PIO_MSG_DEF_VAR, PIO_MSG_INQ_VAR, PIO_MSG_PUT_ATT_DOUBLE,
  PIO_MSG_PUT_ATT_INT, PIO_MSG_RENAME_ATT, PIO_MSG_DEL_ATT, PIO_MSG_INQ,
  PIO_MSG_GET_ATT_TEXT, PIO_MSG_GET_ATT_SHORT, PIO_MSG_PUT_ATT_LONG, PIO_MSG_REDEF,
  PIO_MSG_SET_FILL, PIO_MSG_ENDDEF, PIO_MSG_RENAME_VAR, PIO_MSG_PUT_ATT_SHORT,
  PIO_MSG_PUT_ATT_TEXT, PIO_MSG_INQ_ATTNAME, PIO_MSG_GET_ATT_ULONGLONG, PIO_MSG_GET_ATT_USHORT,
  PIO_MSG_PUT_ATT_ULONGLONG, PIO_MSG_GET_ATT_UINT, PIO_MSG_GET_ATT_LONGLONG, PIO_MSG_PUT_ATT_SCHAR,
  PIO_MSG_PUT_ATT_FLOAT, PIO_MSG_RENAME_DIM, PIO_MSG_GET_ATT_LONG, PIO_MSG_INQ_DIM,
  PIO_MSG_INQ_DIMID, PIO_MSG_PUT_ATT_USHORT, PIO_MSG_GET_ATT_FLOAT, PIO_MSG_SYNC,
  PIO_MSG_PUT_ATT_LONGLONG, PIO_MSG_PUT_ATT_UINT, PIO_MSG_GET_ATT_SCHAR, PIO_MSG_INQ_ATTID,
  PIO_MSG_DEF_DIM, PIO_MSG_GET_ATT_INT, PIO_MSG_GET_ATT_DOUBLE, PIO_MSG_PUT_ATT_UCHAR,
  PIO_MSG_GET_ATT_UCHAR, PIO_MSG_PUT_VARS_UCHAR, PIO_MSG_GET_VAR1_SCHAR, PIO_MSG_GET_VARS_ULONGLONG,
  PIO_MSG_GET_VARM_UCHAR, PIO_MSG_GET_VARM_SCHAR, PIO_MSG_GET_VARS_SHORT, PIO_MSG_GET_VAR_DOUBLE,
  PIO_MSG_GET_VARA_DOUBLE, PIO_MSG_GET_VAR_INT, PIO_MSG_GET_VAR_USHORT, PIO_MSG_PUT_VARS_USHORT,
  PIO_MSG_GET_VARA_TEXT, PIO_MSG_PUT_VARS_ULONGLONG, PIO_MSG_GET_VARA_INT, PIO_MSG_PUT_VARM,
  PIO_MSG_GET_VAR1_FLOAT, PIO_MSG_GET_VAR1_SHORT, PIO_MSG_GET_VARS_INT, PIO_MSG_PUT_VARS_UINT,
  PIO_MSG_GET_VAR_TEXT, PIO_MSG_GET_VARM_DOUBLE, PIO_MSG_PUT_VARM_UCHAR, PIO_MSG_PUT_VAR_USHORT,
  PIO_MSG_GET_VARS_SCHAR, PIO_MSG_GET_VARA_USHORT, PIO_MSG_PUT_VAR1_LONGLONG, PIO_MSG_PUT_VARA_UCHAR,
  PIO_MSG_PUT_VARM_SHORT, PIO_MSG_PUT_VAR1_LONG, PIO_MSG_PUT_VARS_LONG, PIO_MSG_GET_VAR1_USHORT,
  PIO_MSG_PUT_VAR_SHORT, PIO_MSG_PUT_VARA_INT, PIO_MSG_GET_VAR_FLOAT, PIO_MSG_PUT_VAR1_USHORT,
  PIO_MSG_PUT_VARA_TEXT, PIO_MSG_PUT_VARM_TEXT, PIO_MSG_GET_VARS_UCHAR, PIO_MSG_GET_VAR,
  PIO_MSG_PUT_VARM_USHORT, PIO_MSG_GET_VAR1_LONGLONG, PIO_MSG_GET_VARS_USHORT, PIO_MSG_GET_VAR_LONG,
  PIO_MSG_GET_VAR1_DOUBLE, PIO_MSG_PUT_VAR_ULONGLONG, PIO_MSG_PUT_VAR_INT, PIO_MSG_GET_VARA_UINT,
  PIO_MSG_PUT_VAR_LONGLONG, PIO_MSG_GET_VARS_LONGLONG, PIO_MSG_PUT_VAR_SCHAR, PIO_MSG_PUT_VAR_UINT,
  PIO_MSG_PUT_VAR, PIO_MSG_PUT_VARA_USHORT, PIO_MSG_GET_VAR_LONGLONG, PIO_MSG_GET_VARA_SHORT,
  PIO_MSG_PUT_VARS_SHORT, PIO_MSG_PUT_VARA_UINT, PIO_MSG_PUT_VARA_SCHAR, PIO_MSG_PUT_VARM_ULONGLONG,
  PIO_MSG_PUT_VAR1_UCHAR, PIO_MSG_PUT_VARM_INT, PIO_MSG_PUT_VARS_SCHAR, PIO_MSG_GET_VARA_LONG,
  PIO_MSG_PUT_VAR1, PIO_MSG_GET_VAR1_INT, PIO_MSG_GET_VAR1_ULONGLONG, PIO_MSG_GET_VAR_UCHAR,
  PIO_MSG_PUT_VARA_FLOAT, PIO_MSG_GET_VARA_UCHAR, PIO_MSG_GET_VARS_FLOAT, PIO_MSG_PUT_VAR1_FLOAT,
  PIO_MSG_PUT_VARM_FLOAT, PIO_MSG_PUT_VAR1_TEXT, PIO_MSG_PUT_VARS_TEXT, PIO_MSG_PUT_VARM_LONG,
  PIO_MSG_GET_VARS_LONG, PIO_MSG_PUT_VARS_DOUBLE, PIO_MSG_GET_VAR1, PIO_MSG_GET_VAR_UINT,
  PIO_MSG_PUT_VARA_LONGLONG, PIO_MSG_GET_VARA, PIO_MSG_PUT_VAR_DOUBLE, PIO_MSG_GET_VARA_SCHAR,
  PIO_MSG_PUT_VAR_FLOAT, PIO_MSG_GET_VAR1_UINT, PIO_MSG_GET_VARS_UINT, PIO_MSG_PUT_VAR1_ULONGLONG,
  PIO_MSG_PUT_VARM_UINT, PIO_MSG_PUT_VAR1_UINT, PIO_MSG_PUT_VAR1_INT, PIO_MSG_GET_VARA_FLOAT,
  PIO_MSG_GET_VARM_TEXT, PIO_MSG_PUT_VARS_FLOAT, PIO_MSG_GET_VAR1_TEXT, PIO_MSG_PUT_VARA_SHORT,
  PIO_MSG_PUT_VAR1_SCHAR, PIO_MSG_PUT_VARA_ULONGLONG, PIO_MSG_PUT_VARM_DOUBLE, PIO_MSG_GET_VARM_INT,
  PIO_MSG_PUT_VARA, PIO_MSG_PUT_VARA_LONG, PIO_MSG_GET_VARM_UINT, PIO_MSG_GET_VARM,
  PIO_MSG_PUT_VAR1_DOUBLE, PIO_MSG_GET_VARS_DOUBLE, PIO_MSG_GET_VARA_LONGLONG, PIO_MSG_GET_VAR_ULONGLONG,
  PIO_MSG_PUT_VARM_SCHAR, PIO_MSG_GET_VARA_ULONGLONG, PIO_MSG_GET_VAR_SHORT, PIO_MSG_GET_VARM_FLOAT,
  PIO_MSG_PUT_VAR_TEXT, PIO_MSG_PUT_VARS_INT, PIO_MSG_GET_VAR1_LONG, PIO_MSG_GET_VARM_LONG,
  PIO_MSG_GET_VARM_USHORT, PIO_MSG_PUT_VAR1_SHORT, PIO_MSG_PUT_VARS_LONGLONG, PIO_MSG_GET_VARM_LONGLONG,
  PIO_MSG_GET_VARS_TEXT, PIO_MSG_PUT_VARA_DOUBLE, PIO_MSG_PUT_VARS, PIO_MSG_PUT_VAR_UCHAR,
  PIO_MSG_GET_VAR1_UCHAR, PIO_MSG_PUT_VAR_LONG, PIO_MSG_GET_VARS, PIO_MSG_GET_VARM_SHORT,
  PIO_MSG_GET_VARM_ULONGLONG, PIO_MSG_PUT_VARM_LONGLONG, PIO_MSG_GET_VAR_SCHAR, PIO_MSG_GET_ATT_UBYTE,
  PIO_MSG_PUT_ATT_STRING, PIO_MSG_GET_ATT_STRING, PIO_MSG_PUT_ATT_UBYTE, PIO_MSG_INQ_VAR_FILL,
  PIO_MSG_DEF_VAR_FILL, PIO_MSG_DEF_VAR_DEFLATE, PIO_MSG_INQ_VAR_DEFLATE, PIO_MSG_INQ_VAR_SZIP,
  PIO_MSG_DEF_VAR_FLETCHER32, PIO_MSG_INQ_VAR_FLETCHER32, PIO_MSG_DEF_VAR_CHUNKING, PIO_MSG_INQ_VAR_CHUNKING,
  PIO_MSG_DEF_VAR_ENDIAN, PIO_MSG_INQ_VAR_ENDIAN, PIO_MSG_SET_CHUNK_CACHE, PIO_MSG_GET_CHUNK_CACHE,
  PIO_MSG_SET_VAR_CHUNK_CACHE, PIO_MSG_GET_VAR_CHUNK_CACHE, PIO_MSG_INITDECOMP_DOF, PIO_MSG_WRITEDARRAY,
  PIO_MSG_READDARRAY, PIO_MSG_SETERRORHANDLING, PIO_MSG_FREEDECOMP, PIO_MSG_CLOSE_FILE,
  PIO_MSG_DELETE_FILE, PIO_MSG_EXIT, PIO_MSG_GET_ATT, PIO_MSG_PUT_ATT,
  PIO_MSG_INQ_TYPE
}
 These are the messages that can be sent over the intercomm when async is being used. More...
 

Functions

void pio_get_env (void)
 Get PIO environment variables. More...
 
int pio_add_to_iodesc_list (io_desc_t *iodesc)
 
io_desc_tpio_get_iodesc_from_id (int ioid)
 
int pio_delete_iodesc_from_list (int ioid)
 
file_desc_tpio_get_file_from_id (int ncid)
 
int pio_delete_file_from_list (int ncid)
 
void pio_add_to_file_list (file_desc_t *file)
 Add a new entry to the global list of open files. More...
 
void pio_push_request (file_desc_t *file, int request)
 
iosystem_desc_tpio_get_iosystem_from_id (int iosysid)
 
int pio_add_to_iosystem_list (iosystem_desc_t *ios)
 
int check_netcdf (file_desc_t *file, const int status, const char *fname, const int line)
 Check the result of a netCDF API call. More...
 
int iotype_error (const int iotype, const char *fname, const int line)
 
void piodie (const char *msg, const char *fname, const int line)
 
void pioassert (bool exp, const char *msg, const char *fname, const int line)
 
int CalcStartandCount (const int basetype, const int ndims, const int *gdims, const int num_io_procs, const int myiorank, PIO_Offset *start, PIO_Offset *kount)
 
void CheckMPIReturn (const int ierr, const char file[], const int line)
 Wrapper for MPI calls to print the Error string on error.
 
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.
 
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.
 
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.
 
long long lgcd_array (int nain, long long *ain)
 
void PIO_Offset_size (MPI_Datatype *dtype, int *tsize)
 
PIO_Offset GCDblocksize (const int arrlen, const PIO_Offset arr_in[])
 
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)
 
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)
 
int rearrange_io2comp (const iosystem_desc_t ios, io_desc_t *iodesc, void *sbuf, void *rbuf)
 
int rearrange_comp2io (const iosystem_desc_t ios, io_desc_t *iodesc, void *sbuf, void *rbuf, const int nvars)
 
int calcdisplace (const int bsize, const int numblocks, const PIO_Offset map[], int displace[])
 
io_desc_tmalloc_iodesc (const int piotype, const int ndims)
 
void performance_tune_rearranger (iosystem_desc_t ios, io_desc_t *iodesc)
 
int flush_output_buffer (file_desc_t *file, bool force, PIO_Offset addsize)
 Flush the output buffer. More...
 
void compute_maxIObuffersize (MPI_Comm io_comm, io_desc_t *iodesc)
 
io_regionalloc_region (const int ndims)
 
int pio_delete_iosystem_from_list (int piosysid)
 Delete iosystem info from list. More...
 
int gcd (int a, int b)
 
long long lgcd (long long a, long long b)
 
int gcd_array (int nain, int *ain)
 
void free_region_list (io_region *top)
 
void gindex_to_coord (const int ndims, const PIO_Offset gindex, const PIO_Offset gstride[], PIO_Offset *gcoord)
 
PIO_Offset coord_to_lindex (const int ndims, const PIO_Offset lcoord[], const PIO_Offset count[])
 
int ceil2 (const int i)
 Returns the smallest power of 2 greater than i.
 
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.
 
int define_iodesc_datatypes (const iosystem_desc_t ios, io_desc_t *iodesc)
 
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[])
 
int compare_offsets (const void *a, const void *b)
 
void print_trace (FILE *fp)
 
void cn_buffer_report (iosystem_desc_t ios, bool collective)
 Print out info about the buffer for debug purposes. More...
 
void compute_buffer_init (iosystem_desc_t ios)
 Initialize the compute buffer to size PIO_CNBUFFER_LIMIT. More...
 
void free_cn_buffer_pool (iosystem_desc_t ios)
 Free the buffer pool. More...
 
void flush_buffer (int ncid, wmulti_buffer *wmb, bool flushtodisk)
 Flush the buffer. More...
 
void piomemerror (iosystem_desc_t ios, size_t req, char *fname, const int line)
 
void compute_maxaggregate_bytes (const iosystem_desc_t ios, io_desc_t *iodesc)
 Compute the maximum aggregate number of bytes. More...
 
int check_mpi (file_desc_t *file, const int mpierr, const char *filename, const int line)
 Handle MPI errors. More...
 

Variables

PIO_Offset PIO_BUFFER_SIZE_LIMIT
 
bool PIO_Save_Decomps
 

Detailed Description

Private headers and defines for the PIO C interface.

Author
Jim Edwards
Date
2014
See also
http://code.google.com/p/parallelio/

Macro Definition Documentation

§ max

#define max (   a,
 
)
Value:
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })

§ min

#define min (   a,
 
)
Value:
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })

Typedef Documentation

§ mapsort

typedef struct mapsort mapsort

Used to sort map points in the subset rearranger.

§ pio_swapm_defaults

swapm defaults.

Enumeration Type Documentation

§ PIO_MSG

enum PIO_MSG

These are the messages that can be sent over the intercomm when async is being used.

Function Documentation

§ box_rearrange_create()

int box_rearrange_create ( const iosystem_desc_t  ios,
const int  maplen,
const PIO_Offset  compmap[],
const int  gsize[],
const int  ndims,
io_desc_t iodesc 
)

§ check_mpi()

int check_mpi ( file_desc_t file,
const int  mpierr,
const char *  filename,
const int  line 
)

Handle MPI errors.

An error message is sent to stderr, then the check_netcdf() function is called with PIO_EIO.

Parameters
filepointer to the file_desc_t info. May be NULL, in which case check_netcdf() is not called.
mpierrthe MPI return code to handle
filenamethe name of the code file where error occured.
linethe line of code where error occured.
Returns
PIO_NOERR for no error, otherwise PIO_EIO.

§ check_netcdf()

int check_netcdf ( file_desc_t file,
int  status,
const char *  fname,
const int  line 
)

Check the result of a netCDF API call.

Parameters
filepointer to the PIO structure describing this file.
statusthe return value from the netCDF call.
fnamethe name of the code file.
linethe line number of the netCDF call in the code.
Returns
the error code

§ cn_buffer_report()

void cn_buffer_report ( iosystem_desc_t  ios,
bool  collective 
)

Print out info about the buffer for debug purposes.

Parameters
iosthe IO system structure
collectivetrue if collective report is desired

§ compare_offsets()

int compare_offsets ( const void *  a,
const void *  b 
)

§ compute_buffer_init()

void compute_buffer_init ( iosystem_desc_t  ios)

Initialize the compute buffer to size PIO_CNBUFFER_LIMIT.

This routine initializes the compute buffer pool if the bget memory management is used. If malloc is used (that is, PIO_USE_MALLOC is non zero), this function does nothing.

Parameters
iosthe iosystem descriptor which will use the new buffer

§ compute_maxaggregate_bytes()

void compute_maxaggregate_bytes ( const iosystem_desc_t  ios,
io_desc_t iodesc 
)

Compute the maximum aggregate number of bytes.

Parameters
iosthe IO system structure
iodesca pointer to the defined iodescriptor for the buffer

§ compute_maxIObuffersize()

void compute_maxIObuffersize ( MPI_Comm  io_comm,
io_desc_t iodesc 
)

§ coord_to_lindex()

PIO_Offset coord_to_lindex ( const int  ndims,
const PIO_Offset  lcoord[],
const PIO_Offset  count[] 
)

§ create_mpi_datatypes()

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[] 
)

§ define_iodesc_datatypes()

int define_iodesc_datatypes ( const iosystem_desc_t  ios,
io_desc_t iodesc 
)

§ flush_buffer()

void flush_buffer ( int  ncid,
wmulti_buffer wmb,
bool  flushtodisk 
)

Flush the buffer.

Parameters
ncididentifies the netCDF file
wmb
flushtodisk

§ flush_output_buffer()

int flush_output_buffer ( file_desc_t file,
bool  force,
PIO_Offset  addsize 
)

Flush the output buffer.

This is only relevant for files opened with pnetcdf.

Parameters
filea pointer to the open file descriptor for the file that will be written to
forcetrue to force the flushing of the buffer
addsizeadditional size to add to buffer (in bytes)
Returns
0 for success, error code otherwise.

§ free_cn_buffer_pool()

void free_cn_buffer_pool ( iosystem_desc_t  ios)

Free the buffer pool.

If malloc is used (that is, PIO_USE_MALLOC is non zero), this function does nothing.

Parameters
iosthe IO system structure

§ pio_add_to_file_list()

void pio_add_to_file_list ( file_desc_t file)

Add a new entry to the global list of open files.

Parameters
filepointer to the file_desc_t struct for the new file.

§ pio_delete_iosystem_from_list()

int pio_delete_iosystem_from_list ( int  piosysid)

Delete iosystem info from list.

§ pio_get_env()

void pio_get_env ( void  )

Get PIO environment variables.

§ rearrange_comp2io()

int rearrange_comp2io ( const iosystem_desc_t  ios,
io_desc_t iodesc,
void *  sbuf,
void *  rbuf,
const int  nvars 
)

§ rearrange_io2comp()

int rearrange_io2comp ( const iosystem_desc_t  ios,
io_desc_t iodesc,
void *  sbuf,
void *  rbuf 
)

§ subset_rearrange_create()

int subset_rearrange_create ( const iosystem_desc_t  ios,
const int  maplen,
PIO_Offset  compmap[],
const int  gsize[],
const int  ndims,
io_desc_t iodesc 
)