15 #include <rapidsmpf/communicator/communicator.hpp>
16 #include <rapidsmpf/error.hpp>
32 void init(
int* argc,
char*** argv);
49 #define RAPIDSMPF_MPI(call) \
50 rapidsmpf::mpi::detail::check_mpi_error((call), __FILE__, __LINE__)
60 void check_mpi_error(
int error_code,
const char* file,
int line);
90 Future(MPI_Request req, std::unique_ptr<Buffer> data_buffer)
91 : req_{req}, data_buffer_{std::move(data_buffer)} {}
102 Future(MPI_Request req, std::unique_ptr<std::vector<uint8_t>> synced_host_data)
103 : req_{std::move(req)}, synced_host_data_{std::move(synced_host_data)} {}
105 ~
Future() noexcept override = default;
111 std::unique_ptr<
Buffer> data_buffer_;
113 std::unique_ptr<std::vector<uint8_t>> synced_host_data_;
122 MPI(MPI_Comm comm, config::Options options);
124 ~
MPI() noexcept override = default;
129 [[nodiscard]] Rank
rank()
const override {
136 [[nodiscard]] Rank
nranks()
const override {
143 [[nodiscard]] std::unique_ptr<Communicator::Future>
send(
144 std::unique_ptr<std::vector<uint8_t>> msg, Rank
rank,
Tag tag
152 [[nodiscard]] std::unique_ptr<Communicator::Future>
send(
153 std::unique_ptr<Buffer> msg, Rank
rank,
Tag tag
159 [[nodiscard]] std::unique_ptr<Communicator::Future>
recv(
160 Rank
rank,
Tag tag, std::unique_ptr<Buffer> recv_buffer
169 Rank
rank,
Tag tag, std::unique_ptr<std::vector<uint8_t>> synced_buffer
175 [[nodiscard]] std::pair<std::unique_ptr<std::vector<uint8_t>>, Rank>
recv_any(
182 [[nodiscard]] std::unique_ptr<std::vector<uint8_t>>
recv_from(
189 std::vector<std::unique_ptr<Communicator::Future>>,
190 std::vector<std::size_t>>
191 test_some(std::vector<std::unique_ptr<Communicator::Future>>& future_vector)
override;
199 std::unordered_map<std::size_t, std::unique_ptr<Communicator::Future>>
const&
206 [[nodiscard]] std::unique_ptr<Buffer>
wait(
207 std::unique_ptr<Communicator::Future> future
214 std::unique_ptr<Communicator::Future> future
221 std::unique_ptr<Communicator::Future> future
234 [[nodiscard]] std::string
str()
const override;
Buffer representing device or host memory.
Abstract base class for asynchronous operation within the communicator.
A logger base class for handling different levels of log messages.
Abstract base class for a communication mechanism between nodes.
Represents the future result of an MPI operation.
Future(MPI_Request req, std::unique_ptr< std::vector< uint8_t >> synced_host_data)
Construct a Future from synchronized host data.
Future(MPI_Request req, std::unique_ptr< Buffer > data_buffer)
Construct a Future from a data buffer.
MPI communicator class that implements the Communicator interface.
std::vector< std::size_t > test_some(std::unordered_map< std::size_t, std::unique_ptr< Communicator::Future >> const &future_map) override
Tests for completion of multiple futures in a map.
std::unique_ptr< Communicator::Future > recv_sync_host_data(Rank rank, Tag tag, std::unique_ptr< std::vector< uint8_t >> synced_buffer) override
Receives a message from a specific rank to an allocated (synchronized) host buffer....
std::unique_ptr< Buffer > wait(std::unique_ptr< Communicator::Future > future) override
Wait for a future to complete and return the data buffer.
std::pair< std::vector< std::unique_ptr< Communicator::Future > >, std::vector< std::size_t > > test_some(std::vector< std::unique_ptr< Communicator::Future >> &future_vector) override
Tests for completion of multiple futures.
std::unique_ptr< Communicator::Future > send(std::unique_ptr< Buffer > msg, Rank rank, Tag tag) override
Sends a message (device or host) to a specific rank.
std::pair< std::unique_ptr< std::vector< uint8_t > >, Rank > recv_any(Tag tag) override
Receives a message from any rank (blocking).
Logger & logger() override
Retrieves the logger associated with this communicator.
Rank nranks() const override
Retrieves the total number of ranks.
Rank rank() const override
Retrieves the rank of the current node.
std::unique_ptr< Communicator::Future > send(std::unique_ptr< std::vector< uint8_t >> msg, Rank rank, Tag tag) override
Sends a host message to a specific rank.
std::unique_ptr< std::vector< uint8_t > > recv_from(Rank src, Tag tag) override
Receives a message from a specific rank (blocking).
std::unique_ptr< std::vector< uint8_t > > release_sync_host_data(std::unique_ptr< Communicator::Future > future) override
Retrieves synchronized host data associated with a completed future. When the future is completed,...
std::string str() const override
Provides a string representation of the communicator.
std::unique_ptr< Communicator::Future > recv(Rank rank, Tag tag, std::unique_ptr< Buffer > recv_buffer) override
Receives a message from a specific rank to a buffer. Use release_data to extract the data out of the ...
std::unique_ptr< Buffer > release_data(std::unique_ptr< Communicator::Future > future) override
Retrieves data associated with a completed future.
A tag used for identifying messages in a communication operation.
void init(int *argc, char ***argv)
Helper to initialize MPI with threading support.
bool is_initialized()
Check if MPI is initialized.