7 #ifndef CUDA_API_WRAPPERS_NODE_HPP 8 #define CUDA_API_WRAPPERS_NODE_HPP 10 #if CUDA_VERSION >= 10000 12 #include "../types.hpp" 30 ::std::string identify(
const node_t &node);
34 using type_t = CUgraphNodeType;
54 using dependencies_type = ::std::vector<node_t>;
55 using dependents_type = ::std::vector<node_t>;
61 handle_type handle() const noexcept {
return handle_; }
62 template_t containing_graph() const noexcept;
63 template_::
handle_t containing_graph_handle() const noexcept {
return graph_template_handle_; }
64 type_type type_()
const 67 auto status = cuGraphNodeGetType(handle_, &result);
72 size_t num_dependencies()
const 74 size_t num_dependencies_;
75 auto status = cuGraphNodeGetDependencies(handle_,
nullptr, &num_dependencies_);
76 throw_if_error_lazy(status,
"Obtaining the number of nodes on which " + node::detail_::identify(*
this) +
" is dependent");
77 return num_dependencies_;
80 size_t num_dependents()
const 82 size_t num_dependents_;
83 auto status = cuGraphNodeGetDependentNodes(handle_,
nullptr, &num_dependents_);
84 throw_if_error_lazy(status,
"Obtaining the number of nodes dependent on " + node::detail_::identify(*
this));
85 return num_dependents_;
88 dependencies_type dependencies()
const 90 size_type num_dependencies_ {num_dependencies() } ;
91 ::std::vector<node::handle_t> node_handles {num_dependencies_ };
92 auto status = cuGraphNodeGetDependencies(handle_, node_handles.data(), &num_dependencies_);
93 throw_if_error_lazy(status,
"Obtaining the set nodes on which " + node::detail_::identify(*
this) +
" is dependent");
94 dependencies_type result;
95 for (
const auto& node_handle : node_handles) {
96 result.emplace_back(
node::wrap(graph_template_handle_, node_handle));
101 dependencies_type dependents()
const 103 size_type num_dependents_ { num_dependents() } ;
104 ::std::vector<node::handle_t> node_handles {num_dependents_ };
105 auto status = cuGraphNodeGetDependentNodes(handle_, node_handles.data(), &num_dependents_);
106 throw_if_error_lazy(status,
"Obtaining the set nodes dependent on " + node::detail_::identify(*
this));
107 dependencies_type result;
108 for (
const auto& node_handle : node_handles) {
109 result.emplace_back(
node::wrap(graph_template_handle_, node_handle));
116 : graph_template_handle_(graph_template_handle), handle_(handle) { }
122 node_t(
const node_t&) noexcept =
default;
123 node_t(node_t&&) noexcept = default;
125 node_t& operator=(node_t other) noexcept
127 graph_template_handle_ = other.graph_template_handle_;
128 handle_ = other.handle_;
141 return { graph_handle, handle };
150 #endif // CUDA_VERSION >= 10000 152 #endif //CUDA_API_WRAPPERS_NODE_HPP Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
::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:81
#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:316
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:264
type_t
The CUDA execution ecosystem involves different memory spaces in their relation to a GPU device or th...
Definition: pointer.hpp:41