7 #ifndef CUDA_API_WRAPPERS_NODE_HPP 8 #define CUDA_API_WRAPPERS_NODE_HPP 10 #if CUDA_VERSION >= 10000 12 #include "../types.hpp" 31 ::std::string identify(
const node_t &node);
35 handle_t * __restrict__ dependency_handles,
38 #if CUDA_VERSION >= 13000 39 static constexpr
auto no_edge_data {
nullptr };
40 return cuGraphNodeGetDependencies(handle, dependency_handles, no_edge_data, num_dependencies);
42 return cuGraphNodeGetDependencies(handle, dependency_handles, num_dependencies);
48 handle_t * __restrict__ dependent_handles,
51 #if CUDA_VERSION >= 13000 52 static constexpr
auto no_edge_data {
nullptr };
53 return cuGraphNodeGetDependentNodes(handle, dependent_handles, no_edge_data, num_dependencies);
55 return cuGraphNodeGetDependentNodes(handle, dependent_handles, num_dependencies);
59 #if CUDA_VERSION >= 13010 63 auto status = cuGraphNodeGetContainingGraph(handle, &graph_template_handle);
64 throw_if_error_lazy(status,
"Failed obtaining the graph template containing " + graph::node::detail_::identify(handle));
65 return graph_template_handle;
71 auto status = cuGraphNodeGetLocalId(handle, &
id);
75 #endif // CUDA_VERSION >= 13010 79 using type_t = CUgraphNodeType;
99 using dependencies_type = ::std::vector<node_t>;
100 using dependents_type = ::std::vector<node_t>;
106 handle_type handle() const noexcept {
return handle_; }
107 template_t containing_graph() const noexcept;
108 template_::
handle_t containing_graph_handle() const noexcept {
return graph_template_handle_; }
109 type_type type_()
const 112 auto status = cuGraphNodeGetType(handle_, &result);
117 size_t num_dependencies()
const 119 size_t num_dependencies_;
120 static constexpr
auto no_returned_handles =
nullptr;
121 auto status = node::detail_::get_dependencies(handle_, no_returned_handles, &num_dependencies_);
122 throw_if_error_lazy(status,
"Obtaining the number of nodes on which " + node::detail_::identify(*
this) +
" is dependent");
123 return num_dependencies_;
126 size_t num_dependents()
const 128 size_t num_dependents_;
129 static constexpr
auto no_returned_handles =
nullptr;
130 auto status = node::detail_::get_dependents(handle_, no_returned_handles, &num_dependents_);
131 throw_if_error_lazy(status,
"Obtaining the number of nodes dependent on " + node::detail_::identify(*
this));
132 return num_dependents_;
135 dependencies_type dependencies()
const 137 size_type num_dependencies_ { num_dependencies() } ;
138 ::std::vector<node::handle_t> node_handles {num_dependencies_ };
139 auto status = node::detail_::get_dependencies(handle_, node_handles.data(), &num_dependencies_);
140 throw_if_error_lazy(status,
"Obtaining the set nodes on which " + node::detail_::identify(*
this) +
" is dependent");
141 dependencies_type result;
142 for (
const auto& node_handle : node_handles) {
143 result.emplace_back(
node::wrap(graph_template_handle_, node_handle));
148 dependencies_type dependents()
const 150 size_type num_dependents_ { num_dependents() } ;
151 ::std::vector<node::handle_t> node_handles {num_dependents_ };
152 auto status = node::detail_::get_dependents(handle_, node_handles.data(), &num_dependents_);
153 throw_if_error_lazy(status,
"Obtaining the set nodes dependent on " + node::detail_::identify(*
this));
154 dependencies_type result;
155 for (
const auto& node_handle : node_handles) {
156 result.emplace_back(
node::wrap(graph_template_handle_, node_handle));
161 #if CUDA_VERSION >= 13010 162 id_t get_id()
const {
return node::detail_::get_id(handle_); }
168 #endif // CUDA_VERSION >= 13010 172 : graph_template_handle_(graph_template_handle), handle_(handle) { }
178 node_t(
const node_t&) noexcept =
default;
179 node_t(node_t&&) noexcept = default;
181 node_t& operator=(node_t other) noexcept
183 graph_template_handle_ = other.graph_template_handle_;
184 handle_ = other.handle_;
197 return { graph_handle, handle };
200 #if CUDA_VERSION >= 13010 204 inline node_t from_handle(
handle_t handle)
206 auto graph_template_handle = graph_handle_of(handle);
207 return wrap(graph_template_handle, handle);
211 #endif // CUDA_VERSION >= 13010 219 #endif // CUDA_VERSION >= 10000 221 #endif //CUDA_API_WRAPPERS_NODE_HPP Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
CUdevice id_t
Numeric ID of a CUDA device used by the CUDA Runtime API.
Definition: types.hpp:852
::std::size_t size_t
A size type for use throughout the wrappers library (except when specific API functions limit the siz...
Definition: types.hpp:78
#define throw_if_error_lazy(status__,...)
A macro for only throwing an error if we've failed - which also ensures no string is constructed unle...
Definition: error.hpp:327
CUarray handle_t
Raw CUDA driver handle for arrays (of any dimension)
Definition: array.hpp:34
array_t< T, NumDimensions > wrap(device::id_t device_id, context::handle_t context_handle, handle_t handle, dimensions_t< NumDimensions > dimensions) noexcept
Wrap an existing CUDA array in an array_t instance.
Definition: array.hpp:271
type_t
The CUDA execution ecosystem involves different memory spaces in their relation to a GPU device or th...
Definition: pointer.hpp:41
CUresult status_t
Indicates either the result (success or error index) of a CUDA Runtime or Driver API call...
Definition: types.hpp:74