tatami_chunked
Helpers to create custom chunked tatami matrices
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
tatami_chunked::SparseSlabFactory< Value_, Index_, Count_ > Struct Template Reference

Factory for sparse slabs. More...

#include <SparseSlabFactory.hpp>

Classes

struct  Slab
 Sparse slab. More...
 

Public Member Functions

 SparseSlabFactory (size_t target_dim, size_t non_target_dim, size_t slab_size, size_t max_slabs, bool needs_value, bool needs_index)
 
 SparseSlabFactory (size_t target_dim, size_t non_target_dim, size_t max_slabs, bool needs_value, bool needs_index)
 
 SparseSlabFactory (size_t target_dim, size_t non_target_dim, const SlabCacheStats &stats, bool needs_value, bool needs_index)
 
Slab create ()
 

Detailed Description

template<typename Value_, typename Index_, typename Count_ = Index_>
struct tatami_chunked::SparseSlabFactory< Value_, Index_, Count_ >

Factory for sparse slabs.

An instance of this class allocates two memory pools (for values and indices) during its construction. Each slab simply contains pointers into this pool at regular offsets. The idea is to allocate large blocks for caching in, e.g., LruSlabCache, improving performance by avoiding repeated requests to the allocator. This also reduces fragmentation that could increase memory usage beyond the expected cache size.

Template Parameters
Value_Type of the data in each slab.
Index_Integer type of the indices in each slab.
Count_Integer type for counting structural non-zeros. This should be large enough to store the extent of the non-target dimension of the slab.

Constructor & Destructor Documentation

◆ SparseSlabFactory() [1/3]

template<typename Value_ , typename Index_ , typename Count_ = Index_>
tatami_chunked::SparseSlabFactory< Value_, Index_, Count_ >::SparseSlabFactory ( size_t  target_dim,
size_t  non_target_dim,
size_t  slab_size,
size_t  max_slabs,
bool  needs_value,
bool  needs_index 
)
inline
Parameters
target_dimExtent of the target dimension of the slab, i.e., the dimension that is indexed into.
non_target_dimExtent of the non-target dimension of the slab.
slab_sizeSize of the slab. This should be equal to the product of target_dim and non_target_dim.
max_slabsMaximum number of slabs.
needs_valueWhether the values of the structural non-zeros should be cached.
needs_indexWhether the indices of the structural non-zeros should be cached.

◆ SparseSlabFactory() [2/3]

template<typename Value_ , typename Index_ , typename Count_ = Index_>
tatami_chunked::SparseSlabFactory< Value_, Index_, Count_ >::SparseSlabFactory ( size_t  target_dim,
size_t  non_target_dim,
size_t  max_slabs,
bool  needs_value,
bool  needs_index 
)
inline

Overload that computes slab_size automatically.

Parameters
target_dimExtent of the target dimension of the slab.
non_target_dimExtent of the non-target dimension of the slab.
max_slabsMaximum number of slabs.
needs_valueWhether the values of the structural non-zeros should be cached.
needs_indexWhether the indices of the structural non-zeros should be cached.

◆ SparseSlabFactory() [3/3]

template<typename Value_ , typename Index_ , typename Count_ = Index_>
tatami_chunked::SparseSlabFactory< Value_, Index_, Count_ >::SparseSlabFactory ( size_t  target_dim,
size_t  non_target_dim,
const SlabCacheStats stats,
bool  needs_value,
bool  needs_index 
)
inline

Overload that takes the relevant statistics from a SlabCacheStats object.

Parameters
target_dimExtent of the target dimension of the slab.
non_target_dimExtent of the non-target dimension of the slab.
statsSlab statistics, computed from target_dim and non_target_dim.
needs_valueWhether the values of the structural non-zeros should be cached.
needs_indexWhether the indices of the structural non-zeros should be cached.

Member Function Documentation

◆ create()

Create a new slab, i.e., designate a portion of each memory pool for use through the returned pointers. This should not be called more than max_slabs times.

Returns
Slab containing pointers to the relevant memory pools.

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