backend.hpp
1 
6 #pragma once
7 
8 #include <cstddef>
9 #include <string>
10 #include <string_view>
11 
12 #include <rapidsmpf/bootstrap/types.hpp>
13 
15 
19 enum class BackendType {
29  AUTO,
30 
38  FILE,
39 
52  SOCKET,
53 
68  SLURM,
69 };
70 
71 namespace detail {
72 
80 class Backend {
81  public:
82  virtual ~Backend() = default;
83 
97  virtual void put(std::string const& key, std::string_view value) = 0;
98 
111  virtual std::string get(std::string const& key, Duration timeout) = 0;
112 
118  virtual void barrier() = 0;
119 
123  virtual void sync() = 0;
124 
125  // Non-copyable, non-movable (backends manage resources)
126  Backend(Backend const&) = delete;
127  Backend& operator=(Backend const&) = delete;
128  Backend(Backend&&) = delete;
129  Backend& operator=(Backend&&) = delete;
130 
131  protected:
132  Backend() = default;
133 };
134 
135 } // namespace detail
136 } // namespace rapidsmpf::bootstrap
Abstract interface for bootstrap coordination backends.
Definition: backend.hpp:80
virtual void put(std::string const &key, std::string_view value)=0
Store a key-value pair (rank 0 only).
virtual void barrier()=0
Perform a barrier synchronization.
virtual void sync()=0
Ensure all previous put() operations are globally visible.
virtual std::string get(std::string const &key, Duration timeout)=0
Retrieve a value, blocking until available or timeout occurs.
BackendType
Backend types for process coordination and bootstrapping.
Definition: backend.hpp:19
@ SOCKET
Socket-based coordination using an in-process TCP server (rrun-hosted).
@ FILE
File-based coordination using a shared directory.
@ AUTO
Automatically detect the best backend based on environment.
@ SLURM
Slurm-based coordination using PMIx.
std::chrono::duration< double > Duration
Type alias for Duration type.
Definition: types.hpp:17