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> 58 virtual ~Pass() =
default;
69 virtual dwStatus
run() = 0;
72 virtual void setRunnableId(dw::core::StringView
const& runnableId) = 0;
74 virtual dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const = 0;
105 Pass(dwProcessorType
const processor,
106 dwProcessType
const processType,
107 dwTime_t
const minTime, dwTime_t
const avgTime, dwTime_t
const maxTime) noexcept
120 template <
typename PassFunctionT>
127 PassFunctionT
const passFunc,
128 dwProcessorType
const processor,
129 dwProcessType
const processType,
130 dwTime_t
const minTime, dwTime_t
const avgTime, dwTime_t
const maxTime)
131 :
Pass(processor, processType, minTime, avgTime, maxTime)
133 , m_functionInt(passFunc)
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)
147 , m_functionInt(passFunc)
149 if (processor == DW_PROCESSOR_TYPE_GPU)
155 throw Exception(DW_NOT_SUPPORTED,
"PassImpl: Only GPU passes can use a cuda stream");
162 PassFunctionT
const passFunc,
163 dwProcessorType
const processor,
164 dwProcessType
const processType,
165 dwTime_t
const minTime, dwTime_t
const avgTime, dwTime_t
const maxTime,
166 NvMediaDla*
const dlaEngine)
167 :
Pass(processor, processType, minTime, avgTime, maxTime)
169 , m_functionInt(passFunc)
171 if (processor == DW_PROCESSOR_TYPE_DLA_0 || processor == DW_PROCESSOR_TYPE_DLA_1)
177 throw Exception(DW_NOT_SUPPORTED,
"PassImpl: Only DLA passes can use a DLA handle");
193 if (runnableId.size() >= 128 - 10 - 1)
195 throw Exception(DW_BUFFER_FULL,
"setRunnableId() runnable id exceeds capacity: ", runnableId);
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";
203 dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const final 207 return m_runnableIdSubmit;
222 PassFunctionT m_functionInt;
224 dw::core::FixedString<MAX_NAME_LEN> m_runnableId;
226 dw::core::FixedString<MAX_NAME_LEN> m_runnableIdSubmit;
232 #endif // DW_FRAMEWORK_PASS_HPP_ virtual void setRunnableId(dw::core::StringView const &runnableId)=0
Set the runnable id.
dw::core::FixedString< MAX_NAME_LEN > const & getRunnableId(bool isSubmitPass) const final
static constexpr size_t MAX_NAME_LEN
The maximum length of the runnable id.
NvMediaDla * m_dlaEngine
The dla engine to run on in case the processor type is GPU.
void setRunnableId(dw::core::StringView const &runnableId) final
dwProcessType m_processType
The process type this pass runs with.
virtual ~Pass()=default
Destructor.
static dwStatus guard(TryBlock tryBlock)
Same as previous guard but with a simpler tryBlock with signature 'void tryBlock()' Always returns DW...
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.
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.
Pass is a runnable describes the metadata of a pass.
virtual Node * getNode() const =0
Get the node this pass belongs to.
dwProcessorType m_processor
The processor type this pass runs on.
virtual dwStatus run()=0
Run the pass.
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.
PassImpl contains the function to invoke on run().
cudaStream_t m_cudaStream
The cuda stream to use in case the processor type is GPU.
Pass(dwProcessorType const processor, dwProcessType const processType, dwTime_t const minTime, dwTime_t const avgTime, dwTime_t const maxTime) noexcept
Constructor.
Pass(Pass const &)=delete
Copy constructor.
virtual dw::core::FixedString< MAX_NAME_LEN > const & getRunnableId(bool isSubmitPass) const =0
Get the runnable id.
Node * getNode() const final
Pass & operator=(Pass const &)=delete
Copy assignment operator.