bootstrap.hpp
1 
6 #pragma once
7 
8 #include <chrono>
9 #include <memory>
10 #include <optional>
11 #include <string>
12 
13 #include <rapidsmpf/bootstrap/backend.hpp>
14 #include <rapidsmpf/bootstrap/types.hpp>
15 
16 namespace rapidsmpf::bootstrap {
17 
24 struct Context {
27 
30 
33 
35  std::optional<std::string> coord_dir;
36 
38  std::shared_ptr<detail::Backend> backend;
39 };
40 
62 
70 void barrier(Context const& ctx);
71 
84 void sync(Context const& ctx);
85 
99 void put(Context const& ctx, std::string const& key, std::string const& value);
100 
114 std::string get(
115  Context const& ctx,
116  std::string const& key,
117  Duration timeout = std::chrono::seconds{30}
118 );
119 
120 } // namespace rapidsmpf::bootstrap
void put(Context const &ctx, std::string const &key, std::string const &value)
Store a key-value pair in the coordination backend (rank 0 only).
std::string get(Context const &ctx, std::string const &key, Duration timeout=std::chrono::seconds{30})
Retrieve a value from the coordination backend.
Context init(BackendType type=BackendType::AUTO)
Initialize the bootstrap context from environment variables.
std::int32_t Rank
Type alias for communicator::Rank.
Definition: types.hpp:14
void barrier(Context const &ctx)
Perform a barrier synchronization across all ranks.
BackendType
Backend types for process coordination and bootstrapping.
Definition: backend.hpp:18
@ AUTO
Automatically detect the best backend based on environment.
std::chrono::duration< double > Duration
Type alias for Duration type.
Definition: types.hpp:17
void sync(Context const &ctx)
Ensure all previous put() operations are globally visible.
Context information for the current process/rank.
Definition: bootstrap.hpp:24
std::optional< std::string > coord_dir
Coordination directory (for FILE backend).
Definition: bootstrap.hpp:35
Rank nranks
Total number of ranks in the job.
Definition: bootstrap.hpp:29
std::shared_ptr< detail::Backend > backend
Backend implementation (internal, do not access directly).
Definition: bootstrap.hpp:38
BackendType type
Backend type used for coordination.
Definition: bootstrap.hpp:32
Rank rank
This process's rank (0-indexed).
Definition: bootstrap.hpp:26