A device_memory_resource
which allocates memory blocks of a single fixed size.
More...
#include <fixed_size_memory_resource.hpp>
|
using | free_list = detail::fixed_size_free_list |
| The free list type.
|
|
using | block_type = free_list::block_type |
| The type of block managed by the free list.
|
|
using | lock_guard = std::lock_guard< std::mutex > |
| Type of lock used to synchronize access.
|
|
|
class | detail::stream_ordered_memory_resource< fixed_size_memory_resource< Upstream >, detail::fixed_size_free_list > |
|
template<typename Upstream>
class rmm::mr::fixed_size_memory_resource< Upstream >
A device_memory_resource
which allocates memory blocks of a single fixed size.
Supports only allocations of size smaller than the configured block_size.
◆ fixed_size_memory_resource()
template<typename Upstream >
Construct a new fixed_size_memory_resource
that allocates memory from upstream_resource
.
When the pool of blocks is all allocated, grows the pool by allocating blocks_to_preallocate
more blocks from upstream_mr
.
- Parameters
-
upstream_mr | The memory_resource from which to allocate blocks for the pool. |
block_size | The size of blocks to allocate. |
blocks_to_preallocate | The number of blocks to allocate to initialize the pool. |
◆ allocate_from_block()
template<typename Upstream >
Splits block if necessary to return a pointer to memory of size
bytes.
If the block is split, the remainder is returned to the pool.
- Parameters
-
block | The block to allocate from. |
size | The size in bytes of the requested allocation. |
- Returns
- A pair comprising the allocated pointer and any unallocated remainder of the input block.
◆ blocks_from_upstream()
template<typename Upstream >
Allocate blocks from upstream to expand the suballocation pool.
- Parameters
-
stream | The stream on which the memory is to be used. |
- Returns
- block_type The allocated block
◆ do_get_mem_info()
template<typename Upstream >
Get free and available memory for memory resource.
- Exceptions
-
std::runtime_error | if we could not get free / total memory |
- Parameters
-
stream | the stream being executed on |
- Returns
- std::pair with available and free memory for resource
◆ expand_pool()
template<typename Upstream >
Allocate a block from upstream to supply the suballocation pool.
Note typically the allocated size will be larger than requested, and is based on the growth strategy (see size_to_grow()
).
- Parameters
-
size | The minimum size to allocate |
blocks | The set of blocks from which to allocate |
stream | The stream on which the memory is to be used. |
- Returns
- block_type The allocated block
◆ free_block()
template<typename Upstream >
Finds, frees and returns the block associated with pointer.
- Parameters
-
ptr | The pointer to the memory to free. |
size | The size of the memory to free. Must be equal to the original allocation size. |
- Returns
- The (now freed) block associated with
p
. The caller is expected to return the block to the pool.
◆ free_list_summary()
template<typename Upstream >
Get the largest available block size and total free size in the specified free list.
This is intended only for debugging
- Parameters
-
blocks | The free list from which to return the summary |
- Returns
- std::pair<std::size_t, std::size_t> Pair of largest available block, total free size
◆ get_block_size()
template<typename Upstream >
Get the size of blocks allocated by this memory resource.
- Returns
- std::size_t size in bytes of allocated blocks.
◆ get_maximum_allocation_size()
template<typename Upstream >
Get the (fixed) size of allocations supported by this memory resource.
- Returns
- std::size_t The (fixed) maximum size of a single allocation supported by this memory resource
◆ get_upstream()
template<typename Upstream >
Get the upstream memory_resource object.
- Returns
- UpstreamResource* the upstream memory resource.
◆ supports_get_mem_info()
template<typename Upstream >
Query whether the resource supports the get_mem_info API.
- Returns
- false
◆ supports_streams()
template<typename Upstream >
Query whether the resource supports use of non-null streams for allocation/deallocation.
- Returns
- true
◆ default_blocks_to_preallocate
template<typename Upstream >
The number of blocks that the pool starts out with, and also the number of blocks by which the pool grows when all of its current blocks are allocated
The documentation for this class was generated from the following file: