10 #include <unordered_map>
13 #include <rapidsmpf/communicator/communicator.hpp>
14 #include <rapidsmpf/config.hpp>
15 #include <rapidsmpf/memory/buffer.hpp>
16 #include <rapidsmpf/memory/buffer_resource.hpp>
17 #include <rapidsmpf/progress_thread.hpp>
40 ~
Future() noexcept
override =
default;
54 ~
Single() noexcept override = default;
59 [[nodiscard]] constexpr
Rank rank()
const override {
73 [[nodiscard]] std::unique_ptr<Communicator::Future>
send(
74 std::unique_ptr<std::vector<std::uint8_t>> msg,
Rank rank,
Tag tag
84 [[nodiscard]] std::unique_ptr<Communicator::Future>
send(
94 [[nodiscard]] std::unique_ptr<Communicator::Future>
recv(
95 Rank rank,
Tag tag, std::unique_ptr<Buffer> recv_buffer
107 Rank rank,
Tag tag, std::unique_ptr<std::vector<std::uint8_t>> synced_buffer
116 [[nodiscard]] std::pair<std::unique_ptr<std::vector<std::uint8_t>>,
Rank>
recv_any(
126 [[nodiscard]] std::unique_ptr<std::vector<std::uint8_t>>
recv_from(
137 std::vector<std::unique_ptr<Communicator::Future>>,
138 std::vector<std::size_t>>
139 test_some(std::vector<std::unique_ptr<Communicator::Future>>& future_vector)
override;
149 std::unordered_map<std::size_t, std::unique_ptr<Communicator::Future>>
const&
154 bool test(std::unique_ptr<Communicator::Future>& future)
override;
157 std::vector<std::unique_ptr<Communicator::Future>>&& futures
166 [[nodiscard]] std::unique_ptr<Buffer>
wait(
167 std::unique_ptr<Communicator::Future> future
177 std::unique_ptr<Communicator::Future> future
187 std::unique_ptr<Communicator::Future> future
193 [[nodiscard]] std::shared_ptr<Logger>
const&
logger()
override {
200 [[nodiscard]] std::shared_ptr<ProgressThread>
const&
202 return progress_thread_;
208 [[nodiscard]] std::string
str()
const override;
211 std::shared_ptr<Logger> logger_;
212 std::shared_ptr<ProgressThread> progress_thread_;
Abstract base class for asynchronous operation within the communicator.
Abstract base class for a communication mechanism between nodes.
Represents the future result of an operation.
Single process communicator class that implements the Communicator interface.
std::string str() const override
Provides a string representation of the communicator.
std::unique_ptr< Communicator::Future > recv_sync_host_data(Rank rank, Tag tag, std::unique_ptr< std::vector< std::uint8_t >> synced_buffer) override
Receives a message from a specific rank to an allocated (synchronized) host buffer....
std::shared_ptr< Logger > const & logger() override
Retrieves the logger associated with this communicator.
constexpr Rank rank() const override
Retrieves the rank of the current node.
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::vector< std::unique_ptr< Buffer > > wait_all(std::vector< std::unique_ptr< Communicator::Future >> &&futures) override
Wait for completion of all futures and return their data buffers.
bool test(std::unique_ptr< Communicator::Future > &future) override
Test for completion of a single future.
constexpr Rank nranks() const override
Retrieves the total number of ranks.
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< std::vector< std::uint8_t > > recv_from(Rank src, Tag tag) override
Receives a message from a specific rank (blocking).
std::unique_ptr< Buffer > wait(std::unique_ptr< Communicator::Future > future) override
Wait for a future to complete and return the data buffer.
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< Buffer > release_data(std::unique_ptr< Communicator::Future > future) override
Retrieves data associated with a completed future.
std::unique_ptr< Communicator::Future > send(std::unique_ptr< std::vector< std::uint8_t >> msg, Rank rank, Tag tag) override
Sends a host message to a specific rank.
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. Use release_data to obtain the data buffer again...
Single(std::shared_ptr< ProgressThread > progress_thread, std::shared_ptr< Logger > logger)
Construct a single process communicator.
std::unique_ptr< std::vector< std::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::shared_ptr< ProgressThread > const & progress_thread() const override
Retrieves the progress thread associated with this communicator.
std::pair< std::unique_ptr< std::vector< std::uint8_t > >, Rank > recv_any(Tag tag) override
Receives a message from any rank (blocking).
A tag used for identifying messages in a communication operation.
RAPIDS Multi-Processor interfaces.
std::int32_t Rank
The rank of a node (e.g. the rank of a MPI process), or world size (total number of ranks).