Loading...
Searching...
No Matches
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/context_builder.h>
17#include <ucxx/memory_handle_builder.h>
18#include <ucxx/worker_builder.h>
19
20namespace ucxx {
21
22class ContextBuilder;
23
24class MemoryHandle;
25class Worker;
26
35class Context : public Component {
36 private:
37 ucp_context_h _handle{nullptr};
38 Config _config{{}};
39 uint64_t _featureFlags{0};
40 bool _cudaSupport{false};
41
54 Context(const ConfigMap ucxConfig, const uint64_t featureFlags);
55
56 public:
57 static constexpr uint64_t defaultFeatureFlags =
58 UCP_FEATURE_TAG | UCP_FEATURE_WAKEUP | UCP_FEATURE_STREAM | UCP_FEATURE_AM |
59 UCP_FEATURE_RMA;
60
61 Context() = delete;
62 Context(const Context&) = delete;
63 Context& operator=(Context const&) = delete;
64 Context(Context&& o) = delete;
65 Context& operator=(Context&& o) = delete;
66
67 // Allow internal construction without exposing factory functions.
68 friend class detail::ConstructorFactory;
69
73 friend class ContextBuilder;
74
79
93 [[nodiscard]] ConfigMap getConfig();
94
110 [[nodiscard]] ucp_context_h getHandle();
111
126 [[nodiscard]] std::string getInfo();
127
142 [[nodiscard]] uint64_t getFeatureFlags() const;
143
158 [[nodiscard]] bool hasCudaSupport() const;
159
169
179 [[nodiscard]] MemoryHandleBuilder memoryHandleBuilder(size_t size);
180};
181
182} // namespace ucxx
A UCXX component class to prevent early destruction of parent object.
Definition component.h:21
Component encapsulating the UCP configuration.
Definition config.h:19
Builder class for constructing std::shared_ptr<ucxx::Context> objects.
Definition context_builder.h:43
WorkerBuilder workerBuilder()
Create a builder for a new ucxx::Worker.
std::string getInfo()
Get information from UCP context.
friend class ContextBuilder
Allow ContextBuilder to access private constructor.
Definition context.h:73
ConfigMap getConfig()
Get the context configuration.
MemoryHandleBuilder memoryHandleBuilder(size_t size)
Create a builder for a new ucxx::MemoryHandle.
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:57
Builder class for constructing std::shared_ptr<ucxx::MemoryHandle> objects.
Definition memory_handle_builder.h:25
Component holding a UCP memory handle.
Definition memory_handle.h:28
Builder class for constructing std::shared_ptr<ucxx::Worker> objects.
Definition worker_builder.h:45
Component encapsulating a UCP worker.
Definition worker.h:62
Definition address.h:16
std::unordered_map< std::string, std::string > ConfigMap
A UCP configuration map.
Definition typedefs.h:89