Public Member Functions | List of all members
rapidsmpf::coll::detail::PostBox Class Reference

A thread-safe container for managing chunks in collectives. More...

#include <utils.hpp>

Public Member Functions

 PostBox ()=default
 Default constructor.
 
 ~PostBox ()=default
 Default destructor.
 
 PostBox (PostBox const &)=delete
 Deleted copy constructor.
 
PostBoxoperator= (PostBox const &)=delete
 Deleted copy assignment operator.
 
 PostBox (PostBox &&)=delete
 Deleted move constructor.
 
PostBoxoperator= (PostBox &&)=delete
 Deleted move assignment operator.
 
void insert (std::unique_ptr< Chunk > chunk)
 Insert a single chunk into the postbox. More...
 
void insert (std::vector< std::unique_ptr< Chunk >> &&chunks)
 Insert multiple chunks into the postbox. More...
 
std::vector< std::unique_ptr< Chunk > > extract_ready ()
 Extract ready chunks from the postbox. More...
 
std::vector< std::unique_ptr< Chunk > > extract ()
 Extract all chunks from the postbox. More...
 
std::size_t size () const noexcept
 Check the number of chunks currently stored. More...
 
bool empty () const noexcept
 Check if the postbox is empty. More...
 
std::size_t spill (BufferResource *br, std::size_t amount)
 Spill device data from the post box. More...
 

Detailed Description

A thread-safe container for managing chunks in collectives.

A PostBox provides a synchronized storage mechanism for chunks, allowing multiple threads to insert chunks and extract ready chunks safely.

Definition at line 262 of file utils.hpp.

Member Function Documentation

◆ empty()

bool rapidsmpf::coll::detail::PostBox::empty ( ) const
noexcept

Check if the postbox is empty.

Returns
True if the postbox contains no chunks, false otherwise.

◆ extract()

std::vector<std::unique_ptr<Chunk> > rapidsmpf::coll::detail::PostBox::extract ( )

Extract all chunks from the postbox.

Returns
A vector containing all chunks in the postbox.
Note
The caller must ensure that any subsequent operations on the return chunks are stream-ordered.

◆ extract_ready()

std::vector<std::unique_ptr<Chunk> > rapidsmpf::coll::detail::PostBox::extract_ready ( )

Extract ready chunks from the postbox.

Returns
A vector of chunks that are ready for processing.
Note
Ready chunks are those with no pending operations on their data buffers.

◆ insert() [1/2]

void rapidsmpf::coll::detail::PostBox::insert ( std::unique_ptr< Chunk chunk)

Insert a single chunk into the postbox.

Parameters
chunkThe chunk to insert.

◆ insert() [2/2]

void rapidsmpf::coll::detail::PostBox::insert ( std::vector< std::unique_ptr< Chunk >> &&  chunks)

Insert multiple chunks into the postbox.

Parameters
chunksA vector of chunks to insert.

◆ size()

std::size_t rapidsmpf::coll::detail::PostBox::size ( ) const
noexcept

Check the number of chunks currently stored.

Returns
The number of chunks currently in the postbox.

◆ spill()

std::size_t rapidsmpf::coll::detail::PostBox::spill ( BufferResource br,
std::size_t  amount 
)

Spill device data from the post box.

The spilling is stream ordered by the spilled buffers' CUDA streams.

Parameters
brThe buffer resource for host and device allocations.
amountRequested amount of data to spill in bytes.
Returns
Actual amount of data spilled in bytes.
Note
We attempt to minimise the number of individual buffers spilled, as well as the amount of "overspill".

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