Compute Graph Framework SDK Reference  5.22
SimpleNode.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) 2019-2024 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_SIMPLENODE_HPP_
32#define DW_FRAMEWORK_SIMPLENODE_HPP_
33
34#include <dw/core/base/Types.h>
35#include <dwcgf/Exception.hpp>
37#include <dwcgf/pass/Pass.hpp>
38#include <dwcgf/node/Node.hpp>
43
44#include <dwshared/dwfoundation/dw/core/container/BaseString.hpp>
45#include <dwshared/dwfoundation/dw/core/container/HashContainer.hpp>
46#include <dwshared/dwfoundation/dw/core/container/VectorFixed.hpp>
47#include <dwshared/dwfoundation/dw/core/language/Function.hpp>
48
49#include <memory>
50
51namespace dw
52{
53namespace framework
54{
55
57{
58public:
61 size_t maxInputPortCount_,
62 size_t maxOutputPortCount_,
63 size_t maxPassCount_)
64 : maxInputPortCount(maxInputPortCount_)
65 , maxOutputPortCount(maxOutputPortCount_)
66 , maxPassCount(maxPassCount_)
67 {
68 }
71 size_t maxPassCount{};
72};
73
74template <typename NodeT>
75// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
77{
79 portSize<NodeT, PortDirection::INPUT>(),
80 portSize<NodeT, PortDirection::OUTPUT>(),
81 passSize<NodeT>()};
82 return params;
83}
84
85class SimpleNode : public Node
86{
87public:
90
91 dwStatus reset() override
92 {
93 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleNode::reset() not implemented");
94 }
95
97
100 dwStatus setInputChannel(ChannelObject* channel, size_t portID) override;
101
103
106 dwStatus setOutputChannel(ChannelObject* channel, size_t portID) override;
107
109 dwStatus getInputChannel(const size_t portID, ChannelObject*& channel) const override;
110
112 dwStatus getOutputChannel(const size_t portID, ChannelObject*& channel) const override;
113
114 dwStatus validate() override
115 {
116 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleNode::validate() not implemented");
117 }
118
120
123 dwStatus validate(const char* direction, const PortCollectionDescriptor& collection, dw::core::Function<bool(size_t)> isPortBound);
124
125 dwStatus run() override;
126 size_t getPassCount() const noexcept override;
127 dwStatus runPass(size_t passIndex) override;
128 dwStatus getPass(Pass*& pass, size_t index) override;
129 // coverity[autosar_cpp14_a2_10_5_violation]
130 dwStatus getPasses(VectorFixed<Pass*>& passList) override;
131
132 dwStatus setName(const char* name) override;
133 dwStatus getName(const char** name) override;
134
135 dwStatus collectErrorSignals(dwGraphErrorSignal*& errorSignal) override;
136 dwStatus getModuleErrorSignal(dwErrorSignal& errorSignal) override;
137 dwStatus getNodeErrorSignal(dwGraphErrorSignal& errorSignal) override;
138 dwStatus collectHealthSignals(dwGraphHealthSignal*& healthSignal) override;
139 dwStatus getModuleHealthSignal(dwHealthSignal& healthSignal) override;
140 dwStatus getNodeHealthSignal(dwGraphHealthSignal& healthSignal) override;
141 dwStatus clearErrorSignal() override;
142 dwStatus clearHealthSignal() override;
143 dwStatus addToErrorSignal(uint32_t error, dwTime_t timestamp = 0L) final;
144 dwStatus addToHealthSignal(uint32_t error, dwTime_t timestamp = 0L) override;
145
146 template <typename Func, typename PortList>
147 void iteratePorts(PortList& portList, Func func)
148 {
149 for (auto& elem : portList)
150 {
151 func(elem);
152 }
153 }
154
155 template <typename Func>
157 {
158 iteratePorts(m_inputPorts, [&func, this](decltype(m_inputPorts)::TElement& elem) {
159 if (nullptr == elem.second.get())
160 {
161 const char* nodeName{nullptr};
162 static_cast<void>(this->getName(&nodeName));
163 throw ExceptionWithStatus(DW_NOT_INITIALIZED, "SimpleNode: input port not initialized, node ", nodeName, ", port id ", elem.first);
164 }
165 func(*elem.second);
166 });
167 }
168
169 template <typename Func>
171 {
172 iteratePorts(m_outputPorts, [&func, this](decltype(m_outputPorts)::TElement& elem) {
173 if (nullptr == elem.second.get())
174 {
175 const char* nodeName{nullptr};
176 static_cast<void>(this->getName(&nodeName));
177 throw ExceptionWithStatus(DW_NOT_INITIALIZED, "SimpleNode: output port not initialized, node ", nodeName, ", port id ", elem.first);
178 }
179 func(*elem.second);
180 });
181 }
182
183 template <typename ModuleHandle_t>
184 dwStatus setModuleHandle(ModuleHandle_t handle, dwContextHandle_t context)
185 {
186 dwModuleHandle_t moduleHandle;
187
188 if (DW_NULL_HANDLE == handle)
189 {
190 return DW_INVALID_ARGUMENT;
191 }
192
193 dwStatus ret{getModuleHandle(&moduleHandle, handle, context)};
194 if (DW_SUCCESS != ret)
195 {
196 return ret;
197 }
198
199 return setObjectHandle(moduleHandle);
200 }
201
202 dwStatus setObjectHandle(dwModuleHandle_t handle);
203
204 dwModuleHandle_t getObjectHandle() const;
205
207 dwStatus getInputPort(const size_t portID, dw::framework::PortBase*& port) const override;
208
210 dwStatus getOutputPort(const size_t portID, dw::framework::PortBase*& port) const override;
211
212protected:
213 dwStatus getModuleHandle(dwModuleHandle_t* moduleHandle, void* handle, dwContextHandle_t context);
214
216
222 template <
223 typename NodeT, size_t PassIndex, typename PassFunctionT>
224 void registerPass(PassFunctionT func, std::initializer_list<std::pair<dwStatus, uint32_t>> const& returnMapping = {})
225 {
226 // if the pass index is invalid the compilation will fail on passProcessorType() below
227 // no need to check with isValidPass<NodeT>(PassIndex) at runtime
228
229 // coverity[autosar_cpp14_a5_1_1_violation] RFD Accepted: TID-2056
230 if (0U == m_passList.size() || m_passList.size() - 1U < PassIndex)
231 {
232 // coverity[autosar_cpp14_a5_1_1_violation] RFD Accepted: TID-2056
233 m_passList.resize(PassIndex + 1U);
234 }
235 // coverity[autosar_cpp14_a5_1_1_violation] FP: nvbugs/3364868
236 if (nullptr != m_passList[PassIndex])
237 {
238 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "registerPass called with a pass id which has been added before: ", PassIndex);
239 }
240 dwProcessorType processorType{passProcessorType<NodeT, PassIndex>()};
241 // coverity[autosar_cpp14_a5_1_1_violation] FP: nvbugs/3364868
242 m_passList[PassIndex] = std::make_unique<PassImpl<PassFunctionT>>(*this, passName<NodeT, PassIndex>(), func, processorType, returnMapping);
243 }
244
246
249 template <
250 typename NodeT, size_t PassIndex, typename PassFunctionT>
251 void registerPass(PassFunctionT func, cudaStream_t const cudaStream, std::initializer_list<std::pair<dwStatus, uint32_t>> const& returnMapping = {})
252 {
253 static_assert(DW_PROCESSOR_TYPE_GPU == passProcessorType<NodeT, PassIndex>(), "The processor type of a pass with a cuda stream must be GPU");
254 registerPass<NodeT, PassIndex>(func, returnMapping);
255 // coverity[autosar_cpp14_a5_1_1_violation] FP: nvbugs/3364868
256 m_passList[PassIndex]->m_cudaStream = cudaStream;
257 }
258
259public:
266
276
286
287protected:
289 {
290 return m_healthSignal;
291 }
292
293private:
294 VectorFixed<std::unique_ptr<Pass>> m_passList;
295 FixedString<MAX_NAME_LEN> m_name;
296 bool m_setupTeardownCreated;
297
299 dwGraphErrorSignal m_errorSignal;
300 dwGraphHealthSignal m_healthSignal;
301
302 dwModuleHandle_t m_object;
303 uint32_t m_iterationCount{};
304 uint32_t m_nodePeriod{};
305
306public:
308
311 template <typename NodeT, size_t PortIndex, typename... Args>
312 void initInputPort(Args&&... args)
313 {
314 static_assert(PortIndex < portSize<NodeT, PortDirection::INPUT>(), "Invalid port index");
315 using DataType = decltype(portType<NodeT, PortDirection::INPUT, PortIndex>());
316 std::shared_ptr<ManagedPortInput<DataType>> port{std::make_shared<ManagedPortInput<DataType>>(portName<NodeT, PortDirection::INPUT, PortIndex>(), std::forward<Args>(args)...)};
317 if (m_inputPorts.find(PortIndex) != m_inputPorts.end())
318 {
319 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Input port with the following id registered multiple times: ", PortIndex);
320 }
321 m_inputPorts[PortIndex] = port;
322 }
323
325
331 template <typename NodeT, size_t PortIndex, typename... Args>
332 void initInputArrayPorts(Args&&... args)
333 {
334 static_assert(PortIndex < portSize<NodeT, PortDirection::INPUT>(), "Invalid port index");
335 constexpr size_t arraySize{descriptorPortSize<NodeT, PortDirection::INPUT, descriptorIndex<NodeT, PortDirection::INPUT, PortIndex>()>()};
336 for (size_t i{0U}; i < arraySize; ++i)
337 {
338 initInputArrayPort<NodeT, PortIndex>(i, std::forward<Args>(args)...);
339 }
340 }
341
343
348 template <typename NodeT, size_t PortIndex, typename... Args>
349 void initInputArrayPort(size_t arrayIndex, Args&&... args)
350 {
351 static_assert(PortIndex < portSize<NodeT, PortDirection::INPUT>(), "Invalid port index");
352 using DataType = decltype(portType<NodeT, PortDirection::INPUT, PortIndex>());
353 if (arrayIndex >= descriptorPortSize<NodeT, PortDirection::INPUT, descriptorIndex<NodeT, PortDirection::INPUT, PortIndex>()>())
354 {
355 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Invalid array index ", arrayIndex, " for array input port ", PortIndex);
356 }
357 std::shared_ptr<ManagedPortInput<DataType>> port{std::make_shared<ManagedPortInput<DataType>>(portName<NodeT, PortDirection::INPUT, PortIndex>(arrayIndex), std::forward<Args>(args)...)};
358 if (m_inputPorts.find(PortIndex + arrayIndex) != m_inputPorts.end())
359 {
360 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Input port with the following id registered multiple times: ", PortIndex + arrayIndex);
361 }
362 m_inputPorts[PortIndex + arrayIndex] = port;
363 }
364
366
369 template <typename NodeT, size_t PortIndex, typename... Args>
370 void initOutputPort(Args&&... args)
371 {
372 static_assert(PortIndex - portSize<NodeT, PortDirection::INPUT>() < portSize<NodeT, PortDirection::OUTPUT>(), "Invalid port index");
373 using DataType = decltype(portType<NodeT, PortDirection::OUTPUT, PortIndex>());
374 std::shared_ptr<ManagedPortOutput<DataType>> port{std::make_shared<ManagedPortOutput<DataType>>(portName<NodeT, PortDirection::OUTPUT, PortIndex>(), std::forward<Args>(args)...)};
375 if (m_outputPorts.find(PortIndex) != m_outputPorts.end())
376 {
377 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Output port with the following id registered multiple times: ", PortIndex);
378 }
379 m_outputPorts[PortIndex] = port;
380 }
381
383
389 template <typename NodeT, size_t PortIndex, typename... Args>
390 void initOutputArrayPorts(Args&&... args)
391 {
392 static_assert(PortIndex - portSize<NodeT, PortDirection::INPUT>() < portSize<NodeT, PortDirection::OUTPUT>(), "Invalid port index");
393 constexpr size_t arraySize{descriptorPortSize<NodeT, PortDirection::OUTPUT, descriptorIndex<NodeT, PortDirection::OUTPUT, PortIndex>()>()};
394 for (size_t i{0U}; i < arraySize; ++i)
395 {
396 initOutputArrayPort<NodeT, PortIndex>(i, std::forward<Args>(args)...);
397 }
398 }
399
401
406 template <typename NodeT, size_t PortIndex, typename... Args>
407 void initOutputArrayPort(size_t arrayIndex, Args&&... args)
408 {
409 static_assert(PortIndex - portSize<NodeT, PortDirection::INPUT>() < portSize<NodeT, PortDirection::OUTPUT>(), "Invalid port index");
410 using DataType = decltype(portType<NodeT, PortDirection::OUTPUT, PortIndex>());
411 if (arrayIndex >= descriptorPortSize<NodeT, PortDirection::OUTPUT, descriptorIndex<NodeT, PortDirection::OUTPUT, PortIndex>()>())
412 {
413 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Invalid array index ", arrayIndex, " for array output port ", PortIndex);
414 }
415 std::shared_ptr<ManagedPortOutput<DataType>> port{std::make_shared<ManagedPortOutput<DataType>>(portName<NodeT, PortDirection::OUTPUT, PortIndex>(arrayIndex), std::forward<Args>(args)...)};
416 if (m_outputPorts.find(PortIndex + arrayIndex) != m_outputPorts.end())
417 {
418 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Output port with the following id registered multiple times: ", PortIndex + arrayIndex);
419 }
420 m_outputPorts[PortIndex + arrayIndex] = port;
421 }
422
424 template <typename NodeT, size_t PortIndex>
426 {
427 static_assert(PortIndex < portSize<NodeT, PortDirection::INPUT>(), "Invalid port index");
428 constexpr bool isArray{descriptorPortArray<NodeT, PortDirection::INPUT, descriptorIndex<NodeT, PortDirection::INPUT, PortIndex>()>()};
429 static_assert(!isArray, "Input port is an array, must pass an array index");
430 if (m_inputPorts.find(PortIndex) == m_inputPorts.end())
431 {
432 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Input port with the following id not registered: ", PortIndex);
433 }
434 ManagedPortInputBase* portBase{m_inputPorts[PortIndex].get()};
435 using DataType = decltype(portType<NodeT, PortDirection::INPUT, PortIndex>());
436 using PointerType = ManagedPortInput<DataType>*;
437 // LCOV_EXCL_START the type is ensured by the template parameter and the exception in the defensive code can't be triggered
438 // coverity[autosar_cpp14_m5_2_3_violation]
439 PointerType port{dynamic_cast<PointerType>(portBase)};
440 if (!port)
441 {
442 throw ExceptionWithStatus(DW_BAD_CAST, "Failed to cast the following input port to its declared type: ", PortIndex);
443 }
444 // LCOV_EXCL_STOP
445 return *port;
446 }
447
449 template <typename NodeT, size_t PortIndex>
451 {
452 static_assert(PortIndex < portSize<NodeT, PortDirection::INPUT>(), "Invalid port index");
453 constexpr bool isArray{descriptorPortArray<NodeT, PortDirection::INPUT, descriptorIndex<NodeT, PortDirection::INPUT, PortIndex>()>()};
454 static_assert(isArray, "Input port is not an array, must not pass an array index");
455 constexpr size_t arraySize{descriptorPortSize<NodeT, PortDirection::INPUT, descriptorIndex<NodeT, PortDirection::INPUT, PortIndex>()>()};
456 if (arrayIndex >= arraySize)
457 {
458 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "The array index is out of bound: ", arrayIndex);
459 }
460 if (m_inputPorts.find(PortIndex + arrayIndex) == m_inputPorts.end())
461 {
462 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Input port with the following id not registered: ", PortIndex + arrayIndex);
463 }
464 ManagedPortInputBase* portBase{m_inputPorts[PortIndex + arrayIndex].get()};
465 using DataType = decltype(portType<NodeT, PortDirection::INPUT, PortIndex>());
466 using PointerType = ManagedPortInput<DataType>*;
467 // LCOV_EXCL_START the type is ensured by the template parameter and the exception in the defensive code can't be triggered
468 // coverity[autosar_cpp14_m5_2_3_violation]
469 PointerType port{dynamic_cast<PointerType>(portBase)};
470 if (!port)
471 {
472 throw ExceptionWithStatus(DW_BAD_CAST, "Failed to cast the following input port to its declared type: ", PortIndex + arrayIndex);
473 }
474 // LCOV_EXCL_STOP
475 return *port;
476 }
477
479 template <typename NodeT, size_t PortIndex>
481 {
482 static_assert(PortIndex - portSize<NodeT, PortDirection::INPUT>() < portSize<NodeT, PortDirection::OUTPUT>(), "Invalid port index");
483 constexpr bool isArray{descriptorPortArray<NodeT, PortDirection::OUTPUT, descriptorIndex<NodeT, PortDirection::OUTPUT, PortIndex>()>()};
484 static_assert(!isArray, "Output port is an array, must pass an array index");
485 if (m_outputPorts.find(PortIndex) == m_outputPorts.end())
486 {
487 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Output port with the following id not registered: ", PortIndex);
488 }
489 ManagedPortOutputBase* portBase{m_outputPorts[PortIndex].get()};
490 using DataType = decltype(portType<NodeT, PortDirection::OUTPUT, PortIndex>());
491 using PointerType = ManagedPortOutput<DataType>*;
492 // LCOV_EXCL_START the type is ensured by the template parameter and the exception in the defensive code can't be triggered
493 // coverity[autosar_cpp14_m5_2_3_violation]
494 PointerType port{dynamic_cast<PointerType>(portBase)};
495 if (!port)
496 {
497 throw ExceptionWithStatus(DW_BAD_CAST, "Failed to cast the following output port to its declared type: ", PortIndex);
498 }
499 // LCOV_EXCL_STOP
500 return *port;
501 }
502
504 template <typename NodeT, size_t PortIndex>
506 {
507 static_assert(PortIndex - portSize<NodeT, PortDirection::INPUT>() < portSize<NodeT, PortDirection::OUTPUT>(), "Invalid port index");
508 constexpr bool isArray{descriptorPortArray<NodeT, PortDirection::OUTPUT, descriptorIndex<NodeT, PortDirection::OUTPUT, PortIndex>()>()};
509 static_assert(isArray, "Output port is not an array, must not pass an array index");
510 constexpr size_t arraySize{descriptorPortSize<NodeT, PortDirection::OUTPUT, descriptorIndex<NodeT, PortDirection::OUTPUT, PortIndex>()>()};
511 if (arrayIndex >= arraySize)
512 {
513 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "The array index is out of bound: ", arrayIndex);
514 }
515 if (m_outputPorts.find(PortIndex + arrayIndex) == m_outputPorts.end())
516 {
517 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Output port with the following id not registered: ", PortIndex + arrayIndex);
518 }
519 ManagedPortOutputBase* portBase{m_outputPorts[PortIndex + arrayIndex].get()};
520 using DataType = decltype(portType<NodeT, PortDirection::OUTPUT, PortIndex>());
521 using PointerType = ManagedPortOutput<DataType>*;
522 // LCOV_EXCL_START the type is ensured by the template parameter and the exception in the defensive code can't be triggered
523 // coverity[autosar_cpp14_m5_2_3_violation]
524 PointerType port{dynamic_cast<PointerType>(portBase)};
525 if (!port)
526 {
527 throw ExceptionWithStatus(DW_BAD_CAST, "Failed to cast the following output port to its declared type: ", PortIndex + arrayIndex);
528 }
529 // LCOV_EXCL_STOP
530 return *port;
531 }
532
534
538 dwStatus setup();
539
541
545 dwStatus teardown();
546
548
552 void resetPorts() override;
553
558 dwStatus setIterationCount(uint32_t iterationCount) override;
559
564 dwStatus setNodePeriod(uint32_t period) override;
565
566 const dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortInputBase>>& getRegisteredInputPorts() const
567 {
568 return m_inputPorts;
569 }
570
571 const dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortOutputBase>>& getRegisteredOutputPorts() const
572 {
573 return m_outputPorts;
574 }
575
576 uint32_t getIterationCount() const;
577 uint32_t getNodePeriod() const;
582 dwStatus setState(const char* state) override
583 {
584 static_cast<void>(state);
585 return DW_SUCCESS;
586 }
587
588protected:
589 dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortInputBase>> m_inputPorts;
590 dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortOutputBase>> m_outputPorts;
591
592 std::atomic<bool> m_asyncResetFlag;
593};
594
595} // namespace framework
596} // namespace dw
597
598#endif // DW_FRAMEWORK_SIMPLENODE_HPP_
Basic error signal that gets reported only when there is an error.
Basic health signal that describes the health status of the graph.
Pass is a runnable describes the metadata of a pass.
Definition: Pass.hpp:50
dw::core::HeapHashMap< size_t, std::shared_ptr< ManagedPortInputBase > > m_inputPorts
Definition: SimpleNode.hpp:589
ManagedPortOutput< decltype(portType< NodeT, PortDirection::OUTPUT, PortIndex >())> & getOutputPort(size_t arrayIndex)
Get one specific ManagedPortOutput from a previously initialized output array port.
Definition: SimpleNode.hpp:505
dwStatus getOutputChannel(const size_t portID, ChannelObject *&channel) const override
Gets the output channel associated with the output port.
dwStatus getInputPort(const size_t portID, dw::framework::PortBase *&port) const override
Gets the input port associated with the input port Id.
void initOutputArrayPorts(Args &&... args)
Initialize an array of ManagedPortOutput which will be owned by the base class and can be retrieved u...
Definition: SimpleNode.hpp:390
dwStatus reset() override
Definition: SimpleNode.hpp:91
void iterateManagedInputPorts(Func func)
Definition: SimpleNode.hpp:156
dwStatus setNodePeriod(uint32_t period) override
dwStatus validate() override
Definition: SimpleNode.hpp:114
dwStatus collectErrorSignals(dwGraphErrorSignal *&errorSignal) override
void initInputPort(Args &&... args)
Initialize a ManagedPortInput which will be owned by the base class and can be retrieved using getInp...
Definition: SimpleNode.hpp:312
dwStatus updateHealthSignal(const dwGraphHealthSignal &signal)
Adds the provided Health Signal to the Health Signal Array. If the array is full, the new signal will...
dwStatus addToHealthSignal(uint32_t error, dwTime_t timestamp=0L) override
uint32_t getNodePeriod() const
dwStatus setInputChannel(ChannelObject *channel, size_t portID) override
Associate an input port with a channel instances.
SimpleNode(NodeAllocationParams params)
Constructor which tailors the preallocated size of the internal collections for ports and passes to t...
void initOutputArrayPort(size_t arrayIndex, Args &&... args)
Initialize one ManagedPortOutput of an array which will be owned by the base class and can be retriev...
Definition: SimpleNode.hpp:407
dwStatus setOutputChannel(ChannelObject *channel, size_t portID) override
Associate an output port with a channel instances.
size_t getPassCount() const noexcept override
dwStatus clearHealthSignal() override
const dw::core::HeapHashMap< size_t, std::shared_ptr< ManagedPortOutputBase > > & getRegisteredOutputPorts() const
Definition: SimpleNode.hpp:571
uint32_t getIterationCount() const
dwStatus collectHealthSignals(dwGraphHealthSignal *&healthSignal) override
dwStatus getInputChannel(const size_t portID, ChannelObject *&channel) const override
Gets the input channel associated with the input port.
dwStatus setObjectHandle(dwModuleHandle_t handle)
dwStatus setModuleHandle(ModuleHandle_t handle, dwContextHandle_t context)
Definition: SimpleNode.hpp:184
dwStatus updateCurrentErrorSignal(dwGraphErrorSignal &signal) override
A function that allows user override to update error signal It is automatically called by dwFramework...
const dw::core::HeapHashMap< size_t, std::shared_ptr< ManagedPortInputBase > > & getRegisteredInputPorts() const
Definition: SimpleNode.hpp:566
void iterateManagedOutputPorts(Func func)
Definition: SimpleNode.hpp:170
dwStatus run() override
dwStatus getNodeErrorSignal(dwGraphErrorSignal &errorSignal) override
dwStatus setName(const char *name) override
dwModuleHandle_t getObjectHandle() const
void resetPorts() override
Default implementation to reset ports managed by the base class.
dwStatus getNodeHealthSignal(dwGraphHealthSignal &healthSignal) override
dwStatus setState(const char *state) override
Definition: SimpleNode.hpp:582
dwStatus getOutputPort(const size_t portID, dw::framework::PortBase *&port) const override
Gets the output port associated with the output port Id.
dwStatus getName(const char **name) override
dwStatus runPass(size_t passIndex) override
void registerPass(PassFunctionT func, cudaStream_t const cudaStream, std::initializer_list< std::pair< dwStatus, uint32_t > > const &returnMapping={})
Register a GPU pass function and a cuda stream with the node base class.
Definition: SimpleNode.hpp:251
void registerPass(PassFunctionT func, std::initializer_list< std::pair< dwStatus, uint32_t > > const &returnMapping={})
Register a pass function with the node base class.
Definition: SimpleNode.hpp:224
dwStatus getPasses(VectorFixed< Pass * > &passList) override
dwStatus getModuleHandle(dwModuleHandle_t *moduleHandle, void *handle, dwContextHandle_t context)
dwStatus getPass(Pass *&pass, size_t index) override
dwStatus setup()
Default implementation of the setup pass.
ManagedPortInput< decltype(portType< NodeT, PortDirection::INPUT, PortIndex >())> & getInputPort()
Get a previously initialized non-array ManagedPortInput.
Definition: SimpleNode.hpp:425
void initOutputPort(Args &&... args)
Initialize a ManagedPortOutput which will be owned by the base class and can be retrieved using getOu...
Definition: SimpleNode.hpp:370
void iteratePorts(PortList &portList, Func func)
Definition: SimpleNode.hpp:147
void initInputArrayPort(size_t arrayIndex, Args &&... args)
Initialize one ManagedPortInput of an array which will be owned by the base class and can be retrieve...
Definition: SimpleNode.hpp:349
void initInputArrayPorts(Args &&... args)
Initialize an array of ManagedPortInput which will be owned by the base class and can be retrieved us...
Definition: SimpleNode.hpp:332
dwGraphHealthSignal & getHealthSignal()
Definition: SimpleNode.hpp:288
dwStatus updateCurrentHealthSignal(dwGraphHealthSignal &signal) override
A function that allows user override to update health signal It is automatically called by dwFramewor...
ManagedPortInput< decltype(portType< NodeT, PortDirection::INPUT, PortIndex >())> & getInputPort(size_t arrayIndex)
Get one specific ManagedPortInput from a previously initialized input array port.
Definition: SimpleNode.hpp:450
dwStatus teardown()
Default implementation of the teardown pass.
dwStatus validate(const char *direction, const PortCollectionDescriptor &collection, dw::core::Function< bool(size_t)> isPortBound)
Helper function used by dw::framework::SimpleNodeT::validate.
dwStatus clearErrorSignal() override
dwStatus setIterationCount(uint32_t iterationCount) override
dwStatus getModuleErrorSignal(dwErrorSignal &errorSignal) override
dwStatus getModuleHealthSignal(dwHealthSignal &healthSignal) override
std::atomic< bool > m_asyncResetFlag
Definition: SimpleNode.hpp:592
dwStatus addToErrorSignal(uint32_t error, dwTime_t timestamp=0L) final
dw::core::HeapHashMap< size_t, std::shared_ptr< ManagedPortOutputBase > > m_outputPorts
Definition: SimpleNode.hpp:590
ManagedPortOutput< decltype(portType< NodeT, PortDirection::OUTPUT, PortIndex >())> & getOutputPort()
Get a previously initialized non-array ManagedPortOutput.
Definition: SimpleNode.hpp:480
constexpr size_t descriptorPortSize()
constexpr size_t passIndex(dw::core::StringView identifier)
Get the the pass index for a pass identified by name.
NodeAllocationParams createAllocationParams()
Definition: SimpleNode.hpp:76
Definition: Buffer.hpp:41
NodeAllocationParams(size_t maxInputPortCount_, size_t maxOutputPortCount_, size_t maxPassCount_)
Definition: SimpleNode.hpp:60