All Classes Namespaces Functions Variables Typedefs Enumerations Friends
context.h
1 
5 #pragma once
6 
7 #include <cstdint>
8 #include <cstring>
9 #include <memory>
10 #include <string>
11 
12 #include <ucp/api/ucp.h>
13 
14 #include <ucxx/component.h>
15 #include <ucxx/config.h>
16 #include <ucxx/constructors.h>
17 
18 namespace ucxx {
19 
20 class MemoryHandle;
21 class Worker;
22 
29 class Context : public Component {
30  private:
31  ucp_context_h _handle{nullptr};
32  Config _config{{}};
33  uint64_t _featureFlags{0};
34  bool _cudaSupport{false};
35 
46  Context(const ConfigMap ucxConfig, const uint64_t featureFlags);
47 
48  public:
49  static constexpr uint64_t defaultFeatureFlags =
50  UCP_FEATURE_TAG | UCP_FEATURE_WAKEUP | UCP_FEATURE_STREAM | UCP_FEATURE_AM |
51  UCP_FEATURE_RMA;
52 
53  Context() = delete;
54  Context(const Context&) = delete;
55  Context& operator=(Context const&) = delete;
56  Context(Context&& o) = delete;
57  Context& operator=(Context&& o) = delete;
58 
75  [[nodiscard]] friend std::shared_ptr<Context> createContext(ConfigMap ucxConfig,
76  const uint64_t featureFlags);
77 
82 
96  [[nodiscard]] ConfigMap getConfig();
97 
113  [[nodiscard]] ucp_context_h getHandle();
114 
129  [[nodiscard]] std::string getInfo();
130 
145  [[nodiscard]] uint64_t getFeatureFlags() const;
146 
161  [[nodiscard]] bool hasCudaSupport() const;
162 
181  [[nodiscard]] std::shared_ptr<Worker> createWorker(const bool enableDelayedSubmission = false,
182  const bool enableFuture = false);
183 
221  [[nodiscard]] std::shared_ptr<MemoryHandle> createMemoryHandle(
222  const size_t size, void* buffer, const ucs_memory_type_t memoryType = UCS_MEMORY_TYPE_HOST);
223 };
224 
225 } // namespace ucxx
A UCXX component class to prevent early destruction of parent object.
Definition: component.h:17
Component encapsulating the UCP configuration.
Definition: config.h:19
Component encapsulating the UCP context.
Definition: context.h:29
std::string getInfo()
Get information from UCP context.
friend std::shared_ptr< Context > createContext(ConfigMap ucxConfig, const uint64_t featureFlags)
Constructor of shared_ptr<ucxx::Context>.
std::shared_ptr< MemoryHandle > createMemoryHandle(const size_t size, void *buffer, const ucs_memory_type_t memoryType=UCS_MEMORY_TYPE_HOST)
Create a new std::shared_ptr<ucxx::memoryHandle>.
ConfigMap getConfig()
Get the context configuration.
bool hasCudaSupport() const
Query whether CUDA support is available.
~Context()
ucxx::Context destructor
ucp_context_h getHandle()
Get the underlying ucp_context_h handle.
uint64_t getFeatureFlags() const
Get feature flags that were used to construct the UCP context.
static constexpr uint64_t defaultFeatureFlags
Suggested default context feature flags to use.
Definition: context.h:49
std::shared_ptr< Worker > createWorker(const bool enableDelayedSubmission=false, const bool enableFuture=false)
Create a new ucxx::Worker.
Definition: address.h:15
std::unordered_map< std::string, std::string > ConfigMap
A UCP configuration map.
Definition: typedefs.h:81