31#ifndef DW_FRAMEWORK_PASS_HPP_
32#define DW_FRAMEWORK_PASS_HPP_
36#include <dwshared/dwfoundation/dw/core/container/StringView.hpp>
37#include <dwshared/dwfoundation/dw/core/container/HashContainer.hpp>
69 virtual dwStatus
run() = 0;
74 virtual dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const = 0;
94 Pass(dwProcessorType
const processor,
95 std::initializer_list<std::pair<dwStatus, uint32_t>>
const& returnMapping = {});
99 dw::core::HeapHashMap<dwStatus, uint32_t> m_passReturnErrorMapping;
103template <
typename PassFunctionT>
106 static_assert(std::is_convertible<PassFunctionT, std::function<dwStatus()>>::value,
"PassFunctionT must be callable without arguments and return dwStatus");
111 PassFunctionT
const passFunc,
112 dwProcessorType
const processor,
113 std::initializer_list<std::pair<dwStatus, uint32_t>>
const& returnMapping = {})
114 :
Pass(processor, returnMapping)
116 , m_functionInt(passFunc)
123 PassFunctionT
const passFunc,
124 dwProcessorType
const processor,
126 std::initializer_list<std::pair<dwStatus, uint32_t>>
const& returnMapping = {})
127 :
Pass(processor, returnMapping)
129 , m_functionInt(passFunc)
131 if (processor == DW_PROCESSOR_TYPE_GPU)
137 throw ExceptionWithStatus(DW_NOT_SUPPORTED,
"PassImpl: Only GPU passes can use a cuda stream");
148 dw::core::Logger::Verbosity::WARN);
155 if (runnableId.size() >= 128U - 10U - 1U)
157 throw ExceptionWithStatus(DW_BUFFER_FULL,
"setRunnableId() runnable id exceeds capacity: ", runnableId);
159 m_runnableId = dw::core::FixedString<128>(runnableId.data(), runnableId.size());
160 m_runnableIdSubmit = dw::core::FixedString<128>(runnableId.data(), runnableId.size());
162 m_runnableIdSubmit +=
"_submittee";
166 dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const final
170 return m_runnableIdSubmit;
185 PassFunctionT m_functionInt;
187 dw::core::FixedString<MAX_NAME_LEN> m_runnableId;
189 dw::core::FixedString<MAX_NAME_LEN> m_runnableIdSubmit;
static dwStatus guard(TryBlock const &tryBlock, ::dw::core::Logger::Verbosity verbosity=::dw::core::Logger::Verbosity::ERROR)
PassImpl contains the function to invoke on run().
PassImpl(Node &node, PassFunctionT const passFunc, dwProcessorType const processor, cudaStream_t const cudaStream, std::initializer_list< std::pair< dwStatus, uint32_t > > const &returnMapping={})
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, std::initializer_list< std::pair< dwStatus, uint32_t > > const &returnMapping={})
Constructor with a function running on the given processor type.
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, std::initializer_list< std::pair< dwStatus, uint32_t > > const &returnMapping={})
Constructor.
dw::core::HeapHashMap< dwStatus, uint32_t > const & getPassReturnErrorMap()
Get the return status code to error map.
virtual dwStatus run()=0
Run the pass.
static constexpr const 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.