Compute Graph Framework SDK Reference  5.16
PassCollectionDescriptor.hpp
Go to the documentation of this file.
1
2//
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-2023 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 <dwshared/dwfoundation/dw/core/container/VectorFixed.hpp>
37
38namespace dw
39{
40namespace framework
41{
42
45{
46public:
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
61
63 dw::core::StringView const& getDependency(size_t const index) const;
64
66 void addDependency(dw::core::StringView const& dependency);
67
68private:
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{
82public:
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
119private:
121 dw::core::VectorFixed<PassDescriptor> m_descriptors;
122};
123
124namespace detail
125{
126
128template <
129 typename NodeT, size_t Index,
130 typename std::enable_if_t<!hasPassDependencies<NodeT, Index>(), void>* = nullptr>
131// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
132void addPassDescriptorDependencies(PassDescriptor& descriptor)
133{
134 static_cast<void>(descriptor);
135}
136
138template <
139 typename NodeT, size_t Index,
140 typename std::enable_if_t<hasPassDependencies<NodeT, Index>(), void>* = nullptr>
141// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
142void addPassDescriptorDependencies(PassDescriptor& descriptor)
143{
144 for (size_t i{0U}; i < passDependencies<NodeT, Index>().size(); ++i)
145 {
146 descriptor.addDependency(passDependencies<NodeT, Index>()[i]);
147 }
148}
149
151template <
152 typename NodeT, size_t Index,
153 typename std::enable_if_t<Index == passSize<NodeT>(), void>* = nullptr>
154// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
155void addPassDescriptor(PassCollectionDescriptor& collection)
156{
157 static_cast<void>(collection);
158}
159
161template <
162 typename NodeT, size_t Index,
163 typename std::enable_if_t<Index<passSize<NodeT>(), void>* = nullptr>
164 // coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
165 void addPassDescriptor(PassCollectionDescriptor& collection)
166{
167 PassDescriptor descriptor{passName<NodeT, Index>(), passProcessorType<NodeT, Index>(), hasPassDependencies<NodeT, Index>(), passDependencies<NodeT, Index>().size()};
168 addPassDescriptorDependencies<NodeT, Index>(descriptor);
169 collection.addDescriptor(descriptor);
170
171 addPassDescriptor<NodeT, Index + 1>(collection);
172}
173
174} // namespace detail
175
177template <typename NodeT>
178// coverity[autosar_cpp14_a2_10_4_violation] FP: nvbugs/4040101
179// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
181{
182 PassCollectionDescriptor collection{passSize<NodeT>()};
183 detail::addPassDescriptor<NodeT, 0>(collection);
184 return collection;
185}
186
187} // namespace framework
188} // namespace dw
189
190#endif // DW_FRAMEWORK_PASSCOLLECTIONDESCRIPTOR_HPP_
const PassDescriptor & getDescriptor(dw::core::StringView const &identifier) const
bool isValid(size_t const index) const noexcept
Check if the passed index is valid, which mean is within [0, size()).
PassCollectionDescriptor(size_t const capacity)
Constructor.
const PassDescriptor & getDescriptor(size_t const index) const
Get the pass descriptor for the passed index.
size_t getIndex(dw::core::StringView const &identifier) const
bool isValid(dw::core::StringView const &identifier) const noexcept
Check if the passed pass name matches a pass descriptor in the collection.
void addDescriptor(const PassDescriptor &descriptor)
size_t getSize() const
Get the number of pass descriptors.
size_t getNumberOfDependencies() const
Get number of dependencies.
dwProcessorType getProcessorType() const noexcept
Get the processor type running on.
dw::core::StringView const & getName() const noexcept
Get the pass name.
bool hasExplicitDependencies() const noexcept
Check if the pass specifies explicit dependencies.
dw::core::StringView const & getDependency(size_t const index) const
Get the dependent on pass name by index.
PassDescriptor(dw::core::StringView const &name, dwProcessorType const processorType, const bool hasExplicitDependencies, size_t const dependencies)
Constructor.
void addDependency(dw::core::StringView const &dependency)
Add another pass name as a dependency.
static PassCollectionDescriptor createPassCollectionDescriptor()
Create a pass collection descriptor for a give node.
Definition: Buffer.hpp:40