Classes | Public Member Functions | List of all members
rapidsmpf::Communicator Class Referenceabstract

Abstract base class for a communication mechanism between nodes. More...

#include <communicator.hpp>

Inheritance diagram for rapidsmpf::Communicator:
rapidsmpf::MPI rapidsmpf::Single rapidsmpf::ucxx::UCXX

Classes

class  Future
 Abstract base class for asynchronous operation within the communicator. More...
 
class  Logger
 A logger base class for handling different levels of log messages. More...
 

Public Member Functions

virtual Rank rank () const =0
 Retrieves the rank of the current node. More...
 
virtual Rank nranks () const =0
 Retrieves the total number of ranks. More...
 
virtual std::unique_ptr< Futuresend (std::unique_ptr< std::vector< uint8_t >> msg, Rank rank, Tag tag)=0
 Sends a host message to a specific rank. More...
 
virtual std::unique_ptr< Futuresend (std::unique_ptr< Buffer > msg, Rank rank, Tag tag)=0
 Sends a message (device or host) to a specific rank. More...
 
virtual std::unique_ptr< Futurerecv (Rank rank, Tag tag, std::unique_ptr< Buffer > recv_buffer)=0
 Receives a message from a specific rank to a buffer. Use release_data to extract the data out of the buffer once the future is completed. More...
 
virtual std::unique_ptr< Futurerecv_sync_host_data (Rank rank, Tag tag, std::unique_ptr< std::vector< uint8_t >> synced_buffer)=0
 Receives a message from a specific rank to an allocated (synchronized) host buffer. Use release_sync_host_data to extract the data out of the buffer once the future is completed. More...
 
virtual std::pair< std::unique_ptr< std::vector< uint8_t > >, Rank > recv_any (Tag tag)=0
 Receives a message from any rank (blocking). More...
 
virtual std::unique_ptr< std::vector< uint8_t > > recv_from (Rank src, Tag tag)=0
 Receives a message from a specific rank (blocking). More...
 
virtual std::pair< std::vector< std::unique_ptr< Future > >, std::vector< std::size_t > > test_some (std::vector< std::unique_ptr< Future >> &future_vector)=0
 Tests for completion of multiple futures. More...
 
virtual std::vector< std::size_t > test_some (std::unordered_map< std::size_t, std::unique_ptr< Communicator::Future >> const &future_map)=0
 Tests for completion of multiple futures in a map. More...
 
virtual std::unique_ptr< Bufferwait (std::unique_ptr< Future > future)=0
 Wait for a future to complete and return the data buffer. More...
 
virtual std::unique_ptr< Bufferrelease_data (std::unique_ptr< Communicator::Future > future)=0
 Retrieves data associated with a completed future. More...
 
virtual std::unique_ptr< std::vector< uint8_t > > release_sync_host_data (std::unique_ptr< Communicator::Future > future)=0
 Retrieves synchronized host data associated with a completed future. When the future is completed, the the host data is valid, and ready, but not stream-ordered. More...
 
virtual Loggerlogger ()=0
 Retrieves the logger associated with this communicator. More...
 
virtual std::string str () const =0
 Provides a string representation of the communicator. More...
 

Detailed Description

Abstract base class for a communication mechanism between nodes.

Provides an interface for sending and receiving messages between nodes, supporting asynchronous operations, GPU data transfers, and custom logging. Implementations must define the virtual methods to enable specific communication backends.

Definition at line 141 of file communicator.hpp.

Member Function Documentation

◆ logger()

virtual Logger& rapidsmpf::Communicator::logger ( )
pure virtual

Retrieves the logger associated with this communicator.

Returns
Reference to the logger.

Implemented in rapidsmpf::ucxx::UCXX, rapidsmpf::Single, and rapidsmpf::MPI.

◆ nranks()

virtual Rank rapidsmpf::Communicator::nranks ( ) const
pure virtual

Retrieves the total number of ranks.

Returns
The total number of ranks.

Implemented in rapidsmpf::ucxx::UCXX, rapidsmpf::Single, and rapidsmpf::MPI.

◆ rank()

virtual Rank rapidsmpf::Communicator::rank ( ) const
pure virtual

Retrieves the rank of the current node.

Returns
The rank of the node.

Implemented in rapidsmpf::ucxx::UCXX, rapidsmpf::Single, and rapidsmpf::MPI.

◆ recv()

virtual std::unique_ptr<Future> rapidsmpf::Communicator::recv ( Rank  rank,
Tag  tag,
std::unique_ptr< Buffer recv_buffer 
)
pure virtual

Receives a message from a specific rank to a buffer. Use release_data to extract the data out of the buffer once the future is completed.

Parameters
rankThe source rank.
tagMessage tag for identification.
recv_bufferThe receive buffer.
Returns
A unique pointer to a Future representing the asynchronous operation.
Warning
The caller is responsible to ensure the underlying Buffer allocation is already valid before calling, for example, when a CUDA allocation and/or copy are done asynchronously. Specifically, the caller should ensure Buffer::is_ready() returns true before calling this function, if not, a warning is printed and the application will terminate.

Implemented in rapidsmpf::ucxx::UCXX, rapidsmpf::Single, and rapidsmpf::MPI.

◆ recv_any()

virtual std::pair<std::unique_ptr<std::vector<uint8_t> >, Rank> rapidsmpf::Communicator::recv_any ( Tag  tag)
pure virtual

Receives a message from any rank (blocking).

Parameters
tagMessage tag for identification.
Returns
A pair containing the message data (host memory) and the rank of the sender.
Note
If no message is available this is indicated by returning a nullptr in the first slot of the pair.

Implemented in rapidsmpf::ucxx::UCXX, rapidsmpf::Single, and rapidsmpf::MPI.

◆ recv_from()

virtual std::unique_ptr<std::vector<uint8_t> > rapidsmpf::Communicator::recv_from ( Rank  src,
Tag  tag 
)
pure virtual

Receives a message from a specific rank (blocking).

Parameters
srcThe source rank from which to receive the message.
tagMessage tag for identification.
Returns
A unique pointer to a vector containing the received message data (host memory).
Note
If no message is available, this function returns a nullptr.

Implemented in rapidsmpf::ucxx::UCXX, rapidsmpf::Single, and rapidsmpf::MPI.

◆ recv_sync_host_data()

virtual std::unique_ptr<Future> rapidsmpf::Communicator::recv_sync_host_data ( Rank  rank,
Tag  tag,
std::unique_ptr< std::vector< uint8_t >>  synced_buffer 
)
pure virtual

Receives a message from a specific rank to an allocated (synchronized) host buffer. Use release_sync_host_data to extract the data out of the buffer once the future is completed.

Parameters
rankThe source rank.
tagMessage tag for identification.
synced_bufferThe receive buffer.
Returns
A unique pointer to a Future representing the asynchronous operation.

Implemented in rapidsmpf::ucxx::UCXX, rapidsmpf::Single, and rapidsmpf::MPI.

◆ release_data()

virtual std::unique_ptr<Buffer> rapidsmpf::Communicator::release_data ( std::unique_ptr< Communicator::Future future)
pure virtual

Retrieves data associated with a completed future.

Parameters
futureThe completed future.
Returns
A unique pointer to the data buffer.
Exceptions
std::runtime_errorif the future has no data.

◆ release_sync_host_data()

virtual std::unique_ptr<std::vector<uint8_t> > rapidsmpf::Communicator::release_sync_host_data ( std::unique_ptr< Communicator::Future future)
pure virtual

Retrieves synchronized host data associated with a completed future. When the future is completed, the the host data is valid, and ready, but not stream-ordered.

Parameters
futureThe completed future.
Returns
A unique pointer to the synchronized host data.
Exceptions
std::runtime_errorif the future has no data.

◆ send() [1/2]

virtual std::unique_ptr<Future> rapidsmpf::Communicator::send ( std::unique_ptr< Buffer msg,
Rank  rank,
Tag  tag 
)
pure virtual

Sends a message (device or host) to a specific rank.

Parameters
msgUnique pointer to the message data (Buffer).
rankThe destination rank.
tagMessage tag for identification.
Returns
A unique pointer to a Future representing the asynchronous operation.
Warning
The caller is responsible to ensure the underlying Buffer allocation and data are already valid before calling, for example, when a CUDA allocation and/or copy are done asynchronously. Specifically, the caller should ensure Buffer::is_ready() returns true before calling this function, if not, a warning is printed and the application will terminate.

Implemented in rapidsmpf::ucxx::UCXX, rapidsmpf::Single, and rapidsmpf::MPI.

◆ send() [2/2]

virtual std::unique_ptr<Future> rapidsmpf::Communicator::send ( std::unique_ptr< std::vector< uint8_t >>  msg,
Rank  rank,
Tag  tag 
)
pure virtual

Sends a host message to a specific rank.

This is used to send data that resides in host memory and is guaranteed to be valid at the time of the call.

Parameters
msgUnique pointer to the message data (host memory).
rankThe destination rank.
tagMessage tag for identification.
Returns
A unique pointer to a Future representing the asynchronous operation.

Implemented in rapidsmpf::ucxx::UCXX, rapidsmpf::Single, and rapidsmpf::MPI.

◆ str()

virtual std::string rapidsmpf::Communicator::str ( ) const
pure virtual

Provides a string representation of the communicator.

Returns
A string describing the communicator.

Implemented in rapidsmpf::ucxx::UCXX, rapidsmpf::Single, and rapidsmpf::MPI.

◆ test_some() [1/2]

virtual std::vector<std::size_t> rapidsmpf::Communicator::test_some ( std::unordered_map< std::size_t, std::unique_ptr< Communicator::Future >> const &  future_map)
pure virtual

Tests for completion of multiple futures in a map.

Parameters
future_mapMap of futures identified by keys.
Returns
Keys of completed futures.

◆ test_some() [2/2]

virtual std:: pair<std::vector<std::unique_ptr<Future> >, std::vector<std::size_t> > rapidsmpf::Communicator::test_some ( std::vector< std::unique_ptr< Future >> &  future_vector)
pure virtual

Tests for completion of multiple futures.

Parameters
[in,out]future_vectorVector of Future objects. Completed futures are erased from the vector.
Returns
Pair of completed futures and indices of input vector that were completed.

◆ wait()

virtual std::unique_ptr<Buffer> rapidsmpf::Communicator::wait ( std::unique_ptr< Future future)
pure virtual

Wait for a future to complete and return the data buffer.

Parameters
futureThe future to wait for completion of.
Returns
A unique pointer to the GPU data buffer (or nullptr if the future had no data).

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