PXL
pxl::StageBuilder Class Reference

Builds a chain of kernel stages for sequential/parallel execution. More...

#include <stage_builder.hpp>

Public Member Functions

 StageBuilder (std::shared_ptr< impl::DeviceHandle > device)
 
 ~StageBuilder ()
 
 StageBuilder (StageBuilder &&) noexcept
 
StageBuilder & operator= (StageBuilder &&) noexcept
 
 StageBuilder (const StageBuilder &)=delete
 
StageBuilder & operator= (const StageBuilder &)=delete
 
template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > = 0>
StageBuilder & stage (uint32_t taskCount, Args &&... args)
 
template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > = 0>
detail::TaskCountRequired< StageBuilder > stage (Args &&... args) &&
 
template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > = 0>
detail::TaskCountRequired< StageBuilder > stage (Args &&... args) &=delete
 
StageGroupBuilder stage ()
 
StageBuilder & reserve (uint32_t n)
 
StageBuilder & tasks (uint32_t taskCount)
 
StageBuilder & batchSize (uint32_t n)
 Sets per-task batch size for the most-recently-added stage. Affects only the last entry added via stage<K>(...). No-op when no stage has been added yet. More...
 
StageBuilder & clusterBitmap (uint32_t bitmap)
 Sets cluster bitmap for the most-recently-added stage. A bit beyond the device's clusters per Sub fails run() with Result::InvalidArgument. More...
 
StageBuilder & locality (LocalityMode mode)
 Sets locality mode for the most-recently-added stage. More...
 
StageBuilder & onComplete (Map::CompletionCallback cb, void *arg=nullptr)
 Registers a completion callback on the most-recently-added stage. More...
 
StageBuilder & onMessage (Map::MessageCallback cb, void *arg=nullptr)
 Registers a message callback on the most-recently-added stage. More...
 
StageBuilder & onError (Map::ErrorCallback cb, void *arg=nullptr)
 Registers an error callback on the most-recently-added stage. More...
 
StageBuilder & stream (Stream *s)
 Routes the most-recently-added stage through a user-managed stream. More...
 
StageBuilder & enableProfile (const xpti::ProfileConfig &config)
 Enables profiling for the most-recently-added stage. enableProfiling failures are logged but not propagated. More...
 
LaunchResult run ()
 
std::future< LaunchResult > runAsync ()
 
template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > >
detail::TaskCountRequired< StageBuilder > stage (Args &&... args) &&
 

Friends

class StageGroupBuilder
 
template<typename >
class detail::TaskCountConfigured
 

Detailed Description

Builds a chain of kernel stages for sequential/parallel execution.

Stages are executed sequentially with barriers between them. Within a stage group (created by .stage()), kernels run in parallel.

Example:

// Sequential stages:
auto result = pxl::Launcher()
.stage<K1>(data, mid).tasks(taskCount)
.stage<K2>(mid, out).tasks(taskCount)
.run();
// Parallel group + sequential:
auto result = pxl::Launcher()
.stage()
.add<K1>(A, B).tasks(firstTaskCount)
.add<K2>(C, D).tasks(secondTaskCount)
.stage<K3>(E, F).tasks(finalTaskCount)
.run();
Execution context for kernel launches on XCENA devices.
Definition: launcher.hpp:279
StageBuilder stage(uint32_t taskCount, Args &&... args)
Begins a stage chain with a sequential kernel stage.
Definition: launcher.hpp:427
StageBuilder & stage(uint32_t taskCount, Args &&... args)
LaunchResult run()
StageBuilder & tasks(uint32_t taskCount)

Definition at line 154 of file stage_builder.hpp.

Constructor & Destructor Documentation

◆ StageBuilder() [1/3]

pxl::StageBuilder::StageBuilder ( std::shared_ptr< impl::DeviceHandle >  device)

◆ ~StageBuilder()

pxl::StageBuilder::~StageBuilder ( )

◆ StageBuilder() [2/3]

pxl::StageBuilder::StageBuilder ( StageBuilder &&  )
noexcept

◆ StageBuilder() [3/3]

pxl::StageBuilder::StageBuilder ( const StageBuilder &  )
delete

Member Function Documentation

◆ batchSize()

StageBuilder& pxl::StageBuilder::batchSize ( uint32_t  n)

Sets per-task batch size for the most-recently-added stage. Affects only the last entry added via stage<K>(...). No-op when no stage has been added yet.

◆ clusterBitmap()

StageBuilder& pxl::StageBuilder::clusterBitmap ( uint32_t  bitmap)

Sets cluster bitmap for the most-recently-added stage. A bit beyond the device's clusters per Sub fails run() with Result::InvalidArgument.

◆ enableProfile()

StageBuilder& pxl::StageBuilder::enableProfile ( const xpti::ProfileConfig &  config)

Enables profiling for the most-recently-added stage. enableProfiling failures are logged but not propagated.

◆ locality()

StageBuilder& pxl::StageBuilder::locality ( LocalityMode  mode)

Sets locality mode for the most-recently-added stage.

◆ onComplete()

StageBuilder& pxl::StageBuilder::onComplete ( Map::CompletionCallback  cb,
void *  arg = nullptr 
)

Registers a completion callback on the most-recently-added stage.

◆ onError()

StageBuilder& pxl::StageBuilder::onError ( Map::ErrorCallback  cb,
void *  arg = nullptr 
)

Registers an error callback on the most-recently-added stage.

◆ onMessage()

StageBuilder& pxl::StageBuilder::onMessage ( Map::MessageCallback  cb,
void *  arg = nullptr 
)

Registers a message callback on the most-recently-added stage.

◆ operator=() [1/2]

StageBuilder& pxl::StageBuilder::operator= ( const StageBuilder &  )
delete

◆ operator=() [2/2]

StageBuilder& pxl::StageBuilder::operator= ( StageBuilder &&  )
noexcept

◆ reserve()

StageBuilder& pxl::StageBuilder::reserve ( uint32_t  n)

◆ run()

LaunchResult pxl::StageBuilder::run ( )

Resource exhaustion, dropped futures and process exit behave as for LaunchBuilder::run()/runAsync(). Host memory fails with InvalidArgument: pxl::kHostMemoryArgumentMessage followed by the kernel name.

◆ runAsync()

std::future<LaunchResult> pxl::StageBuilder::runAsync ( )

◆ stage() [1/5]

StageGroupBuilder pxl::StageBuilder::stage ( )

◆ stage() [2/5]

template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > = 0>
detail::TaskCountRequired<StageBuilder> pxl::StageBuilder::stage ( Args &&...  args) &&

Adds a stage with only the kernel's own arguments; set its task count with .tasks(taskCount). Kernel arity distinguishes this from the positional compatibility form, including for integral-first kernels. This transition consumes an rvalue stage chain and returns a pending type that exposes tasks() and the current entry's optional settings, but no next stage or execution method.

◆ stage() [3/5]

template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > >
detail::TaskCountRequired<StageBuilder> pxl::StageBuilder::stage ( Args &&...  args) &&

Definition at line 494 of file stage_builder.hpp.

495 {
496  stage<Func>(uint32_t{0}, std::forward<Args>(args)...);
497  return detail::TaskCountRequired<StageBuilder>(std::move(*this));
498 }

◆ stage() [4/5]

template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > = 0>
detail::TaskCountRequired<StageBuilder> pxl::StageBuilder::stage ( Args &&...  args) &
delete

◆ stage() [5/5]

template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > = 0>
StageBuilder& pxl::StageBuilder::stage ( uint32_t  taskCount,
Args &&...  args 
)
inline

Definition at line 167 of file stage_builder.hpp.

168  {
169  const char* kernelName = nullptr;
170 #if defined(__PXCC_ANALYSIS__)
171  kernelName = "__pxcc_placeholder__";
172 #else
173  static_assert(sizeof(pxl::KernelTraits<Func>) > 0,
174  "Kernel function not found in KernelTraits — was it compiled with pxcc?");
175  kernelName = pxl::KernelTraits<Func>::name;
176 #endif
177 
178  impl::StageEntry entry;
179  entry.kernelName = kernelName;
180  entry.taskCount = taskCount;
181  entry.argList.reserve(sizeof...(Args));
182  if constexpr (sizeof...(Args) > 0)
183  {
184  buildArgList(entry.argList, entry.constStorage, entry.syncTargets, std::forward<Args>(args)...);
185  }
186  impl::attachStageDirections(entry, detail::MakeKernelDirections<Func>());
187 
188  impl::StageGroup group;
189  group.entries.push_back(std::move(entry));
190  stages_.push_back(std::move(group));
191  return *this;
192  }
Traits class that maps a kernel function pointer to its name string.
Definition: module.hpp:32

◆ stream()

StageBuilder& pxl::StageBuilder::stream ( Stream *  s)

Routes the most-recently-added stage through a user-managed stream.

◆ tasks()

StageBuilder& pxl::StageBuilder::tasks ( uint32_t  taskCount)

Sets the task count of the most recently added stage. No-op when no stage has been added yet.

Friends And Related Function Documentation

◆ detail::TaskCountConfigured

template<typename >
friend class detail::TaskCountConfigured
friend

Definition at line 313 of file stage_builder.hpp.

◆ StageGroupBuilder

friend class StageGroupBuilder
friend

Definition at line 311 of file stage_builder.hpp.


The documentation for this class was generated from the following file: