31#ifndef DW_FRAMEWORK_PASS_HPP_
32#define DW_FRAMEWORK_PASS_HPP_
34#include <dwcgf/Types.hpp>
37#include <dw/core/container/StringView.hpp>
38#include <dw/trace/Trace.hpp>
69 virtual dwStatus
run() = 0;
74 virtual dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const = 0;
107 Pass(dwProcessorType
const processor,
108 dwProcessType
const processType,
109 dwTime_t
const minTime, dwTime_t
const avgTime, dwTime_t
const maxTime) noexcept
122template <
typename PassFunctionT>
125 static_assert(std::is_convertible<PassFunctionT, std::function<dwStatus()>>::value,
"PassFunctionT must be callable without arguments and return dwStatus");
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)
137 , m_functionInt(passFunc)
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)
151 , m_functionInt(passFunc)
153 if (processor == DW_PROCESSOR_TYPE_GPU)
159 throw Exception(DW_NOT_SUPPORTED,
"PassImpl: Only GPU passes can use a cuda stream");
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)
173 , m_functionInt(passFunc)
175 if (processor == DW_PROCESSOR_TYPE_DLA_0 || processor == DW_PROCESSOR_TYPE_DLA_1)
181 throw Exception(DW_NOT_SUPPORTED,
"PassImpl: Only DLA passes can use a DLA handle");
192 dw::core::Logger::Verbosity::WARN);
198 if (runnableId.size() >= 128 - 10 - 1)
200 throw Exception(DW_BUFFER_FULL,
"setRunnableId() runnable id exceeds capacity: ", runnableId);
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";
208 dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const final
212 return m_runnableIdSubmit;
227 PassFunctionT m_functionInt;
229 dw::core::FixedString<MAX_NAME_LEN> m_runnableId;
231 dw::core::FixedString<MAX_NAME_LEN> m_runnableIdSubmit;
static dwStatus guard(TryBlock tryBlock, dw::core::Logger::Verbosity verbosity=dw::core::Logger::Verbosity::DEBUG)
PassImpl contains the function to invoke on run().
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.
void setRunnableId(dw::core::StringView const &runnableId) final
Node & getNode() const final
dw::core::FixedString< MAX_NAME_LEN > const & getRunnableId(bool isSubmitPass) const final
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.
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.
Pass is a runnable describes the metadata of a pass.
Pass(Pass const &)=delete
Copy constructor.
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.
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.
Pass(dwProcessorType const processor, dwProcessType const processType, dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime) noexcept
Constructor.
dwProcessType m_processType
The process type this pass runs with.
virtual dwStatus run()=0
Run the pass.
static constexpr size_t MAX_NAME_LEN
The maximum length of the runnable id.
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.