tatami_chunked
Helpers to create custom chunked tatami matrices
Loading...
Searching...
No Matches
tatami_chunked::DenseSlabFactory< Value_ > Class Template Reference

Factory for dense slabs. More...

#include <DenseSlabFactory.hpp>

Classes

struct  Slab
 Dense slab. More...
 

Public Member Functions

template<typename Index_ >
 DenseSlabFactory (std::size_t slab_size, Index_ max_slabs)
 
template<typename Index_ >
 DenseSlabFactory (const SlabCacheStats< Index_ > &stats)
 
Slab create ()
 

Detailed Description

template<typename Value_>
class tatami_chunked::DenseSlabFactory< Value_ >

Factory for dense slabs.

An instance of this class allocates a single memory pool during its construction. Each slab is simply a pointer into this pool at regular offsets. The idea is to allocate one large block 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.

Constructor & Destructor Documentation

◆ DenseSlabFactory() [1/2]

template<typename Value_ >
template<typename Index_ >
tatami_chunked::DenseSlabFactory< Value_ >::DenseSlabFactory ( std::size_t slab_size,
Index_ max_slabs )
inline
Template Parameters
Index_Integer type of the maximum number of slabs, see the template parameter of the same name in SlabCacheStats.
Parameters
slab_sizeSize of the slab, in terms of data elements.
max_slabsMaximum number of slabs.

◆ DenseSlabFactory() [2/2]

template<typename Value_ >
template<typename Index_ >
tatami_chunked::DenseSlabFactory< Value_ >::DenseSlabFactory ( const SlabCacheStats< Index_ > & stats)
inline
Template Parameters
Index_Integer type of the dimension extent.
Parameters
statsSlab cache statistics.

Member Function Documentation

◆ create()

template<typename Value_ >
Slab tatami_chunked::DenseSlabFactory< Value_ >::create ( )
inline

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

Returns
Slab containing a pointer to the memory pool.

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