8 #include <unordered_set>
10 #include <rapidsmpf/shuffler/shuffler.hpp>
11 #include <rapidsmpf/streaming/core/channel.hpp>
12 #include <rapidsmpf/streaming/core/context.hpp>
13 #include <rapidsmpf/streaming/core/node.hpp>
14 #include <rapidsmpf/streaming/cudf/partition.hpp>
67 std::shared_ptr<Context>
ctx,
85 [[nodiscard]] constexpr std::shared_ptr<
Context> const&
ctx()
const {
112 void insert(std::unordered_map<shuffler::PartID, PackedData>&& chunks);
149 [[nodiscard]] coro::task<std::optional<std::vector<PackedData>>>
extract_async(
192 [[nodiscard]]
Node finished_drain();
194 std::shared_ptr<Context> ctx_;
195 coro::task_container<coro::thread_pool>
210 std::unordered_set<shuffler::PartID> ready_pids_;
211 std::unordered_set<shuffler::PartID> extracted_pids_;
236 std::shared_ptr<Context> ctx,
237 std::shared_ptr<Channel> ch_in,
238 std::shared_ptr<Channel> ch_out,
Shuffle service for cuDF tables.
static Rank round_robin(std::shared_ptr< Communicator > const &comm, PartID pid)
A PartitionOwner that distribute the partition using round robin.
PartID const total_num_partitions
Total number of partition in the shuffle.
std::function< Rank(std::shared_ptr< Communicator >, PartID)> PartitionOwner
Function that given a Communicator and a PartID, returns the rapidsmpf::Rank of the owning node.
PartitionOwner const partition_owner
Function to determine partition ownership.
Context for nodes (coroutines) in rapidsmpf.
An asynchronous shuffler that allows concurrent insertion and extraction of data.
constexpr std::shared_ptr< Context > const & ctx() const
Gets the streaming context associated with this shuffler.
ShufflerAsync(std::shared_ptr< Context > ctx, OpID op_id, shuffler::PartID total_num_partitions, shuffler::Shuffler::PartitionOwner partition_owner=shuffler::Shuffler::round_robin)
Constructs a new ShufflerAsync instance.
constexpr shuffler::Shuffler::PartitionOwner const & partition_owner() const
Gets the partition owner function used by this shuffler.
coro::task< std::optional< ExtractResult > > extract_any_async()
Asynchronously extracts data for any ready partition.
Node insert_finished(std::vector< shuffler::PartID > &&pids)
Insert a finish mark for a list of partitions.
constexpr shuffler::PartID total_num_partitions() const
Gets the total number of partitions for this shuffle operation.
void insert(std::unordered_map< shuffler::PartID, PackedData > &&chunks)
Insert a bunch of packed (serialized) chunks into the shuffle.
std::pair< shuffler::PartID, std::vector< PackedData > > ExtractResult
Result type for extract_any_async operations.
std::span< shuffler::PartID const > local_partitions() const
Returns the local partition IDs owned by the current node.
coro::task< std::optional< std::vector< PackedData > > > extract_async(shuffler::PartID pid)
Asynchronously extracts all data for a specific partition.
std::uint32_t PartID
Partition ID, which goes from 0 to the total number of partitions.
Node shuffler(std::shared_ptr< Context > ctx, std::shared_ptr< Channel > ch_in, std::shared_ptr< Channel > ch_out, OpID op_id, shuffler::PartID total_num_partitions, shuffler::Shuffler::PartitionOwner partition_owner=shuffler::Shuffler::round_robin)
Launches a shuffler node for a single shuffle operation.
coro::task< void > Node
Alias for a node in a streaming pipeline.
coro::semaphore< std::numeric_limits< std::ptrdiff_t >::max()> Semaphore
An awaitable semaphore to manage acquisition and release of finite resources.