• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.22
    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#include <dwshared/dwfoundation/dw/core/language/Function.hpp>
    39
    40namespace dw
    41{
    42namespace framework
    43{
    44
    46class Node;
    47
    49class Pass
    50{
    51public:
    53 // coverity[autosar_cpp14_a0_1_1_violation] FP: nvbugs/2813925
    54 // coverity[autosar_cpp14_a5_1_1_violation] FP: nvbugs/4020293
    55 // coverity[autosar_cpp14_m0_1_4_violation] FP: nvbugs/2813925
    56 static constexpr const size_t MAX_NAME_LEN{256U};
    57
    59 virtual ~Pass() = default;
    61 Pass(Pass const&) = delete;
    63 Pass(Pass&&) = delete;
    65 Pass& operator=(Pass const&) & = delete;
    67 Pass& operator=(Pass&&) & = delete;
    68
    70 const dw::core::StringView& getName() const;
    71
    73 // coverity[autosar_cpp14_a2_10_5_violation]
    74 virtual dwStatus run() = 0;
    75
    77 virtual void setRunnableId(dw::core::StringView const& runnableId) = 0;
    79 virtual dw::core::FixedString<MAX_NAME_LEN> const& getRunnableId(bool isSubmitPass) const = 0;
    81 dw::core::HeapHashMap<dwStatus, uint32_t> const& getPassReturnErrorMap();
    82
    84 virtual Node& getNode() const = 0;
    85
    87 dwProcessorType m_processor;
    88
    90 cudaStream_t m_cudaStream;
    91
    96
    97protected:
    99 Pass(const dw::core::StringView& name, dwProcessorType const processor,
    100 std::initializer_list<std::pair<dwStatus, uint32_t>> const& returnMapping = {});
    101
    102private:
    104 dw::core::StringView m_name;
    105
    107 dw::core::HeapHashMap<dwStatus, uint32_t> m_passReturnErrorMapping;
    108};
    109
    111template <typename PassFunctionT>
    112class PassImpl : public Pass
    113{
    114 static_assert(std::is_convertible<PassFunctionT, dw::core::Function<dwStatus()>>::value, "PassFunctionT must be callable without arguments and return dwStatus");
    115
    116public:
    119 const dw::core::StringView& name,
    120 PassFunctionT const passFunc,
    121 dwProcessorType const processor,
    122 std::initializer_list<std::pair<dwStatus, uint32_t>> const& returnMapping = {})
    123 : Pass(name, processor, returnMapping)
    124 , m_node(node)
    125 , m_functionInt(passFunc)
    126 {
    127 }
    128
    130 // coverity[autosar_cpp14_a2_10_5_violation]
    131 dwStatus run() final
    132 {
    133 // TODO(DRIV-7184) - return code of the function shall not be ignored
    135 // coverity[autosar_cpp14_a5_1_9_violation] FP: nvbugs/4347682
    136 [&] {
    137 m_functionInt();
    138 },
    139 dw::core::Logger::Verbosity::ERROR);
    140 }
    141
    143 void setRunnableId(dw::core::StringView const& runnableId) final
    144 {
    145 constexpr const dw::core::StringView SUBMITTEE_SUFFIX{"_submittee"};
    146 constexpr const size_t MAX_NAME_LEN_WITHOUT_SUBMITTEE_SUFFIX{MAX_NAME_LEN - SUBMITTEE_SUFFIX.size()};
    147 if (runnableId.size() >= MAX_NAME_LEN_WITHOUT_SUBMITTEE_SUFFIX)
    148 {
    149 throw ExceptionWithStatus(DW_BUFFER_FULL, "setRunnableId() runnable id exceeds capacity: ", runnableId);
    150 }
    151 m_runnableId = dw::core::FixedString<MAX_NAME_LEN>(runnableId.data(), runnableId.size());
    152 m_runnableIdSubmit = dw::core::FixedString<MAX_NAME_LEN>(runnableId.data(), runnableId.size());
    153 m_runnableIdSubmit += SUBMITTEE_SUFFIX;
    154 }
    155
    157 dw::core::FixedString<MAX_NAME_LEN> const& getRunnableId(bool isSubmitPass) const final
    158 {
    159 if (isSubmitPass)
    160 {
    161 return m_runnableIdSubmit;
    162 }
    163 return m_runnableId;
    164 }
    165
    167 Node& getNode() const final
    168 {
    169 return m_node;
    170 }
    171
    172private:
    174 Node& m_node;
    176 dw::core::Function<dwStatus()> m_functionInt;
    178 dw::core::FixedString<MAX_NAME_LEN> m_runnableId;
    180 dw::core::FixedString<MAX_NAME_LEN> m_runnableIdSubmit;
    181};
    182
    183} // namespace framework
    184} // namespace dw
    185
    186#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:113
    dwStatus run() final
    Definition: Pass.hpp:131
    void setRunnableId(dw::core::StringView const &runnableId) final
    Definition: Pass.hpp:143
    Node & getNode() const final
    Definition: Pass.hpp:167
    dw::core::FixedString< MAX_NAME_LEN > const & getRunnableId(bool isSubmitPass) const final
    Definition: Pass.hpp:157
    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:118
    Pass is a runnable describes the metadata of a pass.
    Definition: Pass.hpp:50
    Pass(Pass const &)=delete
    Copy constructor.
    virtual Node & getNode() const =0
    Get the node this pass belongs to.
    bool m_isFirstIteration
    Definition: Pass.hpp:95
    cudaStream_t m_cudaStream
    The cuda stream to use in case the processor type is GPU.
    Definition: Pass.hpp:90
    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:87
    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:56
    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:41
    人人超碰97caoporen国产