SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
Data Structures | Macros | Typedefs | Functions
sion_common.h File Reference
#include <stdio.h>
#include <stdint.h>
#include "sion_const.h"
#include "sion_datatypes.h"
Include dependency graph for sion_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _sion_key_stat_struct
 
struct  _sion_io_stat_struct
 

Macros

#define SION_SERIAL_MASTER
 
#define SION_MAX_FSBLOCKSIZE   32*1024*1024
 
#define SION_DEFAULT_FSBLOCKSIZE   2*1024*1024
 
#define SION_FILENAME_LENGTH   1024
 
#define MAXCHUNKS   100
 
#define WFLARGEMETABLOCK_none   /* for BENCHMARKING only */
 
#define _sion_stat_file   _sion_file_stat_file
 
#define DPRINTF(A)
 
#define DPRINTFP(A)
 
#define DPRINTTS(A, B)
 
#define DPRINTFTS2(A, B)
 

Typedefs

typedef struct _sion_key_stat_struct sion_key_stat_t
 
typedef struct _sion_io_stat_struct sion_io_stat_t
 

Functions

int _sion_close_sid (int sid)
 
size_t sion_fwrite (const void *data, size_t size, size_t nitems, int sid)
 Write data to sion file. More...
 
size_t sion_fread (void *data, size_t size, size_t nitems, int sid)
 Read data from sion file. More...
 
size_t sion_fwrite_key (const void *data, uint64_t key, size_t size, size_t nitems, int sid)
 Writes data for key. More...
 
size_t sion_fread_key (void *data, uint64_t key, size_t size, size_t nitems, int sid)
 Read data for key. More...
 
int sion_fread_key_iterator_reset (int sid)
 Resets key iterator. More...
 
int sion_fread_key_iterator_next (int sid, uint64_t *key, size_t *size)
 Forward to next key. More...
 
int sion_seek_key (int sid, uint64_t key, int entrynum, sion_int64 posinentry)
 Seek to position in key. More...
 
int sion_key_full_scan (int sid)
 Performs a full scan of all meta data in current file. More...
 
int sion_key_list_iterator_reset (int sid)
 Resets key iterator. More...
 
int sion_key_list_iterator_next (int sid, uint64_t *keyptr)
 Forward to next key. More...
 
int sion_key_get_stat (int sid, uint64_t key, sion_key_stat_t *stat)
 get statistics about key More...
 
int sion_feof (int sid)
 Function that indicates whether the end of file is reached for this task. More...
 
int sion_ensure_free_space (int sid, sion_int64 bytes)
 Funtion to ensure that enough space is available for writing. More...
 
int sion_flush (int sid)
 Flushed sion file. More...
 
int sion_get_sizeof (int sid, int *numbytes, int *numfds)
 Function returns size of internal data structure for sid. More...
 
int sion_dup (int sid, int mode, int rank, uint64_t key)
 Function which duplicates a sion file descriptor. More...
 
int sion_dedup (int sid)
 Function which destroy a duplicated sion file descriptor. More...
 
int sion_set_fp_closed (int sid)
 
int sion_set_second_fp (int sid, FILE *fp)
 
int sion_unset_second_fp (int sid)
 
FILE * sion_get_fp (int sid)
 
int sion_get_fd (int sid)
 
int sion_optimize_fp_buffer (int sid)
 
int sion_get_file_endianness (int sid)
 Returns edianness of data in file sid. More...
 
int sion_endianness_swap_needed (int sid)
 Returns whether or not byte swapping is needed for sid. More...
 
sion_int64 sion_get_bytes_written (int sid)
 
sion_int64 sion_get_bytes_read (int sid)
 
sion_int64 sion_bytes_avail_in_block (int sid)
 Return the number of bytes available in the current chunk. More...
 
sion_int64 sion_bytes_avail_in_chunk (int sid)
 Function that returns the number of bytes available in the current chunk. More...
 
sion_int64 sion_get_position (int sid)
 Function that returns the current file position. More...
 
int sion_get_mapping (int sid, int *mapping_size, sion_int32 **mapping, int *numfiles)
 Returns pointers to the internal field mapping. More...
 
int sion_get_locations (int sid, int *ntasks, int *maxblocks, sion_int64 *globalskip, sion_int64 *start_of_varheader, sion_int64 **sion_chunksizes, sion_int64 **sion_globalranks, sion_int64 **sion_blockcount, sion_int64 **sion_blocksizes)
 Returns pointers to internal fields. More...
 
int sion_get_current_location (int sid, int *currentblock, sion_int64 *currentpos, int *maxchunks, sion_int64 **chunksizes)
 Returns current position in file and pointer fiels containing chunk sizes. More...
 
int sion_get_current_locations (int sid, int *ntasks, sion_int64 **sion_currentpos, sion_int64 **sion_currentblocknr)
 Returns current position in file and pointer fiels containing chunk sizes. More...
 
int sion_get_number_of_files (int sid)
 
int sion_get_filenumber (int sid)
 
int sion_is_serial_opened (int sid)
 
int sion_using_hints (int sid)
 
int sion_get_endianness (void)
 Return endianness. More...
 
int sion_is_thread_safe (void)
 
int sion_get_keyval_mode (int sid)
 Return selected mode for key value. More...
 
char * sion_keyval_type_to_str (int type)
 Returns key value mode as string. More...
 
int sion_get_version (int *main_version, int *sub_version, int *patch_level, int *fileformat_version)
 Return version numbers. More...
 
sion_io_stat_tsion_get_io_info (int sid)
 
sion_io_stat_tsion_get_io_info_by_spec (int sid, int roles, int flag)
 
int sion_free_io_info (sion_io_stat_t *info)
 
int sion_seek (int sid, int rank, int currentblocknr, sion_int64 posinblk)
 Function to set the file pointer to a new position. More...
 
int sion_seek_fp (int sid, int rank, int currentblocknr, sion_int64 posinblk, FILE **fileptr)
 Deprecated. Use sion_seek() instead. More...
 
int sion_lock_register_lock_callbacks (int lock(void *), int unlock(void *), void *lock_data)
 Function which registers callback funtions for lock and unlock internal access to shared data structures. More...
 
int sion_lock_user_callbacks_defined (void)
 Function which return flag, if user callback for locking are registered. More...
 
void sion_swap (void *target, void *source, int size, int n, int do_swap)
 
int _sion_file_stat_file (const char *fname)
 Check if file exists (LARGE_FILE support on BlueGene) More...
 

Detailed Description

Common SIONlib functions

Definition in file sion_common.h.

Macro Definition Documentation

◆ MAXCHUNKS

#define MAXCHUNKS   100

Initial maximum number of chunks in a sion file

Definition at line 35 of file sion_common.h.

Function Documentation

◆ _sion_file_stat_file()

int _sion_file_stat_file ( const char *  fname)

Check if file exists (LARGE_FILE support on BlueGene)

Parameters
*fnamefilename to use
Returns
0 or 1

Definition at line 318 of file sion_file.c.

References _sion_file_stat_file2(), and SION_FILE_FLAG_POSIX.

◆ sion_bytes_avail_in_block()

sion_int64 sion_bytes_avail_in_block ( int  sid)

Return the number of bytes available in the current chunk.

See sion_bytes_avail_in_block_description.

Parameters
[in]sidsion file handle
Returns
rc>0 number of bytes rc<=0 file position is after end of block

Definition at line 879 of file sion_common.c.

References sion_bytes_avail_in_chunk().

Referenced by fsion_bytes_avail_in_block_c().

◆ sion_bytes_avail_in_chunk()

sion_int64 sion_bytes_avail_in_chunk ( int  sid)

Function that returns the number of bytes available in the current chunk.

This function returns the number of bytes remaining in the current chunk (bytes not read). It is a local function, which can be called independently from other MPI tasks.

Parameters
[in]sidsion file handle
Returns
rc>0 number of bytes rc<=0 file position is after end of block

Definition at line 894 of file sion_common.c.

Referenced by sion_bytes_avail_in_block().

◆ sion_dedup()

int sion_dedup ( int  sid)

Function which destroy a duplicated sion file descriptor.

Parameters
[in]sidsion file handle
Returns
SION_SUCCESS okay

Definition at line 1195 of file sion_common.c.

◆ sion_dup()

int sion_dup ( int  sid,
int  mode,
int  rank,
uint64_t  key 
)

Function which duplicates a sion file descriptor.

Restrictions:

  • only in read mode
  • only in parallel mode
  • collective operation are not callable on the new sid
Parameters
[in]sidsion file handle
[in]modeone of SION_DUP_ALL, SION_DUP_RANK, SION_DUP_RANK_KEY
[in]rankdup only those part of the internal data struture which are needed to read rank rank from file
[in]keydup only those part of the internal data struture which are needed to read on the rank rank data for key key from file
Returns
new sid if ok, SION_ID_NOT_VALID in other cases

Definition at line 1161 of file sion_common.c.

◆ sion_ensure_free_space()

int sion_ensure_free_space ( int  sid,
sion_int64  bytes 
)

Funtion to ensure that enough space is available for writing.

See sion_ensure_free_space_description

Parameters
[in]sidsion file handle
[in]bytesnumber of bytes requested for the next write operation
Returns
SION_SUCCESS if ok

Definition at line 1053 of file sion_common.c.

Referenced by fsion_ensure_free_space_c().

◆ sion_feof()

int sion_feof ( int  sid)

Function that indicates whether the end of file is reached for this task.

See sion_feof_description.

Parameters
[in]sidsion file handle (in)
Returns
SION_SUCCESS (1) if end of last chunk reached SION_NOT_SUCCESS (0) otherwise

Definition at line 809 of file sion_common.c.

Referenced by fsion_feof_c().

◆ sion_flush()

int sion_flush ( int  sid)

Flushed sion file.

Parameters
[in]sidsion file handle
Returns
SION_SUCCESS if ok

Definition at line 1030 of file sion_common.c.

Referenced by fsion_flush_c().

◆ sion_get_endianness()

int sion_get_endianness ( void  )

Return endianness.

Returns
1-> big endian 0 ->little endian

Definition at line 32 of file sion_tools.c.

Referenced by fsion_get_endianness_c().

◆ sion_get_position()

sion_int64 sion_get_position ( int  sid)

Function that returns the current file position.

This function returns an sion_int64 containing the current file possition.

Parameters
[in]sidsion file handle (in)
Returns
current file position

Definition at line 930 of file sion_common.c.

References _sion_vcdtovcon(), _sion_vcdtype(), and SION_FILEDESCRIPTOR.

Referenced by fsion_get_position_c().

◆ sion_get_sizeof()

int sion_get_sizeof ( int  sid,
int *  numbytes,
int *  numfds 
)

Function returns size of internal data structure for sid.

Parameters
[in]sidsion file handle
[out]numbytesnumber of bytes used
[out]numfdsnumber of file descriptors used
Returns
SION_SUCCESS if ok

Definition at line 1123 of file sion_common.c.

◆ sion_get_version()

int sion_get_version ( int *  main_version,
int *  sub_version,
int *  patch_level,
int *  fileformat_version 
)

Return version numbers.

return version numbers

Definition at line 51 of file sion_tools.c.

◆ sion_lock_register_lock_callbacks()

int sion_lock_register_lock_callbacks ( int   lockvoid *,
int   unlockvoid *,
void *  lock_data 
)

Function which registers callback funtions for lock and unlock internal access to shared data structures.

Parameters
[in]lock()lock function
[in]unlock()unlock function
[in]lock_data()unlock function
Returns
SION_SUCCESS okay

Definition at line 1220 of file sion_common.c.

◆ sion_lock_user_callbacks_defined()

int sion_lock_user_callbacks_defined ( void  )

Function which return flag, if user callback for locking are registered.

Returns
SION_SUCCESS (yes) of SION_NOT_SUCCESS (no)

Definition at line 1239 of file sion_common.c.

◆ sion_seek()

int sion_seek ( int  sid,
int  rank,
int  currentblocknr,
sion_int64  posinblk 
)

Function to set the file pointer to a new position.

See sion_seek_description .

Parameters
[in]sidsion file handle
[in]rankrank number of the process (SION_CURRENT_RANK to select the current rank)
[in]currentblocknrblock number (SION_CURRENT_BLK to select the current block) (SION_ABSOLUTE_POS gives an absolute position; SION_END_POS seeks relative to the end of the file)
[in]posinblkposition in the block (SION_CURRENT_POS to select the current position)
Return values
SION_SUCCESSif file pointer can be moved to new position

Definition at line 698 of file sion_common.c.

References sion_seek_fp().

◆ sion_seek_fp()

int sion_seek_fp ( int  sid,
int  rank,
int  currentblocknr,
sion_int64  posinblk,
FILE **  fileptr 
)

Deprecated. Use sion_seek() instead.

See sion_seek_fp_description .

Parameters
[in]sidsion file handle
[in]rankrank number of the process (SION_CURRENT_RANK to select the current rank)
[in]currentblocknrblock number (SION_CURRENT_BLK to select the current block)
[in]posinblkposition in the block (SION_CURRENT_POS to select the current position)
[out]**fileptrfile pointer to corresponding file of a multi-file set
Return values
SION_SUCCESSif file pointer can be moved to new position

Definition at line 721 of file sion_common.c.

Referenced by sion_seek().

◆ sion_swap()

void sion_swap ( void *  target,
void *  source,
int  size,
int  n,
int  do_swap 
)

@ brief Perform byte-order swapping for arrays

n elements of size bytes each are swapped if do_swap is true. In-place swapping (target == source) is allowed. If target != source, the buffers must not overlap.

Parameters
[out]targetthe byte-swapped data is written starting at this address
[in]sourcethe data to be byte-swapped is read starting at this address
[in]sizethe size (in bytes) of a single element
[in]nthe number of elements to be byte-swapped
[in]do_swapbyte-swapping is only performed if this argument is true

Definition at line 44 of file sion_convert.c.

Referenced by fsion_swap_c().