Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value > Class Template Reference

Sparse index space, with a hierarchical structure (cell->tile->block) More...

#include <Cabana_Grid_SparseIndexSpace.hpp>

Public Types

using key_type = Key
 Tile hash key type.
 
using value_type = Value
 Tile number type.
 
using memory_space = MemorySpace
 memory space
 

Public Member Functions

 SparseMap (const std::array< int, rank > size, const unsigned int pre_alloc_size)
 (Host) Constructor
 
KOKKOS_INLINE_FUNCTION void insertCell (int cell_i, int cell_j, int cell_k) const
 (Device) Insert a cell
 
KOKKOS_INLINE_FUNCTION void insertTile (int tile_i, int tile_j, int tile_k) const
 (Device) Insert a tile (to hash table); Note that the tile ijk should be global
 
KOKKOS_INLINE_FUNCTION value_type queryTile (int cell_i, int cell_j, int cell_k) const
 (Device) Query the 1D tile key from the 3D cell ijk
 
KOKKOS_INLINE_FUNCTION value_type queryTileFromTileId (const int tile_i, const int tile_j, const int tile_k) const
 (Device) Query the 1D tile key from the 3D tile ijk
 
KOKKOS_INLINE_FUNCTION value_type queryTileFromTileKey (const key_type tile_key) const
 (Device) Query the 1D tile key from the 1D tile key
 
KOKKOS_INLINE_FUNCTION value_type queryCell (int cell_i, int cell_j, int cell_k) const
 (Device) Query the 1D cell key from the 3D cell ijk
 
void clear ()
 (Host) Clear tile hash table (required by unordered map clear())
 
bool reserve (const value_type capacity)
 (Host) Set new capacity lower bound on the unordered map
 
KOKKOS_INLINE_FUNCTION uint32_t capacity () const
 (Host/Device) Require capacity of the index hash table
 
value_type size () const
 (Host) Valid tile number inside current block (MPI rank)
 
value_type sizeTile () const
 (Host) Valid tile number inside current block (MPI rank)
 
value_type sizeCell () const
 (Host) Valid cell number inside current block (MPI rank)
 
template<typename T>
value_type reservedTileSize (T factor) const
 (Host) Reserved tile number inside current block (MPI rank)
 
template<typename T>
value_type reservedCellSize (T factor) const
 (Host) Reserved cell number inside current block (MPI rank)
 
KOKKOS_INLINE_FUNCTION bool valid_at (uint32_t index) const
 (Device) Valid block 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 block key at index
 
KOKKOS_INLINE_FUNCTION value_type value_at (uint32_t index) const
 (Device) get tile id value at index
 
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
 
KOKKOS_INLINE_FUNCTION key_type ijk2key (int tile_i, int tile_j, int tile_k) const
 (Device) Transfer tile ijk to til key
 
KOKKOS_INLINE_FUNCTION value_type cell_local_id (const int cell_i, const int cell_j, const int cell_k) const
 (Device) Get local cell ID from cell IJK
 

Static Public Attributes

static constexpr int rank = 3
 Number of dimensions, 3 = ijk.
 
static constexpr unsigned long long cell_bits_per_tile_dim
 Number of bits (per dimension) needed to index the cells inside a tile.
 
static constexpr unsigned long long cell_num_per_tile_dim
 
static constexpr unsigned long long cell_mask_per_tile_dim
 
static constexpr unsigned long long cell_bits_per_tile
 Number of bits (total) needed to index the cells inside a tile.
 
static constexpr unsigned long long cell_mask_per_tile
 Cell mask (combine all dimensions dimension)
 
static constexpr unsigned long long cell_num_per_tile
 Number of cells (total) inside each tile.
 
static constexpr HashTypes hash_type = Hash
 Hash table type.
 

Detailed Description

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
class Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >

Sparse index space, with a hierarchical structure (cell->tile->block)

Template Parameters
MemorySpaceMemory space to store the Map(Hash Table)
CellPerTileDimCell number inside each tile per dimension
HashHash type (lexicographical or morton)
KeyType of the tile/cell hash key
ValueType of the tile/cell No.

Constructor & Destructor Documentation

◆ SparseMap()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::SparseMap ( const std::array< int, rank > size,
const unsigned int pre_alloc_size )
inline

(Host) Constructor

Parameters
sizeThe size of the block (MPI rank) (Unit: cell)
pre_alloc_sizeExpected capacity of the allocator to store the tiles when tile nums exceed the capacity

Member Function Documentation

◆ cell_local_id()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION value_type Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::cell_local_id ( const int cell_i,
const int cell_j,
const int cell_k ) const
inline

(Device) Get local cell ID from cell IJK

Parameters
cell_i,cell_j,cell_kCell ID in each dimension (both local and global IJK work)

◆ ijk2key()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION key_type Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::ijk2key ( int tile_i,
int tile_j,
int tile_k ) const
inline

(Device) Transfer tile ijk to til key

Parameters
tile_i,tile_j,tile_kTile ID in each dimension
Returns
tile hash key

◆ insertCell()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION void Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::insertCell ( int cell_i,
int cell_j,
int cell_k ) const
inline

(Device) Insert a cell

Parameters
cell_i,cell_j,cell_kCell ID in each dimension

Given a cell ijk, insert the tile where the cell reside in to hash table; Note that the ijk should be global

◆ insertTile()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION void Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::insertTile ( int tile_i,
int tile_j,
int tile_k ) const
inline

(Device) Insert a tile (to hash table); Note that the tile ijk should be global

Parameters
tile_i,tile_j,tile_kTile ID in each dimension

◆ isValidKey()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION bool Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, 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 CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION void Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, 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 CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION key_type Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::key_at ( uint32_t index) const
inline

(Device) Get block key at index

Parameters
indexindex number in Kokkos unordered_map

◆ queryCell()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION value_type Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::queryCell ( int cell_i,
int cell_j,
int cell_k ) const
inline

(Device) Query the 1D cell key from the 3D cell ijk

Parameters
cell_i,cell_j,cell_kCell ID in each dimension

◆ queryTile()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION value_type Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::queryTile ( int cell_i,
int cell_j,
int cell_k ) const
inline

(Device) Query the 1D tile key from the 3D cell ijk

Parameters
cell_i,cell_j,cell_kCell ID in each dimension

◆ queryTileFromTileId()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION value_type Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::queryTileFromTileId ( const int tile_i,
const int tile_j,
const int tile_k ) const
inline

(Device) Query the 1D tile key from the 3D tile ijk

Parameters
tile_i,tile_j,tile_kTile ID in each dimension

◆ queryTileFromTileKey()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION value_type Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::queryTileFromTileKey ( const key_type tile_key) const
inline

(Device) Query the 1D tile key from the 1D tile key

Parameters
tile_key1D tile key

◆ reserve()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
bool Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::reserve ( const value_type capacity)
inline

(Host) Set new capacity lower bound on the unordered map

Parameters
capacityNew capacity lower bound

◆ reservedCellSize()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
template<typename T>
value_type Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::reservedCellSize ( T factor) const
inline

(Host) Reserved cell number inside current block (MPI rank)

Parameters
factorscale up the real size as reserved space

◆ reservedTileSize()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
template<typename T>
value_type Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::reservedTileSize ( T factor) const
inline

(Host) Reserved tile number inside current block (MPI rank)

Parameters
factorscale up the real size as reserved space

◆ valid_at()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION bool Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::valid_at ( uint32_t index) const
inline

(Device) Valid block at index

Parameters
indexindex number in Kokkos unordered_map

◆ value_at()

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
KOKKOS_INLINE_FUNCTION value_type Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::value_at ( uint32_t index) const
inline

(Device) get tile id value at index

Parameters
indexindex value in kokkos unordered map

Member Data Documentation

◆ cell_bits_per_tile

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
unsigned long long Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::cell_bits_per_tile
staticconstexpr
Initial value:
=
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:417

Number of bits (total) needed to index the cells inside a tile.

◆ cell_bits_per_tile_dim

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
unsigned long long Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::cell_bits_per_tile_dim
staticconstexpr
Initial value:
=
bitCount( CellPerTileDim )
KOKKOS_INLINE_FUNCTION constexpr Integer bitCount(Integer input_int) noexcept
(Host/Device) Compute the lease bit number needed to index input integer
Definition Cabana_Grid_SparseIndexSpace.hpp:80

Number of bits (per dimension) needed to index the cells inside a tile.

◆ cell_mask_per_tile

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
unsigned long long Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::cell_mask_per_tile
staticconstexpr
Initial value:
=
( 1 << cell_bits_per_tile ) - 1
static constexpr unsigned long long cell_bits_per_tile
Number of bits (total) needed to index the cells inside a tile.
Definition Cabana_Grid_SparseIndexSpace.hpp:428

Cell mask (combine all dimensions dimension)

◆ cell_mask_per_tile_dim

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
unsigned long long Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::cell_mask_per_tile_dim
staticconstexpr
Initial value:
=

Cell mask (per dimension), indicating which part of the tile address(binary bits) will index the cells inside each tile

◆ cell_num_per_tile

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
unsigned long long Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::cell_num_per_tile
staticconstexpr
Initial value:
=
static constexpr unsigned long long cell_num_per_tile_dim
Definition Cabana_Grid_SparseIndexSpace.hpp:421

Number of cells (total) inside each tile.

◆ cell_num_per_tile_dim

template<typename MemorySpace, unsigned long long CellPerTileDim = 4, HashTypes Hash = HashTypes::Naive, typename Key = uint64_t, typename Value = uint64_t>
unsigned long long Cabana::Grid::SparseMap< MemorySpace, CellPerTileDim, Hash, Key, Value >::cell_num_per_tile_dim
staticconstexpr
Initial value:
=
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_SparseDimPartitioner.hpp:76

Number of cells inside each tile (per dimension), tile size reset to power of 2


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