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. 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:267
StageBuilder stage(uint32_t taskCount, Args &&... args)
Begins a stage chain with a sequential kernel stage.
Definition: launcher.hpp:408
StageBuilder & stage(uint32_t taskCount, Args &&... args)
LaunchResult run()
StageBuilder & tasks(uint32_t taskCount)

Definition at line 150 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.

◆ 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 ( )

◆ 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 485 of file stage_builder.hpp.

486 {
487  stage<Func>(uint32_t{0}, std::forward<Args>(args)...);
488  return detail::TaskCountRequired<StageBuilder>(std::move(*this));
489 }

◆ 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 163 of file stage_builder.hpp.

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

◆ 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 305 of file stage_builder.hpp.

◆ StageGroupBuilder

friend class StageGroupBuilder
friend

Definition at line 303 of file stage_builder.hpp.


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