SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
Macros | Functions
sion_common.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include <sys/time.h>
#include "sion.h"
#include "sion_debug.h"
#include "sion_error_handler.h"
#include "sion_filedesc.h"
#include "sion_tools.h"
#include "sion_fd.h"
#include "sion_file.h"
#include "sion_metadata.h"
#include "sion_internal.h"
#include "sion_internal_seek.h"
#include "sion_hints.h"
#include "sion_printts.h"
#include "sion_buffer.h"
#include "sion_dup.h"
#include "sion_lock.h"
#include "sion_buddy_common.h"
Include dependency graph for sion_common.c:

Go to the source code of this file.

Macros

#define _XOPEN_SOURCE   700
 
#define DFUNCTION   "sion_dup"
 
#define DFUNCTION   "sion_dedup"
 
#define DFUNCTION   "sion_lock_register_lock_callbacks"
 
#define DFUNCTION   "sion_lock_user_callbacks_defined"
 

Functions

sion_io_stat_tsion_get_io_info_buddy (int sid, int roles, int flag)
 
int sion_get_locations (int sid, int *ntasks, int *maxchunks, 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_close_sid (int sid)
 
int sion_get_current_location (int sid, int *currentchunknr, sion_int64 *currentpos, int *maxchunks, sion_int64 **chunksizes)
 Returns current position in file and pointer fiels containing chunk sizes. 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_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...
 
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)
 
sion_int64 sion_get_bytes_written (int sid)
 
sion_int64 sion_get_bytes_read (int sid)
 
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 *p)
 
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...
 
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_feof (int sid)
 Function that indicates whether the end of file is reached for this task. More...
 
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_set_fp_closed (int sid)
 
int sion_set_second_fp (int sid, FILE *secondfd)
 
int sion_unset_second_fp (int sid)
 
int sion_optimize_fp_buffer (int sid)
 
int sion_flush (int sid)
 Flushed sion file. More...
 
int sion_ensure_free_space (int sid, sion_int64 bytes)
 Funtion to ensure that enough space is available for writing. More...
 
int sion_is_thread_safe ()
 
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_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 ()
 Function which return flag, if user callback for locking are registered. More...
 

Detailed Description

Common SIONlib functions

Definition in file sion_common.c.

Function Documentation

◆ 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
Examples
simple/sionpar.c, and simple/sionser.c.

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
Examples
simple/sionpar.c.

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_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_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().