Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
rapidsmpf::allgather::detail::Chunk Class Reference

Represents a data chunk in the allgather operation. More...

#include <allgather.hpp>

Public Member Functions

bool is_ready () const noexcept
 Check if the chunk is ready for processing. More...
 
MemoryType memory_type () const noexcept
 Return the memory type of the chunk. More...
 
bool is_finish () const noexcept
 Check if this is a finish marker chunk. More...
 
ChunkID id () const noexcept
 The unique identifier of the chunk. More...
 
ChunkID sequence () const noexcept
 The sequence number of the chunk. More...
 
Rank origin () const noexcept
 The origin rank of the chunk. More...
 
std::uint64_t data_size () const noexcept
 The size of the data buffer in bytes. More...
 
std::uint64_t metadata_size () const noexcept
 The size of the metadata buffer in bytes. More...
 
PackedData release ()
 Release the chunk's data as PackedData. More...
 
std::unique_ptr< std::vector< std::uint8_t > > serialize () const
 Serialize the metadata of the chunk to a byte vector. More...
 
std::unique_ptr< Bufferrelease_data_buffer () noexcept
 Release and return the data buffer. More...
 
void attach_data_buffer (std::unique_ptr< Buffer > data)
 Attach a data buffer to this chunk. More...
 
 ~Chunk ()=default
 Default destructor.
 
 Chunk (Chunk &&)=default
 Move constructor.
 
Chunkoperator= (Chunk &&)=default
 Move assignment operator. More...
 
 Chunk (Chunk const &)=delete
 Deleted copy constructor.
 
Chunkoperator= (Chunk const &)=delete
 Deleted copy assignment operator.
 

Static Public Member Functions

static std::unique_ptr< Chunkfrom_packed_data (std::uint64_t sequence, Rank origin, PackedData &&packed_data)
 Create a data chunk from packed data. More...
 
static std::unique_ptr< Chunkfrom_empty (std::uint64_t num_local_insertions, Rank origin)
 Create an empty finish marker chunk. More...
 
static constexpr ChunkID chunk_id (std::uint64_t sequence, Rank origin)
 Create a ChunkID from a sequence number and origin rank. More...
 
static std::unique_ptr< Chunkdeserialize (std::vector< std::uint8_t > &data, BufferResource *br)
 Deserialize a chunk from a byte vector of its metadata. More...
 

Static Public Attributes

static constexpr std::uint64_t ID_BITS = 38
 Number of bits used for the sequence ID in the chunk identifier.
 
static constexpr std::uint64_t RANK_BITS
 Number of bits used for the rank in the chunk identifier. More...
 

Detailed Description

Represents a data chunk in the allgather operation.

A chunk is either a data message (in which case metadata indicates how the data are to be interpreted), or a control (finish) message (in which case metadata and data are empty). Chunks within a single AllGather operation are uniquely identified by an (id, is_finish) pair.

Definition at line 51 of file allgather.hpp.

Member Function Documentation

◆ attach_data_buffer()

void rapidsmpf::allgather::detail::Chunk::attach_data_buffer ( std::unique_ptr< Buffer data)

Attach a data buffer to this chunk.

Parameters
dataThe data buffer to attach.
Exceptions
std::logic_errorIf the data_size() of the chunk does not match the size of the provided new data buffer, or the chunk already has a data buffer.

◆ chunk_id()

static constexpr ChunkID rapidsmpf::allgather::detail::Chunk::chunk_id ( std::uint64_t  sequence,
Rank  origin 
)
staticconstexpr

Create a ChunkID from a sequence number and origin rank.

Parameters
sequencethe sequence number.
originthe origin rank.
Returns
The new chunk id.

◆ data_size()

std::uint64_t rapidsmpf::allgather::detail::Chunk::data_size ( ) const
noexcept

The size of the data buffer in bytes.

Returns
The size of the chunk's data buffer.

◆ deserialize()

static std::unique_ptr<Chunk> rapidsmpf::allgather::detail::Chunk::deserialize ( std::vector< std::uint8_t > &  data,
BufferResource br 
)
static

Deserialize a chunk from a byte vector of its metadata.

Parameters
dataThe serialized chunk data.
brBuffer resource for memory allocation.
Returns
A unique pointer to the deserialized chunk.
Note
If the serialized form encodes a data chunk, this function allocates space for the data buffer.

◆ from_empty()

static std::unique_ptr<Chunk> rapidsmpf::allgather::detail::Chunk::from_empty ( std::uint64_t  num_local_insertions,
Rank  origin 
)
static

Create an empty finish marker chunk.

Parameters
num_local_insertionsThe number of data insertions on this rank.
originThe originating rank.
Returns
A unique pointer to the created finish marker chunk.

◆ from_packed_data()

static std::unique_ptr<Chunk> rapidsmpf::allgather::detail::Chunk::from_packed_data ( std::uint64_t  sequence,
Rank  origin,
PackedData &&  packed_data 
)
static

Create a data chunk from packed data.

Parameters
sequenceThe sequence number for the chunk.
originThe originating rank.
packed_dataThe packed data to create the chunk from.
Returns
A unique pointer to the created chunk.

◆ id()

ChunkID rapidsmpf::allgather::detail::Chunk::id ( ) const
noexcept

The unique identifier of the chunk.

Returns
The chunk's unique identifier.

◆ is_finish()

bool rapidsmpf::allgather::detail::Chunk::is_finish ( ) const
noexcept

Check if this is a finish marker chunk.

Returns
True if this chunk represents a finish marker, false otherwise.

◆ is_ready()

bool rapidsmpf::allgather::detail::Chunk::is_ready ( ) const
noexcept

Check if the chunk is ready for processing.

A chunk is ready either if it has no data buffer, or any outstanding operations on the data buffer have completed.

Returns
True if the chunk is ready, false otherwise.

◆ memory_type()

MemoryType rapidsmpf::allgather::detail::Chunk::memory_type ( ) const
noexcept

Return the memory type of the chunk.

Returns
The memory type of the chunk.
Note
a finish chunk has memory type host.

◆ metadata_size()

std::uint64_t rapidsmpf::allgather::detail::Chunk::metadata_size ( ) const
noexcept

The size of the metadata buffer in bytes.

Returns
The size of the chunk's metadata.

◆ operator=()

Chunk& rapidsmpf::allgather::detail::Chunk::operator= ( Chunk &&  )
default

Move assignment operator.

Returns
Moved this

◆ origin()

Rank rapidsmpf::allgather::detail::Chunk::origin ( ) const
noexcept

The origin rank of the chunk.

Returns
The rank that originated this chunk.

◆ release()

PackedData rapidsmpf::allgather::detail::Chunk::release ( )

Release the chunk's data as PackedData.

Returns
The chunk's data and metadata as PackedData.
Exceptions
std::logic_errorif the chunk is not a data chunk.
Note
Behaviour is undefined if the chunk is used after being released.

◆ release_data_buffer()

std::unique_ptr<Buffer> rapidsmpf::allgather::detail::Chunk::release_data_buffer ( )
noexcept

Release and return the data buffer.

Returns
The data buffer, leaving the chunk without data.

◆ sequence()

ChunkID rapidsmpf::allgather::detail::Chunk::sequence ( ) const
noexcept

The sequence number of the chunk.

Returns
The sequence number portion of the chunk ID.

◆ serialize()

std::unique_ptr<std::vector<std::uint8_t> > rapidsmpf::allgather::detail::Chunk::serialize ( ) const

Serialize the metadata of the chunk to a byte vector.

Returns
A vector containing the serialized chunk data.

Member Data Documentation

◆ RANK_BITS

constexpr std::uint64_t rapidsmpf::allgather::detail::Chunk::RANK_BITS
staticconstexpr
Initial value:
=
sizeof(ChunkID) * std::numeric_limits<unsigned char>::digits - ID_BITS
static constexpr std::uint64_t ID_BITS
Number of bits used for the sequence ID in the chunk identifier.
Definition: allgather.hpp:181

Number of bits used for the rank in the chunk identifier.

Definition at line 183 of file allgather.hpp.


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