[ Top ] [ package ]
DESCRIPTION
set of routines to implement named block management in a memory pool possibly shared by multiple threads and processes master arena layout (there must be one and only one) +--------------------+--------------------+---------------------+--------------------> | master tables | arena header | symbol table | data blocks +--------------------+--------------------+---------------------+--------------------> memory arena layout (multiple arenas can coexist) +--------------------+---------------------+--------------------> | arena header | symbol table | data blocks +--------------------+---------------------+--------------------> indices are used instead of addresses because the memory arena might be mapped at different addresses in different processes data block layout +----------------------------------------------------------------- + | | | v +-------+-------+-------+-------+.....................+-------+-------+ | FWD | IX | NWD | SIGNL | user data portion | SIGNH | BWD | +-------+-------+-------+-------+.....................+-------+-------+ ^ | | | +-----------------------------------------------------------------+ FWD : index of start of next block IX : index in symbol table of this block NWD : size of data portion in 64 bit units SIGNL : low marker (used for checking data underruns) SIGNH : high marker (used for checking data overruns) BWD : index of start of this block FWD of last allocated block will point to a non existent block with FWD = 0 FWD and BWD are indices into a 64 bit unsigned integer array starting at the beginning of the memory arena FWD, IX, NWD, SIGNL, SIGNH, BWD are 32 bit unsigned integers
EXAMPLES
[ Top ] [ Functions ]
Synopsis
get memory address associated with shared memory segment shmid function memory_address_from_id(shmid) result(ptr) BIND(C,name='memory_address_from_id') !InTf import :: C_PTR, C_INT !InTf integer, intent(IN), value :: shmid !InTf type(C_PTR) :: ptr !InTf end function memory_address_from_id !InTf schmid : shared memory segment id (from memory_arena_create_shared, memory_allocate_shared, master_arena_create_shared) ptr : local memory addres of said segment
ARGUMENTS
void *memory_address_from_id(int shmid){
[ Top ] [ Functions ]
Synopsis
allocate a shared memory segment (on his process) function memory_allocate_shared(shmid, size) result(ptr) BIND(C,name='memory_allocate_shared') !InTf import :: C_PTR, C_INT !InTf integer, intent(OUT) :: shmid !InTf integer, intent(IN), value :: size !InTf type(C_PTR) :: ptr !InTf end function memory_allocate_shared !InTf shmid : shared memory id of block (set by memory_allocate_shared) (see shmget) size : size of block in 32 bit units return local address of memory block
ARGUMENTS
void *memory_allocate_shared(int *shmid, uint32_t size){
[ Top ] [ Functions ]
Synopsis
initialize an already allocated 'memory arena' (node shared memory usually), return id of current process function memory_arena_init(mem, nsym, size) result(me) BIND(C,name='memory_arena_init') !InTf import :: C_PTR, C_INT !InTf type(C_PTR), intent(IN), value :: mem !InTf integer(C_INT), intent(IN), value :: nsym, size !InTf integer(C_INT) :: me !InTf end function memory_arena_init !InTf mem : pointer to memory area (see memory_arena_init) size : size of memory area in 32 bit units nsym : size of symbol table to allocate (max number of blocks expected)
ARGUMENTS
uint32_t memory_arena_init(void *mem, uint32_t nsym, uint32_t size){
[ Top ] [ Functions ]
Synopsis
dump arena header and symbol table subroutine memory_arena_print_status(mem) BIND(C,name='memory_arena_print_status') !InTf import :: C_PTR !InTf type(C_PTR), intent(IN), value :: mem !InTf end subroutine memory_arena_print_status !InTf mem : pointer to previously created and initialized memory arena see memory_arena_init
ARGUMENTS
void memory_arena_print_status(void *mem){
[ Top ] [ Functions ]
Synopsis
set owner's id (usually MPI rank) for memory arenas function memory_arena_set_id(id) result(me) BIND(C,name='memory_arena_set_id') !InTf import :: C_INT !InTf integer(C_INT), intent(IN), value :: id !InTf integer(C_INT) :: me !InTf end function memory_arena_set_id !InTf set id for memory management arena, return identifier (-1 in case of error) id must be a POSITIVE INTEGER
ARGUMENTS
int32_t memory_arena_set_id(uint32_t id){
[ Top ] [ Functions ]
Synopsis
create a named block in a managed 'memory arena' return start address of data (NULL in case of error) function memory_block_create(mem, size, name) result(ptr) BIND(C,name='memory_block_create') !InTf import :: C_PTR, C_INT, C_CHAR !InTf type(C_PTR), intent(IN), value :: mem !InTf integer(C_INT), intent(IN), value :: size !InTf character(C_CHAR), dimension(*), intent(IN) :: name !InTf type(C_PTR) :: ptr !InTf end function memory_block_create !InTf mem : address of the managed 'memory arena' size : desired size of block in 32 bit units name : name of block to create (characters beyond the 8th will be ignored) ptr : local address of created block
ARGUMENTS
void *memory_block_create(void *mem, uint32_t size, unsigned char *name){
[ Top ] [ Functions ]
Synopsis
find memory block 'name', return data address (NULL if not found), size of block (0 if not found), block flags (0 if not found), function memory_block_find(mem, size, flags, name) result(ptr) BIND(C,name='memory_block_find') !InTf import :: C_PTR, C_INT, C_CHAR !InTf type(C_PTR), intent(IN), value :: mem !InTf integer(C_INT), intent(OUT) :: size, flags !InTf character(C_CHAR), dimension(*), intent(IN) :: name !InTf type(C_PTR) :: ptr !InTf end function memory_block_find !InTf mem : address of the managed 'memory arena' size : size of the memory block (in 32 bit units) flags : blosk flags name : name of block to find (characters beyond the 8th will be ignored) ptr : local address of block
ARGUMENTS
void *memory_block_find(void *mem, uint32_t *size, uint32_t *flags, unsigned char *name){
[ Top ] [ Functions ]
Synopsis
same as memory_block_find, but wait until block is created (or timeout in milliseconds expires) (timeout(milliseconds) = -1 means infinite wait for all practical purposes, 3600000 is one hour) function memory_block_find_wait(mem, size, flags, name, timeout) result(ptr) BIND(C,name='memory_block_find_wait') !InTf import :: C_PTR, C_INT, C_CHAR !InTf type(C_PTR), intent(IN), value :: mem !InTf integer(C_INT), intent(OUT) :: size, flags !InTf character(C_CHAR), dimension(*), intent(IN) :: name !InTf integer(C_INT), intent(IN), value :: timeout !InTf type(C_PTR) :: ptr !InTf end function memory_block_find_wait !InTf mem : address of the managed 'memory arena' size : size of the memory block (in 32 bit units) flags : blosk flags name : name of block to find (characters beyond the 8th will be ignored) timeout : time to wait for block creation in milliseconds (-1 means forever) ptr : local address of block
ARGUMENTS
void *memory_block_find_wait(void *mem, uint32_t *size, uint32_t *flags, char *name, int timeout){
[ Top ] [ Functions ]
Synopsis
mark memory block 'name' as initialized, return block address if found, NULL otherwise function memory_block_mark_init(mem, name) result(ptr) BIND(C,name='memory_block_mark_init') !InTf import :: C_PTR, C_CHAR !InTf type(C_PTR), intent(IN), value :: mem !InTf character(C_CHAR), dimension(*), intent(IN) :: name !InTf type(C_PTR) :: ptr !InTf end function memory_block_mark_init !InTf mem : address of the managed 'memory arena' name : name of block to mark (characters beyond the 8th will be ignored) ptr : local address of block
ARGUMENTS
void *memory_block_mark_init(void *mem, unsigned char *name){