Public Member Functions | Static Public Attributes | List of all members
rmm::mr::detail::arena::superblock Class Referencefinal

Represents a large chunk of memory that is exchanged between the global arena and per-thread arenas. More...

#include <arena.hpp>

Inheritance diagram for rmm::mr::detail::arena::superblock:
Inheritance graph
[legend]
Collaboration diagram for rmm::mr::detail::arena::superblock:
Collaboration graph
[legend]

Public Member Functions

 superblock ()=default
 Construct a default superblock.
 
 superblock (void *pointer, std::size_t size)
 Construct a superblock given a pointer and size. More...
 
 superblock (superblock const &)=delete
 
superblockoperator= (superblock const &)=delete
 
 superblock (superblock &&) noexcept=default
 
superblockoperator= (superblock &&) noexcept=default
 
bool empty () const
 Is this superblock empty? More...
 
std::size_t free_blocks () const
 Return the number of free blocks. More...
 
bool contains (block const &blk) const
 Whether this superblock contains the given block. More...
 
bool fits (std::size_t bytes) const
 Can this superblock fit bytes bytes? More...
 
bool is_contiguous_before (superblock const &sblk) const
 Verifies whether this superblock can be merged to the beginning of superblock s. More...
 
std::pair< superblock, superblocksplit (std::size_t bytes) const
 Split this superblock into two by the given size. More...
 
superblock merge (superblock const &sblk) const
 Coalesce two contiguous superblocks into one. More...
 
block first_fit (std::size_t size)
 Get the first free block of at least size bytes. More...
 
void coalesce (block const &blk)
 Coalesce the given block with other free blocks. More...
 
std::size_t total_free_size () const
 Find the total free block size. More...
 
std::size_t max_free_size () const
 Find the max free block size. More...
 
- Public Member Functions inherited from rmm::mr::detail::arena::byte_span
 byte_span ()=default
 Construct a default span.
 
 byte_span (void *pointer, std::size_t size)
 Construct a span given a pointer and size. More...
 
char * pointer () const
 Returns the underlying pointer.
 
std::size_t size () const
 Returns the size of the span.
 
char * end () const
 Returns the end of the span.
 
bool is_valid () const
 Returns true if this span is valid (non-null), false otherwise.
 
bool operator< (byte_span const &span) const
 Used by std::set to compare spans.
 

Static Public Attributes

static constexpr std::size_t minimum_size {1UL << 20}
 Minimum size of a superblock (1 MiB).
 
static constexpr std::size_t maximum_size {1UL << 40}
 Maximum size of a superblock (1 TiB), as a sanity check.
 

Detailed Description

Represents a large chunk of memory that is exchanged between the global arena and per-thread arenas.

Constructor & Destructor Documentation

◆ superblock()

rmm::mr::detail::arena::superblock::superblock ( void *  pointer,
std::size_t  size 
)
inline

Construct a superblock given a pointer and size.

Parameters
pointerThe address for the beginning of the superblock.
sizeThe size of the superblock.

Member Function Documentation

◆ coalesce()

void rmm::mr::detail::arena::superblock::coalesce ( block const &  blk)
inline

Coalesce the given block with other free blocks.

Parameters
blkThe block to coalesce.

◆ contains()

bool rmm::mr::detail::arena::superblock::contains ( block const &  blk) const
inline

Whether this superblock contains the given block.

Parameters
blkThe block to search for.
Returns
true if the given block belongs to this superblock.

◆ empty()

bool rmm::mr::detail::arena::superblock::empty ( ) const
inline

Is this superblock empty?

Returns
true if this superblock is empty.

◆ first_fit()

block rmm::mr::detail::arena::superblock::first_fit ( std::size_t  size)
inline

Get the first free block of at least size bytes.

Parameters
sizeThe number of bytes to allocate.
Returns
block A block of memory of at least size bytes, or an empty block if not found.

◆ fits()

bool rmm::mr::detail::arena::superblock::fits ( std::size_t  bytes) const
inline

Can this superblock fit bytes bytes?

Parameters
bytesThe size in bytes to check for fit.
Returns
true if this superblock can fit bytes bytes.

◆ free_blocks()

std::size_t rmm::mr::detail::arena::superblock::free_blocks ( ) const
inline

Return the number of free blocks.

Returns
the number of free blocks.

◆ is_contiguous_before()

bool rmm::mr::detail::arena::superblock::is_contiguous_before ( superblock const &  sblk) const
inline

Verifies whether this superblock can be merged to the beginning of superblock s.

Parameters
sThe superblock to check for contiguity.
Returns
true Returns true if both superblocks are empty and this superblock's pointer + size == s.ptr.

◆ max_free_size()

std::size_t rmm::mr::detail::arena::superblock::max_free_size ( ) const
inline

Find the max free block size.

Returns
the max free block size.

◆ merge()

superblock rmm::mr::detail::arena::superblock::merge ( superblock const &  sblk) const
inline

Coalesce two contiguous superblocks into one.

this->is_contiguous_before(s) must be true.

Parameters
sblksuperblock to merge.
Returns
block The merged block.

◆ split()

std::pair<superblock, superblock> rmm::mr::detail::arena::superblock::split ( std::size_t  bytes) const
inline

Split this superblock into two by the given size.

Parameters
bytesThe size in bytes of the first block.
Returns
superblock_pair A pair of superblocks split by bytes.

◆ total_free_size()

std::size_t rmm::mr::detail::arena::superblock::total_free_size ( ) const
inline

Find the total free block size.

Returns
the total free block size.

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