• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.14
    All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
    SimpleNodeT.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_SIMPLENODET_HPP_
    32#define DW_FRAMEWORK_SIMPLENODET_HPP_
    33
    38
    40#define NODE_GET_INPUT_PORT_INDEX(identifier) dw::framework::portIndex<NodeT, dw::framework::PortDirection::INPUT>(identifier)
    42#define NODE_GET_OUTPUT_PORT_INDEX(identifier) dw::framework::portIndex<NodeT, dw::framework::PortDirection::OUTPUT>(identifier)
    43
    45
    49#define NODE_REGISTER_PASS(identifier, ...) this->template registerPass<NodeT, dw::framework::passIndex<NodeT>(identifier)>(__VA_ARGS__)
    50
    52
    56#define NODE_INIT_INPUT_PORT(identifier, ...) \
    57 this->template initInputPort<NodeT, dw::framework::portIndex<NodeT, dw::framework::PortDirection::INPUT>(identifier)>(__VA_ARGS__)
    59
    65#define NODE_INIT_INPUT_ARRAY_PORTS(identifier, ...) \
    66 this->template initInputArrayPorts<NodeT, dw::framework::portIndex<NodeT, dw::framework::PortDirection::INPUT>(identifier)>(__VA_ARGS__)
    68
    72#define NODE_INIT_INPUT_ARRAY_PORT(identifier, arrayIndex, ...) \
    73 this->template initInputArrayPort<NodeT, dw::framework::portIndex<NodeT, dw::framework::PortDirection::INPUT>(identifier)>(arrayIndex, __VA_ARGS__)
    75
    79#define NODE_INIT_OUTPUT_PORT(identifier, ...) \
    80 this->template initOutputPort<NodeT, dw::framework::portIndex<NodeT, dw::framework::PortDirection::OUTPUT>(identifier)>(__VA_ARGS__)
    82
    88#define NODE_INIT_OUTPUT_ARRAY_PORTS(identifier, ...) \
    89 this->template initOutputArrayPorts<NodeT, dw::framework::portIndex<NodeT, dw::framework::PortDirection::OUTPUT>(identifier)>(__VA_ARGS__)
    91
    95#define NODE_INIT_OUTPUT_ARRAY_PORT(identifier, arrayIndex, ...) \
    96 this->template initOutputArrayPort<NodeT, dw::framework::portIndex<NodeT, dw::framework::PortDirection::OUTPUT>(identifier)>(arrayIndex, __VA_ARGS__)
    97
    99
    102#define NODE_GET_INPUT_PORT(identifier) this->template getInputPort<NodeT, NODE_GET_INPUT_PORT_INDEX(identifier)>()
    104
    107#define NODE_GET_INPUT_ARRAY_PORT(identifier, index) this->template getInputPort<NodeT, NODE_GET_INPUT_PORT_INDEX(identifier)>(index)
    109
    112#define NODE_GET_OUTPUT_PORT(identifier) this->template getOutputPort<NodeT, NODE_GET_OUTPUT_PORT_INDEX(identifier)>()
    114
    117#define NODE_GET_OUTPUT_ARRAY_PORT(identifier, index) this->template getOutputPort<NodeT, NODE_GET_OUTPUT_PORT_INDEX(identifier)>(index)
    118
    119namespace dw
    120{
    121namespace framework
    122{
    123
    124// coverity[autosar_cpp14_a14_1_1_violation]
    125template <typename T>
    126// coverity[autosar_cpp14_a12_1_6_violation]
    128{
    129public:
    130 // coverity[autosar_cpp14_a0_1_6_violation]
    131 using NodeT = T;
    132
    136 {
    137 initialize();
    138 }
    139
    141 : SimpleNode(params)
    142 {
    143 initialize();
    144 }
    145
    147 virtual dwStatus setupImpl()
    148 {
    149 return this->setup();
    150 }
    151
    153 virtual dwStatus teardownImpl()
    154 {
    155 return this->teardown();
    156 }
    157
    159 dwStatus reset() override
    160 {
    161 this->resetPorts();
    162 return DW_SUCCESS;
    163 }
    164
    166 dwStatus validate() override
    167 {
    168 if (getRegisteredInputPorts().empty() && getRegisteredOutputPorts().empty())
    169 {
    170 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "Not implemented");
    171 }
    172
    173 // coverity[autosar_cpp14_a18_5_8_violation]
    174 const PortCollectionDescriptor inputPortDescs{createPortCollectionDescriptor<NodeT, PortDirection::INPUT>()};
    175 // coverity[autosar_cpp14_a5_1_1_violation]
    176 dwStatus status{SimpleNode::validate("input", inputPortDescs,
    177 [&](size_t portIdx) -> bool {
    178 const dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortInputBase>>& registeredPorts{getRegisteredInputPorts()};
    179 dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortInputBase>>::const_iterator it{registeredPorts.find(portIdx)};
    180 if (it == registeredPorts.end())
    181 {
    182 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "Input port was not registered");
    183 }
    184 if (it->second.get() == nullptr)
    185 {
    186 throw ExceptionWithStatus(DW_NOT_INITIALIZED, "Input port was not initialized");
    187 }
    188 return it->second->isBound();
    189 })};
    190 if (status != DW_SUCCESS)
    191 {
    192 return status;
    193 }
    194 const PortCollectionDescriptor outputPortDescs{createPortCollectionDescriptor<NodeT, PortDirection::OUTPUT>()};
    195 size_t outputPortOffset{inputPortDescs.getPortSize()};
    196 // coverity[autosar_cpp14_a5_1_1_violation]
    197 return SimpleNode::validate("output", outputPortDescs,
    198 [&](size_t portIdx) -> bool {
    199 const dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortOutputBase>>& registeredPorts{getRegisteredOutputPorts()};
    200 dw::core::HeapHashMap<size_t, std::shared_ptr<ManagedPortOutputBase>>::const_iterator it{registeredPorts.find(portIdx + outputPortOffset)};
    201 if (it == registeredPorts.end())
    202 {
    203 throw ExceptionWithStatus(DW_NOT_IMPLEMENTED, "Output port was not registered");
    204 }
    205 if (it->second.get() == nullptr)
    206 {
    207 throw ExceptionWithStatus(DW_NOT_INITIALIZED, "Output port was not initialized");
    208 }
    209 return it->second->isBound();
    210 });
    211 }
    212
    213private:
    214 void initialize()
    215 {
    216 NODE_REGISTER_PASS("SETUP"_sv, [this]() -> dwStatus {
    217 return setupImpl();
    218 },
    219 {{DW_NOT_AVAILABLE, 0U}});
    220 NODE_REGISTER_PASS("TEARDOWN"_sv, [this]() -> dwStatus {
    221 return teardownImpl();
    222 });
    223 }
    224};
    225
    226} // namespace framework
    227} // namespace dw
    228
    229#endif // DW_FRAMEWORK_SIMPLENODET_HPP_
    #define NODE_REGISTER_PASS(identifier,...)
    Register a pass function with the node base class.
    Definition: SimpleNodeT.hpp:49
    dwStatus validate() override
    Validate that all registered ports which have the flag binding-required are bound to a channel.
    SimpleNodeT()
    Default constructor registering the setup and teardown passes.
    virtual dwStatus setupImpl()
    The default implementation calls SimpleNode::setup.
    SimpleNodeT(NodeAllocationParams params)
    virtual dwStatus teardownImpl()
    The default implementation calls SimpleNode::teardown.
    dwStatus reset() override
    The default implementation calls SimpleNode::resetPorts.
    dwStatus validate() override
    Definition: SimpleNode.hpp:116
    const dw::core::HeapHashMap< size_t, std::shared_ptr< ManagedPortOutputBase > > & getRegisteredOutputPorts() const
    Definition: SimpleNode.hpp:564
    const dw::core::HeapHashMap< size_t, std::shared_ptr< ManagedPortInputBase > > & getRegisteredInputPorts() const
    Definition: SimpleNode.hpp:559
    void resetPorts() override
    Default implementation to reset ports managed by the base class.
    dwStatus setup()
    Default implementation of the setup pass.
    dwStatus teardown()
    Default implementation of the teardown pass.
    NodeAllocationParams createAllocationParams()
    Definition: SimpleNode.hpp:78
    Definition: Buffer.hpp:40
    人人超碰97caoporen国产