• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.6
    All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros 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#include <dw/trace/Trace.hpp>
    39
    40namespace dw
    41{
    42namespace framework
    43{
    44
    46class Node;
    47
    49class Pass
    50{
    51public:
    53 // coverity[autosar_cpp14_a0_1_1_violation]
    54 // coverity[autosar_cpp14_m0_1_4_violation]
    55 static constexpr 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 virtual dwStatus run() = 0;
    70
    72 virtual void setRunnableId(dw::core::StringView const& runnableId) = 0;
    74 virtual dw::core::FixedString<MAX_NAME_LEN> const& getRunnableId(bool isSubmitPass) const = 0;
    75
    77 virtual Node& getNode() const = 0;
    78
    80 // coverity[autosar_cpp14_m11_0_1_violation]
    81 dwProcessorType m_processor;
    83 // coverity[autosar_cpp14_m11_0_1_violation]
    84 dwProcessType m_processType;
    85
    87 // coverity[autosar_cpp14_m11_0_1_violation]
    88 dwTime_t m_minTime;
    90 // coverity[autosar_cpp14_m11_0_1_violation]
    91 dwTime_t m_avgTime;
    93 // coverity[autosar_cpp14_m11_0_1_violation]
    94 dwTime_t m_maxTime;
    95
    97 // coverity[autosar_cpp14_m11_0_1_violation]
    98 cudaStream_t m_cudaStream;
    100 // coverity[autosar_cpp14_m11_0_1_violation]
    101 NvMediaDla* m_dlaEngine;
    102
    103protected:
    105 // TODO(dwplc): FP -- This constructor is called by the PassImpl constructor below
    106 // coverity[autosar_cpp14_m0_1_10_violation]
    107 Pass(dwProcessorType const processor,
    108 dwProcessType const processType,
    109 dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime) noexcept
    110 : m_processor(processor)
    111 , m_processType(processType)
    112 , m_minTime(minTime)
    113 , m_avgTime(avgTime)
    114 , m_maxTime(maxTime)
    115 , m_cudaStream(DW_NULL_HANDLE)
    116 , m_dlaEngine(nullptr)
    117 {
    118 }
    119};
    120
    122template <typename PassFunctionT>
    123class PassImpl : public Pass
    124{
    125 static_assert(std::is_convertible<PassFunctionT, std::function<dwStatus()>>::value, "PassFunctionT must be callable without arguments and return dwStatus");
    126
    127public:
    129 // coverity[autosar_cpp14_a8_4_8_violation]
    131 PassFunctionT const passFunc,
    132 dwProcessorType const processor,
    133 dwProcessType const processType,
    134 dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime)
    135 : Pass(processor, processType, minTime, avgTime, maxTime)
    136 , m_node(node)
    137 , m_functionInt(passFunc)
    138 {
    139 }
    140
    142 // coverity[autosar_cpp14_a8_4_8_violation]
    144 PassFunctionT const passFunc,
    145 dwProcessorType const processor,
    146 dwProcessType const processType,
    147 dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime,
    148 cudaStream_t const cudaStream)
    149 : Pass(processor, processType, minTime, avgTime, maxTime)
    150 , m_node(node)
    151 , m_functionInt(passFunc)
    152 {
    153 if (processor == DW_PROCESSOR_TYPE_GPU)
    154 {
    155 m_cudaStream = cudaStream;
    156 }
    157 else
    158 {
    159 throw Exception(DW_NOT_SUPPORTED, "PassImpl: Only GPU passes can use a cuda stream");
    160 }
    161 }
    162
    164 // coverity[autosar_cpp14_a8_4_8_violation]
    166 PassFunctionT const passFunc,
    167 dwProcessorType const processor,
    168 dwProcessType const processType,
    169 dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime,
    170 NvMediaDla* const dlaEngine)
    171 : Pass(processor, processType, minTime, avgTime, maxTime)
    172 , m_node(node)
    173 , m_functionInt(passFunc)
    174 {
    175 if (processor == DW_PROCESSOR_TYPE_DLA_0 || processor == DW_PROCESSOR_TYPE_DLA_1)
    176 {
    177 m_dlaEngine = dlaEngine;
    178 }
    179 else
    180 {
    181 throw Exception(DW_NOT_SUPPORTED, "PassImpl: Only DLA passes can use a DLA handle");
    182 }
    183 }
    184
    186 dwStatus run() final
    187 {
    188 // TODO(DRIV-7184) - return code of the function shall not be ignored
    189 return Exception::guard([&] {
    190 m_functionInt();
    191 },
    192 dw::core::Logger::Verbosity::WARN);
    193 }
    194
    196 void setRunnableId(dw::core::StringView const& runnableId) final
    197 {
    198 if (runnableId.size() >= 128 - 10 - 1)
    199 {
    200 throw Exception(DW_BUFFER_FULL, "setRunnableId() runnable id exceeds capacity: ", runnableId);
    201 }
    202 m_runnableId = dw::core::FixedString<128>(runnableId.data(), runnableId.size());
    203 m_runnableIdSubmit = dw::core::FixedString<128>(runnableId.data(), runnableId.size());
    204 m_runnableIdSubmit += "_submittee";
    205 }
    206
    208 dw::core::FixedString<MAX_NAME_LEN> const& getRunnableId(bool isSubmitPass) const final
    209 {
    210 if (isSubmitPass)
    211 {
    212 return m_runnableIdSubmit;
    213 }
    214 return m_runnableId;
    215 }
    216
    218 Node& getNode() const final
    219 {
    220 return m_node;
    221 }
    222
    223private:
    225 Node& m_node;
    227 PassFunctionT m_functionInt;
    229 dw::core::FixedString<MAX_NAME_LEN> m_runnableId;
    231 dw::core::FixedString<MAX_NAME_LEN> m_runnableIdSubmit;
    232};
    233
    234} // namespace framework
    235} // namespace dw
    236
    237#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:124
    dwStatus run() final
    Definition: Pass.hpp:186
    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:143
    void setRunnableId(dw::core::StringView const &runnableId) final
    Definition: Pass.hpp:196
    Node & getNode() const final
    Definition: Pass.hpp:218
    dw::core::FixedString< MAX_NAME_LEN > const & getRunnableId(bool isSubmitPass) const final
    Definition: Pass.hpp:208
    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:130
    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:165
    Pass is a runnable describes the metadata of a pass.
    Definition: Pass.hpp:50
    Pass(Pass const &)=delete
    Copy constructor.
    dwTime_t m_minTime
    Definition: Pass.hpp:88
    dwTime_t m_avgTime
    Definition: Pass.hpp:91
    virtual Node & getNode() const =0
    Get the node this pass belongs to.
    cudaStream_t m_cudaStream
    The cuda stream to use in case the processor type is GPU.
    Definition: Pass.hpp:98
    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:81
    Pass(dwProcessorType const processor, dwProcessType const processType, dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime) noexcept
    Constructor.
    Definition: Pass.hpp:107
    dwProcessType m_processType
    The process type this pass runs with.
    Definition: Pass.hpp:84
    virtual dwStatus run()=0
    Run the pass.
    static constexpr size_t MAX_NAME_LEN
    The maximum length of the runnable id.
    Definition: Pass.hpp:55
    dwTime_t m_maxTime
    Definition: Pass.hpp:94
    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:101
    Definition: Exception.hpp:47
    人人超碰97caoporen国产