tatami_chunked
Helpers to create custom chunked tatami matrices
|
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 () |
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.
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. |
|
inline |
target_dim | Extent of the target dimension of the slab, i.e., the dimension that is indexed into. |
non_target_dim | Extent of the non-target dimension of the slab. |
slab_size | Size of the slab. This should be equal to the product of target_dim and non_target_dim . |
max_slabs | Maximum number of slabs. |
needs_value | Whether the values of the structural non-zeros should be cached. |
needs_index | Whether the indices of the structural non-zeros should be cached. |
|
inline |
Overload that computes slab_size
automatically.
target_dim | Extent of the target dimension of the slab. |
non_target_dim | Extent of the non-target dimension of the slab. |
max_slabs | Maximum number of slabs. |
needs_value | Whether the values of the structural non-zeros should be cached. |
needs_index | Whether the indices of the structural non-zeros should be cached. |
|
inline |
Overload that takes the relevant statistics from a SlabCacheStats
object.
target_dim | Extent of the target dimension of the slab. |
non_target_dim | Extent of the non-target dimension of the slab. |
stats | Slab statistics, computed from target_dim and non_target_dim . |
needs_value | Whether the values of the structural non-zeros should be cached. |
needs_index | Whether the indices of the structural non-zeros should be cached. |
|
inline |
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.