Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions
xgboost::collective::Communicator Class Referenceabstract

A communicator class that handles collective communication. More...

#include <communicator.h>

Inheritance diagram for xgboost::collective::Communicator:
xgboost::collective::FederatedCommunicator xgboost::collective::InMemoryCommunicator xgboost::collective::NoOpCommunicator xgboost::collective::RabitCommunicator

Public Member Functions

int GetWorldSize () const
 Get the total number of processes.
 
int GetRank () const
 Get the rank of the current processes.
 
virtual bool IsDistributed () const =0
 Whether the communicator is running in distributed mode.
 
virtual bool IsFederated () const =0
 Whether the communicator is running in federated mode.
 
virtual void AllGather (void *send_receive_buffer, std::size_t size)=0
 Gathers data from all processes and distributes it to all processes.
 
virtual void AllReduce (void *send_receive_buffer, std::size_t count, DataType data_type, Operation op)=0
 Combines values from all processes and distributes the result back to all processes.
 
virtual void Broadcast (void *send_receive_buffer, std::size_t size, int root)=0
 Broadcasts a message from the process with rank root to all other processes of the group.
 
virtual std::string GetProcessorName ()=0
 Gets the name of the processor.
 
virtual void Print (std::string const &message)=0
 Prints the message.
 

Static Public Member Functions

static void Init (Json const &config)
 Initialize the communicator.
 
static void Finalize ()
 Finalize the communicator.
 
static CommunicatorGet ()
 Get the communicator instance.
 
static CommunicatorType GetTypeFromEnv ()
 Get the communicator type from environment variables.
 
static CommunicatorType GetTypeFromConfig (Json const &config)
 Get the communicator type from runtime configuration.
 

Protected Member Functions

 Communicator (int world_size, int rank)
 Construct a new communicator.
 
virtual void Shutdown ()=0
 Shuts down the communicator.
 

Detailed Description

A communicator class that handles collective communication.

Constructor & Destructor Documentation

◆ Communicator()

xgboost::collective::Communicator::Communicator ( int  world_size,
int  rank 
)
inlineprotected

Construct a new communicator.

Parameters
world_sizeTotal number of processes.
rankRank of the current process.

Member Function Documentation

◆ AllGather()

virtual void xgboost::collective::Communicator::AllGather ( void *  send_receive_buffer,
std::size_t  size 
)
pure virtual

Gathers data from all processes and distributes it to all processes.

This assumes all ranks have the same size, and input data has been sliced into the corresponding position.

Parameters
send_receive_bufferBuffer storing the data.
sizeSize of the data in bytes.

Implemented in xgboost::collective::NoOpCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::FederatedCommunicator, and xgboost::collective::RabitCommunicator.

◆ AllReduce()

virtual void xgboost::collective::Communicator::AllReduce ( void *  send_receive_buffer,
std::size_t  count,
DataType  data_type,
Operation  op 
)
pure virtual

Combines values from all processes and distributes the result back to all processes.

Parameters
send_receive_bufferBuffer storing the data.
countNumber of elements in the buffer.
data_typeData type stored in the buffer.
opThe operation to perform.

Implemented in xgboost::collective::NoOpCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::FederatedCommunicator, and xgboost::collective::RabitCommunicator.

◆ Broadcast()

virtual void xgboost::collective::Communicator::Broadcast ( void *  send_receive_buffer,
std::size_t  size,
int  root 
)
pure virtual

Broadcasts a message from the process with rank root to all other processes of the group.

Parameters
send_receive_bufferBuffer storing the data.
sizeSize of the data in bytes.
rootRank of broadcast root.

Implemented in xgboost::collective::NoOpCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::FederatedCommunicator, and xgboost::collective::RabitCommunicator.

◆ GetProcessorName()

virtual std::string xgboost::collective::Communicator::GetProcessorName ( )
pure virtual

◆ GetTypeFromConfig()

static CommunicatorType xgboost::collective::Communicator::GetTypeFromConfig ( Json const &  config)
inlinestatic

Get the communicator type from runtime configuration.

Visible for testing.

◆ GetTypeFromEnv()

static CommunicatorType xgboost::collective::Communicator::GetTypeFromEnv ( )
inlinestatic

Get the communicator type from environment variables.

Visible for testing.

◆ Init()

void xgboost::collective::Communicator::Init ( Json const &  config)
static

Initialize the communicator.

This can only be done once.

Parameters
configJSON configuration for the communicator.

◆ IsDistributed()

virtual bool xgboost::collective::Communicator::IsDistributed ( ) const
pure virtual

◆ IsFederated()

virtual bool xgboost::collective::Communicator::IsFederated ( ) const
pure virtual

◆ Print()

virtual void xgboost::collective::Communicator::Print ( std::string const &  message)
pure virtual

◆ Shutdown()

virtual void xgboost::collective::Communicator::Shutdown ( )
protectedpure virtual

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