cuda::experimental::stf::cached_block_allocator#
-
class cached_block_allocator : public cuda::experimental::stf::block_allocator_interface#
Cached block allocator that implements block_allocator_interface.
This allocator uses an internal cache to reuse previously allocated memory blocks. The aim is to reduce the overhead of memory allocation.
Public Functions
- inline cached_block_allocator(
- block_allocator_untyped root_allocator_,
This constructor takes a root allocator which performs allocations when there is a cache miss.
- inline virtual void *allocate(
- backend_ctx_untyped &ctx,
- const data_place &memory_node,
- ::std::ptrdiff_t &s,
- event_list &prereqs,
Allocates a memory block.
Attempts to allocate a memory block from the internal cache if available.
- Parameters:
ctx – The backend context (unused in this implementation).
memory_node – Memory location where the allocation should happen.
s – Pointer to the size of memory required.
prereqs – List of events that this allocation depends on.
- Returns:
void* A pointer to the allocated memory block or nullptr if allocation fails.
- inline virtual void deallocate(
- backend_ctx_untyped&,
- const data_place &memory_node,
- event_list &prereqs,
- void *ptr,
- size_t sz,
Deallocates a memory block.
Puts the deallocated block back into the internal cache for future reuse.
- Parameters:
ctx – The backend context (unused in this implementation).
memory_node – Memory location where the deallocation should happen.
prereqs – List of events that this deallocation depends on.
ptr – Pointer to the memory block to be deallocated.
sz – Size of the memory block.
-
inline virtual event_list deinit(backend_ctx_untyped &ctx) override#
De-initializes the allocator.
-
inline virtual ::std::string to_string() const override#
Returns a string representation of the allocator.
- Returns:
std::string The string “cached_block_allocator”.
-
inline virtual void print_info() const#
Print information about the allocator.
This method prints information about the allocator to stderr.