• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.8
    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-2022 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/Types.hpp>
    35#include <dwcgf/Exception.hpp>
    37#include <dw/core/container/StringView.hpp>
    38
    39namespace dw
    40{
    41namespace framework
    42{
    43
    45class Node;
    46
    48class Pass
    49{
    50public:
    52 // coverity[autosar_cpp14_a0_1_1_violation]
    53 // coverity[autosar_cpp14_m0_1_4_violation]
    54 static constexpr size_t MAX_NAME_LEN{256U};
    55
    57 virtual ~Pass() = default;
    59 Pass(Pass const&) = delete;
    61 Pass(Pass&&) = delete;
    63 Pass& operator=(Pass const&) & = delete;
    65 Pass& operator=(Pass&&) & = delete;
    66
    68 virtual dwStatus run() = 0;
    69
    71 virtual void setRunnableId(dw::core::StringView const& runnableId) = 0;
    73 virtual dw::core::FixedString<MAX_NAME_LEN> const& getRunnableId(bool isSubmitPass) const = 0;
    74
    76 virtual Node& getNode() const = 0;
    77
    79 dwProcessorType m_processor;
    81 dwProcessType m_processType;
    82
    84 dwTime_t m_minTime;
    86 dwTime_t m_avgTime;
    88 dwTime_t m_maxTime;
    89
    91 cudaStream_t m_cudaStream;
    93 NvMediaDla* m_dlaEngine;
    94
    99
    100protected:
    102 // TODO(dwplc): FP -- This constructor is called by the PassImpl constructor below
    103 // coverity[autosar_cpp14_m0_1_10_violation]
    104 Pass(dwProcessorType const processor,
    105 dwProcessType const processType,
    106 dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime) noexcept
    107 : m_processor(processor)
    108 , m_processType(processType)
    109 , m_minTime(minTime)
    110 , m_avgTime(avgTime)
    111 , m_maxTime(maxTime)
    112 , m_cudaStream(DW_NULL_HANDLE)
    113 , m_dlaEngine(nullptr)
    114 , m_isFirstIteration(true)
    115 {
    116 }
    117};
    118
    120template <typename PassFunctionT>
    121class PassImpl : public Pass
    122{
    123 static_assert(std::is_convertible<PassFunctionT, std::function<dwStatus()>>::value, "PassFunctionT must be callable without arguments and return dwStatus");
    124
    125public:
    128 PassFunctionT const passFunc,
    129 dwProcessorType const processor,
    130 dwProcessType const processType,
    131 dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime)
    132 : Pass(processor, processType, minTime, avgTime, maxTime)
    133 , m_node(node)
    134 , m_functionInt(passFunc)
    135 {
    136 }
    137
    140 PassFunctionT const passFunc,
    141 dwProcessorType const processor,
    142 dwProcessType const processType,
    143 dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime,
    144 cudaStream_t const cudaStream)
    145 : Pass(processor, processType, minTime, avgTime, maxTime)
    146 , m_node(node)
    147 , m_functionInt(passFunc)
    148 {
    149 if (processor == DW_PROCESSOR_TYPE_GPU)
    150 {
    152 }
    153 else
    154 {
    155 throw Exception(DW_NOT_SUPPORTED, "PassImpl: Only GPU passes can use a cuda stream");
    156 }
    157 }
    158
    161 PassFunctionT const passFunc,
    162 dwProcessorType const processor,
    163 dwProcessType const processType,
    164 dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime,
    165 NvMediaDla* const dlaEngine)
    166 : Pass(processor, processType, minTime, avgTime, maxTime)
    167 , m_node(node)
    168 , m_functionInt(passFunc)
    169 {
    170 if (processor == DW_PROCESSOR_TYPE_DLA_0 || processor == DW_PROCESSOR_TYPE_DLA_1)
    171 {
    172 m_dlaEngine = dlaEngine;
    173 }
    174 else
    175 {
    176 throw Exception(DW_NOT_SUPPORTED, "PassImpl: Only DLA passes can use a DLA handle");
    177 }
    178 }
    179
    181 dwStatus run() final
    182 {
    183 // TODO(DRIV-7184) - return code of the function shall not be ignored
    184 return Exception::guard([&] {
    185 m_functionInt();
    186 },
    187 dw::core::Logger::Verbosity::WARN);
    188 }
    189
    191 void setRunnableId(dw::core::StringView const& runnableId) final
    192 {
    193 if (runnableId.size() >= 128 - 10 - 1)
    194 {
    195 throw Exception(DW_BUFFER_FULL, "setRunnableId() runnable id exceeds capacity: ", runnableId);
    196 }
    197 m_runnableId = dw::core::FixedString<128>(runnableId.data(), runnableId.size());
    198 m_runnableIdSubmit = dw::core::FixedString<128>(runnableId.data(), runnableId.size());
    199 m_runnableIdSubmit += "_submittee";
    200 }
    201
    203 dw::core::FixedString<MAX_NAME_LEN> const& getRunnableId(bool isSubmitPass) const final
    204 {
    205 if (isSubmitPass)
    206 {
    207 return m_runnableIdSubmit;
    208 }
    209 return m_runnableId;
    210 }
    211
    213 Node& getNode() const final
    214 {
    215 return m_node;
    216 }
    217
    218private:
    220 Node& m_node;
    222 PassFunctionT m_functionInt;
    224 dw::core::FixedString<MAX_NAME_LEN> m_runnableId;
    226 dw::core::FixedString<MAX_NAME_LEN> m_runnableIdSubmit;
    227};
    228
    229} // namespace framework
    230} // namespace dw
    231
    232#endif // DW_FRAMEWORK_PASS_HPP_
    static dwStatus guard(TryBlock tryBlock, dw::core::Logger::Verbosity verbosity=dw::core::Logger::Verbosity::DEBUG)
    Definition: Exception.hpp:228
    PassImpl contains the function to invoke on run().
    Definition: Pass.hpp:122
    dwStatus run() final
    Definition: Pass.hpp:181
    PassImpl(Node &node, PassFunctionT const passFunc, dwProcessorType const processor, dwProcessType const processType, dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime, cudaStream_t const cudaStream)
    Constructor with a function running on a GPU.
    Definition: Pass.hpp:139
    void setRunnableId(dw::core::StringView const &runnableId) final
    Definition: Pass.hpp:191
    Node & getNode() const final
    Definition: Pass.hpp:213
    dw::core::FixedString< MAX_NAME_LEN > const & getRunnableId(bool isSubmitPass) const final
    Definition: Pass.hpp:203
    PassImpl(Node &node, PassFunctionT const passFunc, dwProcessorType const processor, dwProcessType const processType, dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime)
    Constructor with a function running on a CPU.
    Definition: Pass.hpp:127
    PassImpl(Node &node, PassFunctionT const passFunc, dwProcessorType const processor, dwProcessType const processType, dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime, NvMediaDla *const dlaEngine)
    Constructor with a function running on a DLA.
    Definition: Pass.hpp:160
    Pass is a runnable describes the metadata of a pass.
    Definition: Pass.hpp:49
    Pass(Pass const &)=delete
    Copy constructor.
    dwTime_t m_minTime
    Definition: Pass.hpp:84
    dwTime_t m_avgTime
    Definition: Pass.hpp:86
    virtual Node & getNode() const =0
    Get the node this pass belongs to.
    bool m_isFirstIteration
    Definition: Pass.hpp:98
    cudaStream_t m_cudaStream
    The cuda stream to use in case the processor type is GPU.
    Definition: Pass.hpp:91
    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:79
    Pass(dwProcessorType const processor, dwProcessType const processType, dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime) noexcept
    Constructor.
    Definition: Pass.hpp:104
    dwProcessType m_processType
    The process type this pass runs with.
    Definition: Pass.hpp:81
    virtual dwStatus run()=0
    Run the pass.
    static constexpr size_t MAX_NAME_LEN
    The maximum length of the runnable id.
    Definition: Pass.hpp:54
    dwTime_t m_maxTime
    Definition: Pass.hpp:88
    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.
    NvMediaDla * m_dlaEngine
    The dla engine to run on in case the processor type is GPU.
    Definition: Pass.hpp:93
    cudaStream_t cudaStream
    Definition: dwIcpNode.hpp:60
    Definition: Exception.hpp:47
    人人超碰97caoporen国产