PXL
pxl::StageGroupBuilder Class Reference

Collects parallel kernels within a single stage group. More...

#include <stage_builder.hpp>

Public Member Functions

template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > = 0>
StageGroupBuilder & add (uint32_t taskCount, Args &&... args)
 
template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > = 0>
detail::TaskCountRequired< StageGroupBuilder > add (Args &&... args) &&
 
template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > = 0>
detail::TaskCountRequired< StageGroupBuilder > add (Args &&... args) &=delete
 
StageGroupBuilder & tasks (uint32_t taskCount)
 Sets the task count of the most recently added kernel in this group. More...
 
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 ()
 
LaunchResult run ()
 
std::future< LaunchResult > runAsync ()
 
StageGroupBuilder & reserve (uint32_t n)
 
StageGroupBuilder & batchSize (uint32_t n)
 Sets per-task batch size for the most-recently-added kernel within the active parallel group. No-op when the group is empty. More...
 
StageGroupBuilder & clusterBitmap (uint32_t bitmap)
 Sets cluster bitmap for the most-recently-added kernel in the active group. A bit beyond the device's clusters per Sub fails run() with Result::InvalidArgument. More...
 
StageGroupBuilder & locality (LocalityMode mode)
 Sets locality mode for the most-recently-added kernel in the active group. More...
 
StageGroupBuilder & onComplete (Map::CompletionCallback cb, void *arg=nullptr)
 Registers a completion callback on the most-recently-added kernel. More...
 
StageGroupBuilder & onMessage (Map::MessageCallback cb, void *arg=nullptr)
 Registers a message callback on the most-recently-added kernel. More...
 
StageGroupBuilder & onError (Map::ErrorCallback cb, void *arg=nullptr)
 Registers an error callback on the most-recently-added kernel. More...
 
StageGroupBuilder & stream (Stream *s)
 Routes the most-recently-added kernel through a user-managed stream. More...
 
StageGroupBuilder & enableProfile (const xpti::ProfileConfig &config)
 Enables profiling for the most-recently-added kernel. enableProfiling failures are logged but not propagated. More...
 
 ~StageGroupBuilder ()
 
 StageGroupBuilder (StageGroupBuilder &&) noexcept
 
template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > >
detail::TaskCountRequired< StageGroupBuilder > add (Args &&... args) &&
 
template<auto Func, typename... Args, detail::EnableCompatibleKernelArguments< Func, Args... > >
detail::TaskCountRequired< StageBuilder > stage (Args &&... args) &&
 

Friends

class StageBuilder
 
class Launcher
 
template<typename >
class detail::TaskCountConfigured
 

Detailed Description

Collects parallel kernels within a single stage group.

Kernels added via add<K>() inside a group all run in parallel; the group itself runs as one sequential stage in the surrounding chain.

Optional knob methods (batchSize/clusterBitmap/locality/onComplete/onMessage/ onError/stream/enableProfile) target the most-recently-added kernel in the group, mirroring StageBuilder's per-stage semantics. Calling a knob before any add<K>() is a silent no-op.

Marked [[nodiscard]] so that building a parallel group and forgetting to call .run()/.runAsync() (or chaining back via .stage<...>()/.stage()) triggers a compile-time warning instead of a silent no-op.

Definition at line 332 of file stage_builder.hpp.

Constructor & Destructor Documentation

◆ ~StageGroupBuilder()

pxl::StageGroupBuilder::~StageGroupBuilder ( )

◆ StageGroupBuilder()

pxl::StageGroupBuilder::StageGroupBuilder ( StageGroupBuilder &&  )
noexcept

Member Function Documentation

◆ add() [1/4]

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

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

◆ add() [2/4]

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

Definition at line 502 of file stage_builder.hpp.

503 {
504  add<Func>(uint32_t{0}, std::forward<Args>(args)...);
505  return detail::TaskCountRequired<StageGroupBuilder>(std::move(*this));
506 }

◆ add() [3/4]

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

◆ add() [4/4]

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

Definition at line 337 of file stage_builder.hpp.

338  {
339  const char* kernelName = nullptr;
340 #if defined(__PXCC_ANALYSIS__)
341  kernelName = "__pxcc_placeholder__";
342 #else
343  static_assert(sizeof(pxl::KernelTraits<Func>) > 0,
344  "Kernel function not found in KernelTraits — was it compiled with pxcc?");
345  kernelName = pxl::KernelTraits<Func>::name;
346 #endif
347 
348  impl::StageEntry entry;
349  entry.kernelName = kernelName;
350  entry.taskCount = taskCount;
351  entry.argList.reserve(sizeof...(Args));
352  if constexpr (sizeof...(Args) > 0)
353  {
354  parent_.buildArgList(entry.argList, entry.constStorage, entry.syncTargets,
355  std::forward<Args>(args)...);
356  }
357  impl::attachStageDirections(entry, detail::MakeKernelDirections<Func>());
358  currentGroup_.entries.push_back(std::move(entry));
359  return *this;
360  }
Traits class that maps a kernel function pointer to its name string.
Definition: module.hpp:32

◆ batchSize()

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

Sets per-task batch size for the most-recently-added kernel within the active parallel group. No-op when the group is empty.

◆ clusterBitmap()

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

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

◆ enableProfile()

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

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

◆ locality()

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

Sets locality mode for the most-recently-added kernel in the active group.

◆ onComplete()

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

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

◆ onError()

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

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

◆ onMessage()

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

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

◆ reserve()

StageGroupBuilder& pxl::StageGroupBuilder::reserve ( uint32_t  n)
inline

Definition at line 414 of file stage_builder.hpp.

415  {
416  parent_.reserve(n);
417  return *this;
418  }
StageBuilder & reserve(uint32_t n)

◆ run()

LaunchResult pxl::StageGroupBuilder::run ( )
inline

Definition at line 402 of file stage_builder.hpp.

403  {
404  flush();
405  return parent_.run();
406  }
LaunchResult run()

◆ runAsync()

std::future<LaunchResult> pxl::StageGroupBuilder::runAsync ( )
inline

Definition at line 408 of file stage_builder.hpp.

409  {
410  flush();
411  return parent_.runAsync();
412  }
std::future< LaunchResult > runAsync()

◆ stage() [1/5]

StageGroupBuilder pxl::StageGroupBuilder::stage ( )
inline

Definition at line 396 of file stage_builder.hpp.

397  {
398  flush();
399  return parent_.stage();
400  }
StageBuilder & stage(uint32_t taskCount, Args &&... args)

◆ stage() [2/5]

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

Chains a sequential stage with only the kernel's own arguments. The returned pending type must receive tasks() before the chain continues.

◆ stage() [3/5]

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

Definition at line 510 of file stage_builder.hpp.

511 {
512  auto& parent = stage<Func>(uint32_t{0}, std::forward<Args>(args)...);
513  return detail::TaskCountRequired<StageBuilder>(std::move(parent));
514 }

◆ stage() [4/5]

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

◆ stage() [5/5]

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

Definition at line 380 of file stage_builder.hpp.

381  {
382  flush();
383  return parent_.stage<Func>(taskCount, std::forward<Args>(args)...);
384  }

◆ stream()

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

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

◆ tasks()

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

Sets the task count of the most recently added kernel in this group.

Friends And Related Function Documentation

◆ detail::TaskCountConfigured

template<typename >
friend class detail::TaskCountConfigured
friend

Definition at line 474 of file stage_builder.hpp.

◆ Launcher

friend class Launcher
friend

Definition at line 472 of file stage_builder.hpp.

◆ StageBuilder

friend class StageBuilder
friend

Definition at line 471 of file stage_builder.hpp.


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