Compute Graph Framework SDK Reference
5.4.5418 Release
For Test and Development only

PassCollectionDescriptor.hpp
Go to the documentation of this file.
1 //
3 // Notice
4 // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5 // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7 // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 //
9 // NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10 // information or for any infringement of patents or other rights of third parties that may
11 // result from its use. No license is granted by implication or otherwise under any patent
12 // or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13 // expressly authorized by NVIDIA. Details are subject to change without notice.
14 // This code supersedes and replaces all information previously supplied.
15 // NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16 // components in life support devices or systems without express written approval of
17 // NVIDIA CORPORATION & AFFILIATES.
18 //
19 // SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20 // SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21 //
22 // NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23 // property and proprietary rights in and to this material, related
24 // documentation and any modifications thereto. Any use, reproduction,
25 // disclosure or distribution of this material and related documentation
26 // without an express license agreement from NVIDIA CORPORATION or
27 // its affiliates is strictly prohibited.
28 //
30 
31 #ifndef DW_FRAMEWORK_PASSCOLLECTIONDESCRIPTOR_HPP_
32 #define DW_FRAMEWORK_PASSCOLLECTIONDESCRIPTOR_HPP_
33 
35 
36 #include <dw/core/container/VectorFixed.hpp>
37 
38 namespace dw
39 {
40 namespace framework
41 {
42 
45 {
46 public:
48  PassDescriptor(dw::core::StringView const& name, dwProcessorType const processorType, const bool hasExplicitDependencies, size_t const dependencies);
49 
51  dw::core::StringView const& getName() const noexcept;
52 
54  dwProcessorType getProcessorType() const noexcept;
55 
57  bool hasExplicitDependencies() const noexcept;
58 
60  size_t getNumberOfDependencies() const;
61 
63  dw::core::StringView const& getDependency(size_t const index) const;
64 
66  void addDependency(dw::core::StringView const& dependency);
67 
68 private:
70  dw::core::StringView m_name;
72  dwProcessorType m_processorType;
74  bool m_hasExplicitDependencies;
76  dw::core::VectorFixed<dw::core::StringView> m_dependencies;
77 };
78 
81 {
82 public:
84  explicit PassCollectionDescriptor(size_t const capacity);
85 
87  size_t getSize() const;
88 
90  const PassDescriptor& getDescriptor(size_t const index) const;
91 
97  size_t getIndex(dw::core::StringView const& identifier) const;
98 
104  const PassDescriptor& getDescriptor(dw::core::StringView const& identifier) const;
105 
107  bool isValid(size_t const index) const noexcept;
108 
110  bool isValid(dw::core::StringView const& identifier) const noexcept;
111 
117  void addDescriptor(const PassDescriptor& descriptor);
118 
119 private:
121  dw::core::VectorFixed<PassDescriptor> m_descriptors;
122 };
123 
124 namespace detail
125 {
126 
128 template <
129  typename NodeT, size_t Index,
130  typename std::enable_if_t<Index == passSize<NodeT>(), void>* = nullptr>
131 // Output parameter is used to populate collection without making collection know about where the information is coming from
132 // coverity[autosar_cpp14_a8_4_8_violation]
133 void addPassDescriptor(PassCollectionDescriptor& collection)
134 {
135  (void)collection;
136 }
137 
139 template <
140  typename NodeT, size_t Index,
141  typename std::enable_if_t<Index<passSize<NodeT>(), void>* = nullptr>
142  // Output parameter is used to populate collection without making collection know about where the information is coming from
143  // coverity[autosar_cpp14_a8_4_8_violation]
144  void addPassDescriptor(PassCollectionDescriptor& collection)
145 {
146  constexpr auto dependencies = passDependencies<NodeT, Index>();
147  PassDescriptor descriptor(passName<NodeT, Index>(), passProcessorType<NodeT, Index>(), hasPassDependencies<NodeT, Index>(), dependencies.size());
148  for (size_t i = 0; i < dependencies.size(); ++i)
149  {
150  descriptor.addDependency(dependencies[i]);
151  }
152  collection.addDescriptor(descriptor);
153 
154  addPassDescriptor<NodeT, Index + 1>(collection);
155 }
156 
157 } // namespace detail
158 
160 template <typename NodeT>
162 {
163  PassCollectionDescriptor collection(passSize<NodeT>());
164  detail::addPassDescriptor<NodeT, 0>(collection);
165  return collection;
166 }
167 
168 } // namespace framework
169 } // namespace dw
170 
171 #endif // DW_FRAMEWORK_PASSCOLLECTIONDESCRIPTOR_HPP_
static PassCollectionDescriptor createPassCollectionDescriptor()
Create a pass collection descriptor for a give node.
size_t getNumberOfDependencies() const
Get number of dependencies.
void addDescriptor(const PassDescriptor &descriptor)
Add a pass descriptor to the collection.
PassDescriptor(dw::core::StringView const &name, dwProcessorType const processorType, const bool hasExplicitDependencies, size_t const dependencies)
Constructor.
dwProcessorType getProcessorType() const noexcept
Get the processor type running on.
void addDependency(dw::core::StringView const &dependency)
Add another pass name as a dependency.
Definition: Exception.hpp:46
dw::core::StringView const & getName() const noexcept
Get the pass name.
dw::core::StringView const & getDependency(size_t const index) const
Get the dependent on pass name by index.
bool hasExplicitDependencies() const noexcept
Check if the pass specifies explicit dependencies.