Compute Graph Framework SDK Reference  5.12
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-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_SIMPLENODE_HPP_
32#define DW_FRAMEWORK_SIMPLENODE_HPP_
33
34#include <dw/core/base/Types.h>
35#include <dwcgf/Exception.hpp>
36#include <dwcgf/Types.hpp>
38#include <dwcgf/pass/Pass.hpp>
39#include <dwcgf/node/Node.hpp>
45
46#include <dwshared/dwfoundation/dw/core/container/BaseString.hpp>
47#include <dwshared/dwfoundation/dw/core/container/HashContainer.hpp>
48#include <dwshared/dwfoundation/dw/core/container/VectorFixed.hpp>
49#include <dwshared/dwfoundation/dw/core/language/Function.hpp>
50
51#include <memory>
52
53namespace dw
54{
55namespace framework
56{
57
59{
63};
64
65template <typename NodeT>
66// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
68{
69 NodeAllocationParams params{};
70 params.maxInputPortCount = portSize<NodeT, PortDirection::INPUT>();
71 params.maxOutputPortCount = portSize<NodeT, PortDirection::OUTPUT>();
72 params.maxPassCount = passSize<NodeT>();
73 return params;
74}
75
76class SimpleNode : public Node
77{
78public:
82 virtual ~SimpleNode();
83
84 dwStatus reset() override
85 {
86 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleNode::reset() not implemented");
87 }
88
90
93 dwStatus setInputChannel(ChannelObject* channel, uint8_t portID) override;
94
96 {
97 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleNode::setInputChannel() not implemented");
98 }
99
101
104 dwStatus setOutputChannel(ChannelObject* channel, uint8_t portID) override;
105
107 dwStatus getInputChannel(const uint8_t portID, ChannelObject*& channel) const override;
108
110 dwStatus getOutputChannel(const uint8_t portID, ChannelObject*& channel) const override;
111
112 dwStatus validate() override
113 {
114 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleNode::validate() not implemented");
115 }
116
118
121 dwStatus validate(const char* direction, const PortCollectionDescriptor& collection, dw::core::Function<bool(size_t)> isPortBound);
122
123 dwStatus run() override;
124 size_t getPassCount() const noexcept override;
125 dwStatus runPass(size_t passIndex) override;
126 dwStatus getPass(Pass** pass, uint8_t index) override;
127 // coverity[autosar_cpp14_a2_10_5_violation]
128 dwStatus getPasses(VectorFixed<Pass*>& passList) override;
129 // coverity[autosar_cpp14_a2_10_5_violation]
130 dwStatus getPasses(VectorFixed<Pass*>& passList, dwProcessorType processorType) override;
131
132 dwStatus setName(const char* name) final;
133 dwStatus getName(const char** name) override;
134
135 dwStatus getErrorSignal(dwGraphErrorSignal& sehErrorSignal, dwGraphErrorSignal*& errorSignal, uint16_t const sourceId, char8_t const* instanceName = nullptr) override;
136 dwStatus getHealthSignal(dwGraphHealthSignal*& healthSignals, bool updateFromModule = false) override;
137 dwStatus clearErrorSignal() override;
138 dwStatus clearHealthSignal() override;
139
140 template <typename Func, typename PortList>
141 void iteratePorts(PortList& portList, Func func)
142 {
143 for (auto& elem : portList)
144 {
145 func(elem);
146 }
147 }
148
149 template <typename Func>
151 {
152 iteratePorts(m_inputPorts, [&func, this](decltype(m_inputPorts)::TElement& elem) {
153 if (elem.second.get() == nullptr)
154 {
155 const char* nodeName{nullptr};
156 this->getName(&nodeName);
157 throw ExceptionWithStatus(DW_NOT_INITIALIZED, "SimpleNode: input port not initialized, node ", nodeName, ", port id ", elem.first);
158 }
159 func(*elem.second);
160 });
161 }
162
163 template <typename Func>
165 {
166 iteratePorts(m_outputPorts, [&func, this](decltype(m_outputPorts)::TElement& elem) {
167 if (elem.second.get() == nullptr)
168 {
169 const char* nodeName{nullptr};
170 this->getName(&nodeName);
171 throw ExceptionWithStatus(DW_NOT_INITIALIZED, "SimpleNode: output port not initialized, node ", nodeName, ", port id ", elem.first);
172 }
173 func(*elem.second);
174 });
175 }
176
177 template <typename ModuleHandle_t>
178 dwStatus setModuleHandle(ModuleHandle_t handle, dwContextHandle_t context)
179 {
180 dwModuleHandle_t moduleHandle;
181
182 if (DW_NULL_HANDLE == handle)
183 {
184 return DW_INVALID_ARGUMENT;
185 }
186
187 dwStatus ret{getModuleHandle(&moduleHandle, handle, context)};
188 if (DW_SUCCESS != ret)
189 {
190 return ret;
191 }
192
193 return setObjectHandle(moduleHandle);
194 }
195
196 virtual dwStatus setObjectHandle(dwModuleHandle_t handle);
197
199 dwStatus getInputPort(const uint8_t portID, dw::framework::PortBase*& port) const override;
200
202 dwStatus getOutputPort(const uint8_t portID, dw::framework::PortBase*& port) const override;
203
204protected:
205 dwStatus getModuleHandle(dwModuleHandle_t* moduleHandle, void* handle, dwContextHandle_t context);
206
207 virtual std::unique_ptr<Pass> createSetupPass()
208 {
209 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleNode::createSetupPass() not implemented");
210 }
211
212 virtual std::unique_ptr<Pass> createTeardownPass()
213 {
214 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleNode::createTeardownPass() not implemented");
215 }
216
239 template <typename PassFunctionT, typename... Args>
240 std::unique_ptr<PassImpl<PassFunctionT>> make_pass(PassFunctionT func, Args&&... args)
241 {
242 return std::make_unique<PassImpl<PassFunctionT>>(*this, func, std::forward<Args>(args)...);
243 }
244
246
252 template <
253 typename NodeT, size_t PassIndex, typename PassFunctionT>
254 void registerPass(PassFunctionT func, std::initializer_list<std::pair<dwStatus, uint32_t>> const& returnMapping = {})
255 {
256 // coverity[autosar_cpp14_a5_1_1_violation]
257 if (!isValidPass<NodeT>(PassIndex))
258 {
259 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "registerPass called with an invalid pass id: ", PassIndex);
260 }
261 // coverity[autosar_cpp14_a5_1_1_violation] RFD Accepted: TID-2056
262 if (m_passList.size() == 0U || m_passList.size() - 1U < PassIndex)
263 {
264 // coverity[autosar_cpp14_a5_1_1_violation] RFD Accepted: TID-2056
265 m_passList.resize(PassIndex + 1U);
266 // coverity[autosar_cpp14_a5_1_1_violation] RFD Accepted: TID-2056
267 m_passOwnershipList.resize(PassIndex + 1U);
268 }
269 // coverity[autosar_cpp14_a5_1_1_violation]
270 if (m_passList[PassIndex] != nullptr)
271 {
272 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "registerPass called with a pass id which has been added before: ", PassIndex);
273 }
274 dwProcessorType processorType{passProcessorType<NodeT, PassIndex>()};
275 // coverity[autosar_cpp14_a5_1_1_violation]
276 m_passList[PassIndex] = std::make_unique<PassImpl<PassFunctionT>>(*this, func, processorType, returnMapping);
277 // coverity[autosar_cpp14_a5_1_1_violation]
278 m_passOwnershipList[PassIndex] = true;
279 }
280
282
285 template <
286 typename NodeT, size_t PassIndex, typename PassFunctionT>
287 void registerPass(PassFunctionT func, cudaStream_t const cudaStream, std::initializer_list<std::pair<dwStatus, uint32_t>> const& returnMapping = {})
288 {
289 static_assert(passProcessorType<NodeT, PassIndex>() == DW_PROCESSOR_TYPE_GPU, "The processor type of a pass with a cuda stream must be GPU");
290 registerPass<NodeT, PassIndex>(func, returnMapping);
291 m_passList[PassIndex]->m_cudaStream = cudaStream;
292 }
293
294public:
297 void addPass(Pass* pass);
298
305
313 dwStatus copyModuleHealthSignals(dwHealthSignal& outSignal);
314
324
334
335private:
336 dwStatus updateHealthSignalFromModule();
337
338 VectorFixed<std::unique_ptr<Pass>> m_passList;
339 // tracking ownership is only necessary until addPass(..., Pass* pass) is removed
340 VectorFixed<bool> m_passOwnershipList;
341 FixedString<MAX_NAME_LEN> m_name;
342 bool m_setupTeardownCreated;
343
345 dwGraphErrorSignal m_errorSignal;
346 dwGraphHealthSignal m_healthSignal;
347
348 dwModuleHandle_t m_object;
349 uint32_t m_iterationCount{};
350 uint32_t m_nodePeriod{};
351
352public:
354 template <typename TPort, typename... Args>
355 std::unique_ptr<TPort> make_port(Args&&... args)
356 {
357 std::unique_ptr<TPort> port{std::make_unique<TPort>(std::forward<Args>(args)...)};
358 port->setSyncRetriever(std::bind(&SimpleNode::getIterationCount, this));
359 return port;
360 }
361
363
366 template <typename NodeT, size_t PortIndex, typename... Args>
367 void initInputPort(Args&&... args)
368 {
369 static_assert(PortIndex < portSize<NodeT, PortDirection::INPUT>(), "Invalid port index");
370 using DataType = decltype(portType<NodeT, PortDirection::INPUT, PortIndex>());
371 auto port = std::make_shared<ManagedPortInput<DataType>>(std::forward<Args>(args)...);
372 if (m_inputPorts.find(PortIndex) != m_inputPorts.end())
373 {
374 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Input port with the following id registered multiple times: ", PortIndex);
375 }
376 m_inputPorts[PortIndex] = port;
377 }
378
380
383 template <typename NodeT, size_t PortIndex, typename... Args>
384 void initInputArrayPort(Args&&... args)
385 {
386 static_assert(PortIndex < portSize<NodeT, PortDirection::INPUT>(), "Invalid port index");
387 using DataType = decltype(portType<NodeT, PortDirection::INPUT, PortIndex>());
388 constexpr size_t descriptor_index = descriptorIndex<NodeT, PortDirection::INPUT, PortIndex>();
389 constexpr size_t arraySize = descriptorPortSize<NodeT, PortDirection::INPUT, descriptor_index>();
390 for (size_t i = 0; i < arraySize; ++i)
391 {
392 auto port = std::make_shared<ManagedPortInput<DataType>>(std::forward<Args>(args)...);
393 if (m_inputPorts.find(PortIndex + i) != m_inputPorts.end())
394 {
395 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Input port with the following id registered multiple times: ", PortIndex + i);
396 }
397 m_inputPorts[PortIndex + i] = port;
398 }
399 }
400
402
405 template <typename NodeT, size_t PortIndex, typename... Args>
406 void initOutputPort(Args&&... args)
407 {
408 static_assert(PortIndex - portSize<NodeT, PortDirection::INPUT>() < portSize<NodeT, PortDirection::OUTPUT>(), "Invalid port index");
409 using DataType = decltype(portType<NodeT, PortDirection::OUTPUT, PortIndex>());
410 std::shared_ptr<ManagedPortOutput<DataType>> port{std::make_shared<ManagedPortOutput<DataType>>(std::forward<Args>(args)...)};
411 if (m_outputPorts.find(PortIndex) != m_outputPorts.end())
412 {
413 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Output port with the following id registered multiple times: ", PortIndex);
414 }
415 m_outputPorts[PortIndex] = port;
416 }
417
419
422 template <typename NodeT, size_t PortIndex, typename... Args>
423 void initOutputArrayPort(Args&&... args)
424 {
425 static_assert(PortIndex - portSize<NodeT, PortDirection::INPUT>() < portSize<NodeT, PortDirection::OUTPUT>(), "Invalid port index");
426 using DataType = decltype(portType<NodeT, PortDirection::OUTPUT, PortIndex>());
427 // coverity[autosar_cpp14_a0_1_1_violation]
428 // coverity[autosar_cpp14_m0_1_4_violation]
429 constexpr size_t descriptor_index{descriptorIndex<NodeT, PortDirection::OUTPUT, PortIndex>()};
430 constexpr size_t arraySize{descriptorPortSize<NodeT, PortDirection::OUTPUT, descriptor_index>()};
431 for (size_t i{0U}; i < arraySize; ++i)
432 {
433 std::shared_ptr<ManagedPortOutput<DataType>> port{std::make_shared<ManagedPortOutput<DataType>>(std::forward<Args>(args)...)};
434 if (m_outputPorts.find(PortIndex + i) != m_outputPorts.end())
435 {
436 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Output port with the following id registered multiple times: ", PortIndex + i);
437 }
438 m_outputPorts[PortIndex + i] = port;
439 }
440 }
441
443 template <typename NodeT, size_t PortIndex>
445 {
446 static_assert(PortIndex < portSize<NodeT, PortDirection::INPUT>(), "Invalid port index");
447 constexpr bool isArray = descriptorPortArray<
448 NodeT, PortDirection::INPUT, descriptorIndex<NodeT, PortDirection::INPUT, PortIndex>()>();
449 static_assert(!isArray, "Input port is an array, must pass an array index");
450 if (m_inputPorts.find(PortIndex) == m_inputPorts.end())
451 {
452 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Input port with the following id not registered: ", PortIndex);
453 }
454 using DataType = decltype(portType<NodeT, PortDirection::INPUT, PortIndex>());
455 using PointerType = ManagedPortInput<DataType>;
456 using ReturnType = std::shared_ptr<PointerType>;
457 ReturnType port = std::dynamic_pointer_cast<PointerType>(m_inputPorts[PortIndex]);
458 if (!port)
459 {
460 throw ExceptionWithStatus(DW_BAD_CAST, "Failed to cast the following input port to its declared type: ", PortIndex);
461 }
462 return *port;
463 }
464
466 template <typename NodeT, size_t PortIndex>
468 {
469 static_assert(PortIndex < portSize<NodeT, PortDirection::INPUT>(), "Invalid port index");
470 constexpr bool isArray = descriptorPortArray<NodeT, PortDirection::INPUT, descriptorIndex<NodeT, PortDirection::INPUT, PortIndex>()>();
471 static_assert(isArray, "Input port is not an array, must not pass an array index");
472 constexpr size_t arraySize = descriptorPortSize<NodeT, PortDirection::INPUT, descriptorIndex<NodeT, PortDirection::INPUT, PortIndex>()>();
473 if (arrayIndex >= arraySize)
474 {
475 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "The array index is out of bound: ", arrayIndex);
476 }
477 if (m_inputPorts.find(PortIndex + arrayIndex) == m_inputPorts.end())
478 {
479 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Input port with the following id not registered: ", PortIndex + arrayIndex);
480 }
481 using DataType = decltype(portType<NodeT, PortDirection::INPUT, PortIndex>());
482 using PointerType = ManagedPortInput<DataType>;
483 using ReturnType = std::shared_ptr<PointerType>;
484 ReturnType port = std::dynamic_pointer_cast<PointerType>(m_inputPorts[PortIndex + arrayIndex]);
485 if (!port)
486 {
487 throw ExceptionWithStatus(DW_BAD_CAST, "Failed to cast the following input port to its declared type: ", PortIndex + arrayIndex);
488 }
489 return *port;
490 }
491
493 template <typename NodeT, size_t PortIndex>
495 {
496 static_assert(PortIndex - portSize<NodeT, PortDirection::INPUT>() < portSize<NodeT, PortDirection::OUTPUT>(), "Invalid port index");
497 constexpr bool isArray = descriptorPortArray<
498 NodeT, PortDirection::OUTPUT, descriptorIndex<NodeT, PortDirection::OUTPUT, PortIndex>()>();
499 static_assert(!isArray, "Output port is an array, must pass an array index");
500 if (m_outputPorts.find(PortIndex) == m_outputPorts.end())
501 {
502 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Output port with the following id not registered: ", PortIndex);
503 }
504 using DataType = decltype(portType<NodeT, PortDirection::OUTPUT, PortIndex>());
505 using PointerType = ManagedPortOutput<DataType>;
506 using ReturnType = std::shared_ptr<PointerType>;
507 ReturnType port = std::dynamic_pointer_cast<PointerType>(m_outputPorts[PortIndex]);
508 if (!port)
509 {
510 throw ExceptionWithStatus(DW_BAD_CAST, "Failed to cast the following output port to its declared type: ", PortIndex);
511 }
512 return *port;
513 }
514
516 template <typename NodeT, size_t PortIndex>
518 {
519 static_assert(PortIndex - portSize<NodeT, PortDirection::INPUT>() < portSize<NodeT, PortDirection::OUTPUT>(), "Invalid port index");
520 constexpr bool isArray = descriptorPortArray<NodeT, PortDirection::OUTPUT, descriptorIndex<NodeT, PortDirection::OUTPUT, PortIndex>()>();
521 static_assert(isArray, "Output port is not an array, must not pass an array index");
522 constexpr size_t arraySize = descriptorPortSize<NodeT, PortDirection::OUTPUT, descriptorIndex<NodeT, PortDirection::OUTPUT, PortIndex>()>();
523 if (arrayIndex >= arraySize)
524 {
525 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "The array index is out of bound: ", arrayIndex);
526 }
527 if (m_outputPorts.find(PortIndex + arrayIndex) == m_outputPorts.end())
528 {
529 throw ExceptionWithStatus(DW_INVALID_ARGUMENT, "Output port with the following id not registered: ", PortIndex + arrayIndex);
530 }
531 using DataType = decltype(portType<NodeT, PortDirection::OUTPUT, PortIndex>());
532 using PointerType = ManagedPortOutput<DataType>;
533 using ReturnType = std::shared_ptr<PointerType>;
534 ReturnType port = std::dynamic_pointer_cast<PointerType>(m_outputPorts[PortIndex + arrayIndex]);
535 if (!port)
536 {
537 throw ExceptionWithStatus(DW_BAD_CAST, "Failed to cast the following output port to its declared type: ", PortIndex + arrayIndex);
538 }
539 return *port;
540 }
541
543
547 dwStatus setup();
548
550
554 dwStatus teardown();
555
557
561 void resetPorts() override;
562
567 dwStatus setIterationCount(uint32_t iterationCount) override;
568
573 dwStatus setNodePeriod(uint32_t period) override;
574
575 const dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortInputBase>>& getRegisteredInputPorts() const
576 {
577 return m_inputPorts;
578 }
579
580 const dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortOutputBase>>& getRegisteredOutputPorts() const
581 {
582 return m_outputPorts;
583 }
584
585 uint32_t getIterationCount() const;
586 uint32_t getNodePeriod() const;
591 dwStatus setState(const char* state) override
592 {
593 static_cast<void>(state);
594 return DW_SUCCESS;
595 }
596
597protected:
598 dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortInputBase>> m_inputPorts;
599 dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortOutputBase>> m_outputPorts;
600
601 std::atomic<bool> m_asyncResetFlag;
602};
603
604// coverity[autosar_cpp14_a0_1_6_violation]
606{
607public:
608 dwStatus start() override
609 {
610 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleSensorNode::start() not implemented");
611 }
612
613 dwStatus stop() override
614 {
615 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleSensorNode::stop() not implemented");
616 }
617
618 dwStatus isVirtual(bool*) override
619 {
620 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleSensorNode::isVirtual() not implemented");
621 }
622
624 {
625 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleSensorNode::setDataEventReadCallback() not implemented");
626 }
627
629 {
630 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "SimpleSensorNode::setDataEventWriteCallback() not implemented");
631 }
632};
633
635// coverity[autosar_cpp14_a0_1_6_violation]
636// coverity[autosar_cpp14_a12_1_6_violation]
638{
639public:
642};
643
644} // namespace framework
645} // namespace dw
646
647#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.
dw::core::Function< bool(DataEvent &)> DataEventReadCallback
Definition: Node.hpp:377
dw::core::Function< void(DataEvent)> DataEventWriteCallback
Definition: Node.hpp:386
static constexpr const uint32_t MAX_PORT_COUNT
Definition: Node.hpp:77
static constexpr const uint32_t MAX_PASS_COUNT
Definition: Node.hpp:81
Pass is a runnable describes the metadata of a pass.
Definition: Pass.hpp:49
dw::core::HeapHashMap< size_t, std::shared_ptr< ManagedPortInputBase > > m_inputPorts
Definition: SimpleNode.hpp:598
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:517
dwStatus getInputChannel(const uint8_t portID, ChannelObject *&channel) const override
Gets the input channel associated with the input port.
dwStatus reset() override
Definition: SimpleNode.hpp:84
void iterateManagedInputPorts(Func func)
Definition: SimpleNode.hpp:150
dwStatus setNodePeriod(uint32_t period) override
dwStatus validate() override
Definition: SimpleNode.hpp:112
dwStatus setInputChannel(ChannelObject *, uint8_t, dwSerializationType) override
Definition: SimpleNode.hpp:95
void initInputPort(Args &&... args)
Initialize a ManagedPortInput which will be owned by the base class and can be retrieved using getInp...
Definition: SimpleNode.hpp:367
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 copyModuleHealthSignals(dwHealthSignal &outSignal)
Copy health signals from the module over to the node and stores in outSignal.
uint32_t getNodePeriod() const
void initInputArrayPort(Args &&... args)
Initialize an array of ManagedPortInput which will be owned by the base class and can be retrieved us...
Definition: SimpleNode.hpp:384
SimpleNode(NodeAllocationParams params)
Constructor which tailors the preallocated size of the internal collections for ports and passes to t...
dwStatus setInputChannel(ChannelObject *channel, uint8_t portID) override
Associate an input port with a channel instances.
size_t getPassCount() const noexcept override
dwStatus clearHealthSignal() override
dwStatus getPass(Pass **pass, uint8_t index) override
dwStatus setName(const char *name) final
const dw::core::HeapHashMap< size_t, std::shared_ptr< ManagedPortOutputBase > > & getRegisteredOutputPorts() const
Definition: SimpleNode.hpp:580
dwStatus getOutputChannel(const uint8_t portID, ChannelObject *&channel) const override
Gets the output channel associated with the output port.
uint32_t getIterationCount() const
dwStatus setModuleHandle(ModuleHandle_t handle, dwContextHandle_t context)
Definition: SimpleNode.hpp:178
dwStatus updateCurrentErrorSignal(dwGraphErrorSignal &signal) override
A function that allows user override to update error signal It is automatically called by dwFramework...
virtual std::unique_ptr< Pass > createTeardownPass()
Definition: SimpleNode.hpp:212
const dw::core::HeapHashMap< size_t, std::shared_ptr< ManagedPortInputBase > > & getRegisteredInputPorts() const
Definition: SimpleNode.hpp:575
void iterateManagedOutputPorts(Func func)
Definition: SimpleNode.hpp:164
void addPass(Pass *pass)
dwStatus run() override
void resetPorts() override
Default implementation to reset ports managed by the base class.
dwStatus setState(const char *state) override
Definition: SimpleNode.hpp:591
dwStatus getName(const char **name) override
virtual std::unique_ptr< Pass > createSetupPass()
Definition: SimpleNode.hpp:207
dwStatus runPass(size_t passIndex) override
dwStatus getErrorSignal(dwGraphErrorSignal &sehErrorSignal, dwGraphErrorSignal *&errorSignal, uint16_t const sourceId, char8_t const *instanceName=nullptr) override
std::unique_ptr< TPort > make_port(Args &&... args)
Definition: SimpleNode.hpp:355
std::unique_ptr< PassImpl< PassFunctionT > > make_pass(PassFunctionT func, Args &&... args)
Definition: SimpleNode.hpp:240
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:287
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:254
dwStatus getHealthSignal(dwGraphHealthSignal *&healthSignals, bool updateFromModule=false) override
dwStatus getPasses(VectorFixed< Pass * > &passList) override
dwStatus getModuleHandle(dwModuleHandle_t *moduleHandle, void *handle, dwContextHandle_t context)
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:444
void initOutputPort(Args &&... args)
Initialize a ManagedPortOutput which will be owned by the base class and can be retrieved using getOu...
Definition: SimpleNode.hpp:406
void iteratePorts(PortList &portList, Func func)
Definition: SimpleNode.hpp:141
dwStatus getInputPort(const uint8_t portID, dw::framework::PortBase *&port) const override
Gets the input port associated with the input port Id.
dwStatus getOutputPort(const uint8_t portID, dw::framework::PortBase *&port) const override
Gets the output port associated with the output port Id.
virtual dwStatus setObjectHandle(dwModuleHandle_t handle)
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:467
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 setOutputChannel(ChannelObject *channel, uint8_t portID) override
Associate an output port with a channel instances.
std::atomic< bool > m_asyncResetFlag
Definition: SimpleNode.hpp:601
void initOutputArrayPort(Args &&... args)
Initialize an array of ManagedPortOutput which will be owned by the base class and can be retrieved u...
Definition: SimpleNode.hpp:423
dw::core::HeapHashMap< size_t, std::shared_ptr< ManagedPortOutputBase > > m_outputPorts
Definition: SimpleNode.hpp:599
ManagedPortOutput< decltype(portType< NodeT, PortDirection::OUTPUT, PortIndex >())> & getOutputPort()
Get a previously initialized non-array ManagedPortOutput.
Definition: SimpleNode.hpp:494
SimpleProcessNode(NodeAllocationParams params)
dwStatus isVirtual(bool *) override
Definition: SimpleNode.hpp:618
dwStatus setDataEventWriteCallback(DataEventWriteCallback) override
Definition: SimpleNode.hpp:628
dwStatus setDataEventReadCallback(DataEventReadCallback) override
Definition: SimpleNode.hpp:623
constexpr bool descriptorPortArray()
dwSerializationType
Definition: Types.hpp:43
constexpr size_t passIndex(dw::core::StringView identifier)
Get the the pass index for a pass identified by name.
NodeAllocationParams createAllocationParams()
Definition: SimpleNode.hpp:67
Definition: Buffer.hpp:40