A simple block structure specifying the size and location of a block of memory, with a flag indicating whether it is the head of a block of memory allocated from the heap (or upstream allocator).
More...
#include <coalescing_free_list.hpp>
|
| block (char *ptr, std::size_t size, bool is_head) |
|
char * | pointer () const |
| Returns the pointer to the memory represented by this block. More...
|
|
std::size_t | size () const |
| Returns the size of the memory represented by this block. More...
|
|
bool | is_head () const |
| Returns whether this block is the start of an allocation from an upstream allocator. More...
|
|
bool | operator< (block const &rhs) const noexcept |
| Comparison operator to enable comparing blocks and storing in ordered containers. More...
|
|
block | merge (block const &blk) const noexcept |
| Coalesce two contiguous blocks into one. More...
|
|
bool | is_contiguous_before (block const &blk) const noexcept |
| Verifies whether this block can be merged to the beginning of block b. More...
|
|
bool | fits (std::size_t bytes) const noexcept |
| Is this block large enough to fit sz bytes? More...
|
|
bool | is_better_fit (std::size_t bytes, block const &blk) const noexcept |
| Is this block a better fit for sz bytes than block b ? More...
|
|
| block_base (void *ptr) |
|
void * | pointer () const |
| Returns the raw pointer for this block.
|
|
bool | is_valid () const |
| Returns true if this block is valid (non-null), false otherwise.
|
|
|
void * | ptr {} |
| Raw memory pointer.
|
|
A simple block structure specifying the size and location of a block of memory, with a flag indicating whether it is the head of a block of memory allocated from the heap (or upstream allocator).
◆ fits()
bool rmm::mr::detail::block::fits |
( |
std::size_t |
bytes | ) |
const |
|
inlinenoexcept |
Is this block large enough to fit sz
bytes?
- Parameters
-
bytes | The size in bytes to check for fit. |
- Returns
- true if this block is at least
bytes
bytes
◆ is_better_fit()
bool rmm::mr::detail::block::is_better_fit |
( |
std::size_t |
bytes, |
|
|
block const & |
blk |
|
) |
| const |
|
inlinenoexcept |
Is this block a better fit for sz
bytes than block b
?
- Parameters
-
bytes | The size in bytes to check for best fit. |
blk | The other block to check for fit. |
- Returns
- true If this block is a tighter fit for
bytes
bytes than block blk
.
-
false If this block does not fit
bytes
bytes or blk
is a tighter fit.
◆ is_contiguous_before()
bool rmm::mr::detail::block::is_contiguous_before |
( |
block const & |
blk | ) |
const |
|
inlinenoexcept |
Verifies whether this block can be merged to the beginning of block b.
- Parameters
-
blk | The block to check for contiguity. |
- Returns
- Returns true if this blocks's
ptr
+ size
== b.ptr
, and not b.is_head
, false otherwise.
◆ is_head()
bool rmm::mr::detail::block::is_head |
( |
| ) |
const |
|
inline |
Returns whether this block is the start of an allocation from an upstream allocator.
A block b
may not be coalesced with a preceding contiguous block a
if b.is_head == true
.
- Returns
- true if this block is the start of an allocation from an upstream allocator.
◆ merge()
block rmm::mr::detail::block::merge |
( |
block const & |
blk | ) |
const |
|
inlinenoexcept |
Coalesce two contiguous blocks into one.
this
must immediately precede b
and both this
and b
must be from the same upstream allocation. That is, this->is_contiguous_before(b)
. Otherwise behavior is undefined.
- Parameters
-
- Returns
- The merged block
◆ operator<()
bool rmm::mr::detail::block::operator< |
( |
block const & |
rhs | ) |
const |
|
inlinenoexcept |
Comparison operator to enable comparing blocks and storing in ordered containers.
Orders by ptr address.
- Parameters
-
- Returns
- true if this block's ptr is < than
rhs
block pointer.
-
false if this block's ptr is >= than
rhs
block pointer.
◆ pointer()
char* rmm::mr::detail::block::pointer |
( |
| ) |
const |
|
inline |
Returns the pointer to the memory represented by this block.
- Returns
- the pointer to the memory represented by this block.
◆ size()
std::size_t rmm::mr::detail::block::size |
( |
| ) |
const |
|
inline |
Returns the size of the memory represented by this block.
- Returns
- the size in bytes of the memory represented by this block.
The documentation for this struct was generated from the following file: