31#ifndef DW_FRAMEWORK_PASS_HPP_
32#define DW_FRAMEWORK_PASS_HPP_
37#include <dw/core/container/StringView.hpp>
68 virtual dwStatus
run() = 0;
73 virtual dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const = 0;
104 Pass(dwProcessorType
const processor,
105 dwProcessType
const processType,
106 dwTime_t
const minTime, dwTime_t
const avgTime, dwTime_t
const maxTime)
noexcept;
110template <
typename PassFunctionT>
113 static_assert(std::is_convertible<PassFunctionT, std::function<dwStatus()>>::value,
"PassFunctionT must be callable without arguments and return dwStatus");
118 PassFunctionT
const passFunc,
119 dwProcessorType
const processor,
120 dwProcessType
const processType,
121 dwTime_t
const minTime, dwTime_t
const avgTime, dwTime_t
const maxTime)
122 :
Pass(processor, processType, minTime, avgTime, maxTime)
124 , m_functionInt(passFunc)
130 PassFunctionT
const passFunc,
131 dwProcessorType
const processor,
132 dwProcessType
const processType,
133 dwTime_t
const minTime, dwTime_t
const avgTime, dwTime_t
const maxTime,
135 :
Pass(processor, processType, minTime, avgTime, maxTime)
137 , m_functionInt(passFunc)
139 if (processor == DW_PROCESSOR_TYPE_GPU)
145 throw ExceptionWithStatus(DW_NOT_SUPPORTED,
"PassImpl: Only GPU passes can use a cuda stream");
151 PassFunctionT
const passFunc,
152 dwProcessorType
const processor,
153 dwProcessType
const processType,
154 dwTime_t
const minTime, dwTime_t
const avgTime, dwTime_t
const maxTime,
155 NvMediaDla*
const dlaEngine)
156 :
Pass(processor, processType, minTime, avgTime, maxTime)
158 , m_functionInt(passFunc)
160 if (processor == DW_PROCESSOR_TYPE_DLA_0 || processor == DW_PROCESSOR_TYPE_DLA_1)
166 throw ExceptionWithStatus(DW_NOT_SUPPORTED,
"PassImpl: Only DLA passes can use a DLA handle");
174 return Exception::guard([&] {
177 dw::core::Logger::Verbosity::WARN);
183 if (runnableId.size() >= 128 - 10 - 1)
185 throw ExceptionWithStatus(DW_BUFFER_FULL,
"setRunnableId() runnable id exceeds capacity: ", runnableId);
187 m_runnableId = dw::core::FixedString<128>(runnableId.data(), runnableId.size());
188 m_runnableIdSubmit = dw::core::FixedString<128>(runnableId.data(), runnableId.size());
189 m_runnableIdSubmit +=
"_submittee";
193 dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const final
197 return m_runnableIdSubmit;
212 PassFunctionT m_functionInt;
214 dw::core::FixedString<MAX_NAME_LEN> m_runnableId;
216 dw::core::FixedString<MAX_NAME_LEN> m_runnableIdSubmit;
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.