Medial Code Documentation
|
A communicator class that handles collective communication. More...
#include <communicator.h>
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 Communicator * | Get () |
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. | |
A communicator class that handles collective communication.
|
inlineprotected |
Construct a new communicator.
world_size | Total number of processes. |
rank | Rank of the current process. |
|
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.
send_receive_buffer | Buffer storing the data. |
size | Size of the data in bytes. |
Implemented in xgboost::collective::NoOpCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::FederatedCommunicator, and xgboost::collective::RabitCommunicator.
|
pure virtual |
Combines values from all processes and distributes the result back to all processes.
send_receive_buffer | Buffer storing the data. |
count | Number of elements in the buffer. |
data_type | Data type stored in the buffer. |
op | The operation to perform. |
Implemented in xgboost::collective::NoOpCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::FederatedCommunicator, and xgboost::collective::RabitCommunicator.
|
pure virtual |
Broadcasts a message from the process with rank root
to all other processes of the group.
send_receive_buffer | Buffer storing the data. |
size | Size of the data in bytes. |
root | Rank of broadcast root. |
Implemented in xgboost::collective::NoOpCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::FederatedCommunicator, and xgboost::collective::RabitCommunicator.
|
pure virtual |
Gets the name of the processor.
Implemented in xgboost::collective::FederatedCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::NoOpCommunicator, and xgboost::collective::RabitCommunicator.
|
inlinestatic |
Get the communicator type from runtime configuration.
Visible for testing.
|
inlinestatic |
Get the communicator type from environment variables.
Visible for testing.
|
static |
Initialize the communicator.
This can only be done once.
config | JSON configuration for the communicator. |
|
pure virtual |
Whether the communicator is running in distributed mode.
Implemented in xgboost::collective::FederatedCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::NoOpCommunicator, and xgboost::collective::RabitCommunicator.
|
pure virtual |
Whether the communicator is running in federated mode.
Implemented in xgboost::collective::FederatedCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::NoOpCommunicator, and xgboost::collective::RabitCommunicator.
|
pure virtual |
Prints the message.
Implemented in xgboost::collective::FederatedCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::NoOpCommunicator, and xgboost::collective::RabitCommunicator.
|
protectedpure virtual |
Shuts down the communicator.
Implemented in xgboost::collective::FederatedCommunicator, xgboost::collective::InMemoryCommunicator, xgboost::collective::NoOpCommunicator, and xgboost::collective::RabitCommunicator.