epk_idmap.h File Reference

Identifier mapping data structure. More...


Typedefs

typedef struct EpkIdMap_struct EpkIdMap

Enumerations

enum  epk_idmap_mode_t { EPK_IDMAP_DENSE, EPK_IDMAP_SPARSE }

Functions

Functions
EpkIdMapepk_idmap_create (epk_idmap_mode_t mode, size_t capacity)
void epk_idmap_free (EpkIdMap *instance)
size_t epk_idmap_size (const EpkIdMap *instance)
epk_idmap_mode_t epk_idmap_mode (const EpkIdMap *instance)
void epk_idmap_clear (EpkIdMap *instance)
void epk_idmap_add (EpkIdMap *instance, elg_ui4 local_id, elg_ui4 global_id)
elg_ui4 epk_idmap_get (const EpkIdMap *instance, elg_ui4 local_id)
const elg_ui4 * epk_idmap_data (const EpkIdMap *instance, size_t *count)


Detailed Description

This file provides type definitions and function prototypes for an identifier mapping data structure which is used to store mapping tables for converting local into global identifiers.

This mapping data structure can operate in two different modes (see epk_idmap_mode_t): A dense mapping can be used if the local identifiers are consecutively enumerated from 0 to N-1. In this case, only the global identifier are stored in the table at the corresponding entry, leading to compact storage and fast look-up. By contrast, if the local identifiers can consist of arbitrary numbers, a sparse mapping is necessary. Here, (local_id, global_id) tuples are stored, which requires a more complicated look-up procedure.

Note:
This module uses the assert() macro to check various conditions (especially the values of given parameters) at runtime, which can cause a performance penalty.

Typedef Documentation

typedef struct EpkIdMap_struct EpkIdMap

Opaque data structure representing an ID mapping table.


Enumeration Type Documentation

Enumeration type defining the two differnt modes of an identifier mapping table.

Enumerator:
EPK_IDMAP_DENSE  Dense mapping table
EPK_IDMAP_SPARSE  Sparse mapping table


Function Documentation

void epk_idmap_add ( EpkIdMap instance,
elg_ui4  local_id,
elg_ui4  global_id 
)

Adds the given mapping from local_id to global_id to the mapping table instance. If the current capacity does not suffice, the data structure is automatically resized. If this memory reallocation request can not be fulfilled, an error message is printed and the program is aborted.

Note:
If the mapping table operates in dense mapping mode, the parameter local_id has to correspond to the next entry in the mapping table.
Parameters:
instance Object to add the mapping to
local_id Local identifier
global_id Global identifier

void epk_idmap_clear ( EpkIdMap instance  ) 

Removes all entries in the given mapping table instance. It can be used, e.g., to reuse an mapping table object for new input data.

Parameters:
instance Object to remove entries from

EpkIdMap* epk_idmap_create ( epk_idmap_mode_t  mode,
size_t  capacity 
)

Creates and returns a new instance of EpkIdMap with the given mode and initial capacity. If the memory allocation request can not be fulfilled, an error message is printed and the program is aborted.

Parameters:
mode Mapping mode
capacity Initial capacity
Returns:
Pointer to new instance

const elg_ui4* epk_idmap_data ( const EpkIdMap instance,
size_t *  count 
)

Returns an pointer to the raw data of the given mapping table instance. In addition, the total number of IDs is stored at the location pointed to by count. For a dense mapping, this number is equal to the number of entries, whereas for a sparse mapping it is twice as much, since each entry consists of an local and an global identifier (in this order).

void epk_idmap_free ( EpkIdMap instance  ) 

Destroys the given instance of EpkIdMap and releases the allocated memory.

Parameters:
instance Object to be freed

elg_ui4 epk_idmap_get ( const EpkIdMap instance,
elg_ui4  local_id 
)

Returns the global identifier for the given local_id stored in the mapping table instance. If no entry can be found, ELG_NO_ID is returned.

Parameters:
instance Queried object
local_id Local identifier
Returns:
Corresponding global identifier or ELG_NO_ID

epk_idmap_mode_t epk_idmap_mode ( const EpkIdMap instance  ) 

Returns the identifier mapping mode (dense/sparse) used for the given mapping table instance.

Parameters:
instance Queried object
Returns:
Identifier mapping mode

size_t epk_idmap_size ( const EpkIdMap instance  ) 

Returns the actual number of entries stored in the given mapping table instance.

Parameters:
instance Queried object
Returns:
Number of entries


SCALASCA    Copyright © 1998–2009 Forschungszentrum Jülich, Jülich Supercomputing Centre