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

A thread-safe container for managing chunks in an AllGather. More...

#include <allgather.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...
 
void increment_goalpost (std::uint64_t amount)
 Increment the goalpost to a new expected chunk count. More...
 
bool ready () const noexcept
 Check if the postbox has reached its goal. 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...
 
bool empty () const noexcept
 Check if the postbox is empty. More...
 
std::size_t spill (BufferResource *br, Communicator::Logger &log, std::size_t amount)
 Spill device data from the post box. More...
 

Detailed Description

A thread-safe container for managing chunks in an AllGather.

A PostBox provides a synchronized storage mechanism for chunks, allowing multiple threads to insert chunks and extract ready chunks safely. It maintains a goalpost mechanism to track when all expected chunks have been received.

Definition at line 255 of file allgather.hpp.

Member Function Documentation

◆ empty()

bool rapidsmpf::allgather::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::allgather::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::allgather::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.

◆ increment_goalpost()

void rapidsmpf::allgather::detail::PostBox::increment_goalpost ( std::uint64_t  amount)

Increment the goalpost to a new expected chunk count.

Parameters
amountThe amount to move the goalpost by.

◆ insert() [1/2]

void rapidsmpf::allgather::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::allgather::detail::PostBox::insert ( std::vector< std::unique_ptr< Chunk >> &&  chunks)

Insert multiple chunks into the postbox.

Parameters
chunksA vector of chunks to insert.

◆ ready()

bool rapidsmpf::allgather::detail::PostBox::ready ( ) const
noexcept

Check if the postbox has reached its goal.

Returns
True if the number of stored chunks matches the current goalpost, false otherwise.

◆ spill()

std::size_t rapidsmpf::allgather::detail::PostBox::spill ( BufferResource br,
Communicator::Logger log,
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.
logLogger instance.
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: