Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value > Class Template Reference

Declaration of BlockMap. More...

#include <Cabana_Grid_SparseIndexSpace.hpp>

Public Types

using key_type = Key
 Tile hash key type.
 
using value_type = Value
 Tile number type.
 
using bis_Type
 Self type.
 

Public Member Functions

 BlockMap (const int size_x, const int size_y, const int size_z, const value_type pre_alloc_size)
 (Host) Constructor
 
void clear ()
 (Host) Clear tile hash table (Host, required by unordered map clear())
 
bool reserve (const value_type capacity)
 (Host) Set new capacity lower bound on the unordered map (Only for hash table, not for capacity of allocation)
 
KOKKOS_INLINE_FUNCTION uint32_t capacity () const
 (Host/Device) Require capacity of the index hash table
 
KOKKOS_INLINE_FUNCTION bool valid_at (uint32_t index) const
 (Device) Valid tile at index.
 
KOKKOS_INLINE_FUNCTION bool isValidKey (key_type key) const
 (Device) Check if the tile key is valid.
 
KOKKOS_INLINE_FUNCTION key_type key_at (uint32_t index) const
 (Device) Get tile key at index.
 
KOKKOS_INLINE_FUNCTION key_type value_at (uint32_t index) const
 (Device) get block id value at index
 
KOKKOS_INLINE_FUNCTION value_type validTileNumDev () const
 (Device) Valid tile number inside current block (MPI rank)
 
value_type validTileNumHost () const
 (Host) Valid tile number inside current block (MPI rank)
 
template<typename T>
value_type reservedTileNumHost (T factor) const
 (Host) Reserved tile number inside current block (MPI rank)
 
KOKKOS_INLINE_FUNCTION void insert (int tile_i, int tile_j, int tile_k) const
 (Device) Insert a tile into the hash table
 
KOKKOS_INLINE_FUNCTION value_type find (int tile_i, int tile_j, int tile_k) const
 (Device) Query the tile No. from the hash table
 
KOKKOS_INLINE_FUNCTION value_type findKey (key_type tile_key) const
 (Device) Query the tile No. from the hash table
 
KOKKOS_INLINE_FUNCTION key_type ijk2key (int tile_i, int tile_j, int tile_k) const
 (Device) Transfer tile ijk to tile hash key
 
KOKKOS_INLINE_FUNCTION void key2ijk (key_type &key, int &tile_i, int &tile_j, int &tile_k) const
 (Device) Transfer tile hash key to tile ijk
 

Static Public Attributes

static constexpr unsigned long long cell_bits_per_tile_dim = CBits
 Number of bits (per dimension) needed to index the cells inside a tile.
 
static constexpr unsigned long long cell_num_per_tile_dim = CNumPerDim
 Number of cells (per dimension) inside each tile.
 
static constexpr unsigned long long cell_num_per_tile = CNumPerTile
 Number of cells (total) inside each tile.
 
static constexpr HashTypes hash_type = Hash
 Hash table type.
 

Detailed Description

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
class Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >

Declaration of BlockMap.

Block index space, mapping tile ijks to tile No. through a hash table (Kokkos unordered map), note that the ijks should be global.

Template Parameters
CBitsNumber of bits (per dimension) to index the cells inside a tile
CNumPerDimNumber of cells (per dimension) inside each tile
CNumPerTileNumber of cells (total) inside each tile
HashHash type (lexicographical or morton)
KeyType of the tile/cell hash key
ValueType of the tile/cell No.

Member Typedef Documentation

◆ bis_Type

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
using Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::bis_Type
Initial value:
BlockMap(const int size_x, const int size_y, const int size_z, const value_type pre_alloc_size)
(Host) Constructor
Definition Cabana_Grid_SparseIndexSpace.hpp:747
Key key_type
Tile hash key type.
Definition Cabana_Grid_SparseIndexSpace.hpp:730
static constexpr unsigned long long cell_num_per_tile_dim
Number of cells (per dimension) inside each tile.
Definition Cabana_Grid_SparseIndexSpace.hpp:726
Value value_type
Tile number type.
Definition Cabana_Grid_SparseIndexSpace.hpp:732
static constexpr unsigned long long cell_num_per_tile
Number of cells (total) inside each tile.
Definition Cabana_Grid_SparseIndexSpace.hpp:728
static constexpr HashTypes hash_type
Hash table type.
Definition Cabana_Grid_SparseIndexSpace.hpp:734
static constexpr unsigned long long cell_bits_per_tile_dim
Number of bits (per dimension) needed to index the cells inside a tile.
Definition Cabana_Grid_SparseIndexSpace.hpp:724

Self type.

Constructor & Destructor Documentation

◆ BlockMap()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::BlockMap ( const int size_x,
const int size_y,
const int size_z,
const value_type pre_alloc_size )
inline

(Host) Constructor

Parameters
size_x,size_y,size_zThe size of the block (MPI rank) in each dimension (Unit: tile)
pre_alloc_sizeExpected capacity of the allocator to store the tiles when tile nums exceed the capacity

Member Function Documentation

◆ find()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
KOKKOS_INLINE_FUNCTION value_type Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::find ( int tile_i,
int tile_j,
int tile_k ) const
inline

(Device) Query the tile No. from the hash table

Parameters
tile_i,tile_j,tile_kTile ID in each dimension

◆ findKey()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
KOKKOS_INLINE_FUNCTION value_type Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::findKey ( key_type tile_key) const
inline

(Device) Query the tile No. from the hash table

Parameters
tile_keyTile Key in each dimension

◆ ijk2key()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
KOKKOS_INLINE_FUNCTION key_type Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::ijk2key ( int tile_i,
int tile_j,
int tile_k ) const
inline

(Device) Transfer tile ijk to tile hash key

Parameters
tile_i,tile_j,tile_kTile ID in each dimension

◆ insert()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
KOKKOS_INLINE_FUNCTION void Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::insert ( int tile_i,
int tile_j,
int tile_k ) const
inline

(Device) Insert a tile into the hash table

Parameters
tile_i,tile_j,tile_kTile ID in each dimension

◆ isValidKey()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
KOKKOS_INLINE_FUNCTION bool Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::isValidKey ( key_type key) const
inline

(Device) Check if the tile key is valid.

Parameters
keytile key to check

◆ key2ijk()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
KOKKOS_INLINE_FUNCTION void Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::key2ijk ( key_type & key,
int & tile_i,
int & tile_j,
int & tile_k ) const
inline

(Device) Transfer tile hash key to tile ijk

Parameters
keyTile hash key
tile_i,tile_j,tile_kTile ID in each dimension

◆ key_at()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
KOKKOS_INLINE_FUNCTION key_type Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::key_at ( uint32_t index) const
inline

(Device) Get tile key at index.

Parameters
indexindex number in Kokkos unordered map

◆ reserve()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
bool Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::reserve ( const value_type capacity)
inline

(Host) Set new capacity lower bound on the unordered map (Only for hash table, not for capacity of allocation)

Parameters
capacityNew capacity lower bound of the unordered map

◆ valid_at()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
KOKKOS_INLINE_FUNCTION bool Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::valid_at ( uint32_t index) const
inline

(Device) Valid tile at index.

Parameters
indexindex number in Kokkos unordered map

◆ value_at()

template<typename MemorySpace, unsigned long long CBits, unsigned long long CNumPerDim, unsigned long long CNumPerTile, HashTypes Hash, typename Key, typename Value>
KOKKOS_INLINE_FUNCTION key_type Cabana::Grid::BlockMap< MemorySpace, CBits, CNumPerDim, CNumPerTile, Hash, Key, Value >::value_at ( uint32_t index) const
inline

(Device) get block id value at index

Parameters
indexindex value in kokkos unordered map

The documentation for this class was generated from the following file: