10 #include <kvikio/defaults.hpp>
118 template <
typename Allocator = CudaPinnedAllocator>
121 mutable std::mutex _mutex{};
123 std::stack<void*> _free_buffers{};
126 Allocator _allocator{};
150 void* get()
const noexcept;
151 void* get(std::ptrdiff_t offset)
const noexcept;
152 std::size_t size()
const noexcept;
172 void _deallocate_buffers(std::stack<
void*>& buffers, std::
size_t buffer_size);
184 [[nodiscard]] std::pair<std::stack<
void*>, std::
size_t> _detach_free_buffers();
198 [[nodiscard]] std::pair<std::stack<
void*>, std::
size_t> _ensure_buffer_size();
223 void put(
void* buffer, std::
size_t size) noexcept;
RAII wrapper for a host bounce buffer allocation.
Thread-safe singleton pool for reusable bounce buffers.
void put(void *buffer, std::size_t size) noexcept
Return a buffer to the pool for reuse.
std::size_t num_free_buffers() const
Get the number of free buffers currently available in the pool.
std::size_t buffer_size() const
Get the current buffer size used by the pool.
std::size_t clear()
Free all retained allocations in the pool.
static KVIKIO_EXPORT BounceBufferPool & instance()
Get the singleton instance of the pool.
Buffer get()
Acquire a bounce buffer from the pool.
Allocator for page-aligned AND CUDA-registered pinned host memory.
void deallocate(void *buffer, std::size_t size)
Deallocate memory previously allocated by this allocator.
void * allocate(std::size_t size)
Allocate page-aligned CUDA-registered pinned host memory.
Allocator for CUDA pinned host memory.
void deallocate(void *buffer, std::size_t size)
Deallocate memory previously allocated by this allocator.
void * allocate(std::size_t size)
Allocate CUDA pinned host memory.
Allocator for page-aligned host memory.
void deallocate(void *buffer, std::size_t size)
Deallocate memory previously allocated by this allocator.
void * allocate(std::size_t size)
Allocate page-aligned host memory.
static std::size_t bounce_buffer_size()
Get the size of the bounce buffer used to stage data in host memory.