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>
38#include <dwshared/dwfoundation/dw/core/language/Function.hpp>
70 const dw::core::StringView&
getName()
const;
74 virtual dwStatus
run() = 0;
79 virtual dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const = 0;
99 Pass(
const dw::core::StringView& name, dwProcessorType
const processor,
100 std::initializer_list<std::pair<dwStatus, uint32_t>>
const& returnMapping = {});
104 dw::core::StringView m_name;
107 dw::core::HeapHashMap<dwStatus, uint32_t> m_passReturnErrorMapping;
111template <
typename PassFunctionT>
114 static_assert(std::is_convertible<PassFunctionT, dw::core::Function<dwStatus()>>::value,
"PassFunctionT must be callable without arguments and return dwStatus");
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)
125 , m_functionInt(passFunc)
139 dw::core::Logger::Verbosity::ERROR);
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)
149 throw ExceptionWithStatus(DW_BUFFER_FULL,
"setRunnableId() runnable id exceeds capacity: ", runnableId);
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;
157 dw::core::FixedString<MAX_NAME_LEN>
const&
getRunnableId(
bool isSubmitPass)
const final
161 return m_runnableIdSubmit;
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;
static dwStatus guard(TryBlock const &tryBlock, ::dw::core::Logger::Verbosity verbosity=::dw::core::Logger::Verbosity::ERROR)
PassImpl contains the function to invoke on run().
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, 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.
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.
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.
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.