bootstrap.hpp
1 
6 #pragma once
7 
8 #include <chrono>
9 #include <memory>
10 #include <optional>
11 #include <string>
12 #include <string_view>
13 
14 #include <rapidsmpf/bootstrap/backend.hpp>
15 #include <rapidsmpf/bootstrap/types.hpp>
16 
17 namespace rapidsmpf::bootstrap {
18 
25 struct Context {
28 
31 
34 
36  std::optional<std::string> coord_dir;
37 
39  std::shared_ptr<detail::Backend> backend;
40 };
41 
63 
71 void barrier(Context const& ctx);
72 
85 void sync(Context const& ctx);
86 
100 void put(Context const& ctx, std::string const& key, std::string_view value);
101 
115 std::string get(
116  Context const& ctx,
117  std::string const& key,
118  Duration timeout = std::chrono::seconds{30}
119 );
120 
121 } // namespace rapidsmpf::bootstrap
std::string get(Context const &ctx, std::string const &key, Duration timeout=std::chrono::seconds{30})
Retrieve a value from the coordination backend.
void put(Context const &ctx, std::string const &key, std::string_view value)
Store a key-value pair in the coordination backend (rank 0 only).
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:19
@ 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:25
std::optional< std::string > coord_dir
Coordination directory (for FILE backend).
Definition: bootstrap.hpp:36
Rank nranks
Total number of ranks in the job.
Definition: bootstrap.hpp:30
std::shared_ptr< detail::Backend > backend
Backend implementation (internal, do not access directly).
Definition: bootstrap.hpp:39
BackendType type
Backend type used for coordination.
Definition: bootstrap.hpp:33
Rank rank
This process's rank (0-indexed).
Definition: bootstrap.hpp:27