• <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
    Pass.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) 2018-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_PASS_HPP_
    32#define DW_FRAMEWORK_PASS_HPP_
    33
    34#include <dwcgf/Exception.hpp>
    36#include <dwshared/dwfoundation/dw/core/container/StringView.hpp>
    37#include <dwshared/dwfoundation/dw/core/container/HashContainer.hpp>
    38
    39namespace dw
    40{
    41namespace framework
    42{
    43
    45class Node;
    46
    48class Pass
    49{
    50public:
    52 // coverity[autosar_cpp14_a0_1_1_violation] FP: nvbugs/2813925
    53 // coverity[autosar_cpp14_a5_1_1_violation] FP: nvbugs/4020293
    54 // coverity[autosar_cpp14_m0_1_4_violation] FP: nvbugs/2813925
    55 static constexpr const size_t MAX_NAME_LEN{256U};
    56
    58 virtual ~Pass() = default;
    60 Pass(Pass const&) = delete;
    62 Pass(Pass&&) = delete;
    64 Pass& operator=(Pass const&) & = delete;
    66 Pass& operator=(Pass&&) & = delete;
    67
    69 const dw::core::StringView& getName() const;
    70
    72 virtual dwStatus run() = 0;
    73
    75 virtual void setRunnableId(dw::core::StringView const& runnableId) = 0;
    77 virtual dw::core::FixedString<MAX_NAME_LEN> const& getRunnableId(bool isSubmitPass) const = 0;
    79 dw::core::HeapHashMap<dwStatus, uint32_t> const& getPassReturnErrorMap();
    80
    82 virtual Node& getNode() const = 0;
    83
    85 dwProcessorType m_processor;
    86
    88 cudaStream_t m_cudaStream;
    89
    94
    95protected:
    97 Pass(const dw::core::StringView& name, dwProcessorType const processor,
    98 std::initializer_list<std::pair<dwStatus, uint32_t>> const& returnMapping = {});
    99
    100private:
    102 dw::core::StringView m_name;
    103
    105 dw::core::HeapHashMap<dwStatus, uint32_t> m_passReturnErrorMapping;
    106};
    107
    109template <typename PassFunctionT>
    110class PassImpl : public Pass
    111{
    112 static_assert(std::is_convertible<PassFunctionT, std::function<dwStatus()>>::value, "PassFunctionT must be callable without arguments and return dwStatus");
    113
    114public:
    117 const dw::core::StringView& name,
    118 PassFunctionT const passFunc,
    119 dwProcessorType const processor,
    120 std::initializer_list<std::pair<dwStatus, uint32_t>> const& returnMapping = {})
    121 : Pass(name, processor, returnMapping)
    122 , m_node(node)
    123 , m_functionInt(passFunc)
    124 {
    125 }
    126
    128 dwStatus run() final
    129 {
    130 // TODO(DRIV-7184) - return code of the function shall not be ignored
    131 return ExceptionGuard::guard([&] {
    132 m_functionInt();
    133 },
    134 dw::core::Logger::Verbosity::ERROR);
    135 }
    136
    138 void setRunnableId(dw::core::StringView const& runnableId) final
    139 {
    140 // coverity[autosar_cpp14_a5_1_1_violation]
    141 if (runnableId.size() >= MAX_NAME_LEN - 10U - 1U)
    142 {
    143 throw ExceptionWithStatus(DW_BUFFER_FULL, "setRunnableId() runnable id exceeds capacity: ", runnableId);
    144 }
    145 m_runnableId = dw::core::FixedString<MAX_NAME_LEN>(runnableId.data(), runnableId.size());
    146 m_runnableIdSubmit = dw::core::FixedString<MAX_NAME_LEN>(runnableId.data(), runnableId.size());
    147 // coverity[autosar_cpp14_a5_1_1_violation]
    148 m_runnableIdSubmit += "_submittee";
    149 }
    150
    152 dw::core::FixedString<MAX_NAME_LEN> const& getRunnableId(bool isSubmitPass) const final
    153 {
    154 if (isSubmitPass)
    155 {
    156 return m_runnableIdSubmit;
    157 }
    158 return m_runnableId;
    159 }
    160
    162 Node& getNode() const final
    163 {
    164 return m_node;
    165 }
    166
    167private:
    169 Node& m_node;
    171 PassFunctionT m_functionInt;
    173 dw::core::FixedString<MAX_NAME_LEN> m_runnableId;
    175 dw::core::FixedString<MAX_NAME_LEN> m_runnableIdSubmit;
    176};
    177
    178} // namespace framework
    179} // namespace dw
    180
    181#endif // DW_FRAMEWORK_PASS_HPP_
    static dwStatus guard(TryBlock const &tryBlock, ::dw::core::Logger::Verbosity verbosity=::dw::core::Logger::Verbosity::ERROR)
    Definition: Exception.hpp:167
    PassImpl contains the function to invoke on run().
    Definition: Pass.hpp:111
    dwStatus run() final
    Definition: Pass.hpp:128
    void setRunnableId(dw::core::StringView const &runnableId) final
    Definition: Pass.hpp:138
    Node & getNode() const final
    Definition: Pass.hpp:162
    dw::core::FixedString< MAX_NAME_LEN > const & getRunnableId(bool isSubmitPass) const final
    Definition: Pass.hpp:152
    PassImpl(Node &node, const dw::core::StringView &name, PassFunctionT const passFunc, dwProcessorType const processor, std::initializer_list< std::pair< dwStatus, uint32_t > > const &returnMapping={})
    Constructor with a function running on the given processor type.
    Definition: Pass.hpp:116
    Pass is a runnable describes the metadata of a pass.
    Definition: Pass.hpp:49
    Pass(Pass const &)=delete
    Copy constructor.
    virtual Node & getNode() const =0
    Get the node this pass belongs to.
    bool m_isFirstIteration
    Definition: Pass.hpp:93
    cudaStream_t m_cudaStream
    The cuda stream to use in case the processor type is GPU.
    Definition: Pass.hpp:88
    Pass(Pass &&)=delete
    Move constructor.
    virtual void setRunnableId(dw::core::StringView const &runnableId)=0
    Set the runnable id.
    dwProcessorType m_processor
    The processor type this pass runs on.
    Definition: Pass.hpp:85
    dw::core::HeapHashMap< dwStatus, uint32_t > const & getPassReturnErrorMap()
    Get the return status code to error map.
    const dw::core::StringView & getName() const
    Get the name of the pass.
    Pass(const dw::core::StringView &name, dwProcessorType const processor, std::initializer_list< std::pair< dwStatus, uint32_t > > const &returnMapping={})
    Constructor.
    virtual dwStatus run()=0
    Run the pass.
    static constexpr const size_t MAX_NAME_LEN
    The maximum length of the runnable id.
    Definition: Pass.hpp:55
    virtual ~Pass()=default
    Destructor.
    Pass & operator=(Pass const &) &=delete
    Copy assignment operator.
    Pass & operator=(Pass &&) &=delete
    Move assignment operator.
    virtual dw::core::FixedString< MAX_NAME_LEN > const & getRunnableId(bool isSubmitPass) const =0
    Get the runnable id.
    Definition: Buffer.hpp:40
    人人超碰97caoporen国产