alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::onAcc Namespace Reference

functionality which is usable on the accelerator compute device from within a kernel. More...

Namespaces

namespace  atomic
namespace  concepts
namespace  cpu
namespace  layout
namespace  order
namespace  origin
 Origin of index domains.
namespace  range
namespace  scope
namespace  trait
namespace  traverse
namespace  unit
 Unit of index domains.
namespace  warp
namespace  worker

Classes

struct  Acc
class  AtomicAtomicRef
 The atomic ops based on atomic_ref for CPU accelerators. More...
struct  DomainSpec
class  FlatIdxContainer
struct  MultiDimensional
struct  SimdAlgo
 Creates a functor operate on contiguous data concurrently. More...
class  TiledIdxContainer
struct  WorkerGroup

Functions

template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicAdd (auto const &acc, T *const addr, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic add operation.
template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicAnd (auto const &acc, T *const addr, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic and operation.
template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicCas (auto const &acc, T *const addr, T const &compare, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic compare-and-swap operation.
template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicDec (auto const &acc, T *const addr, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic decrement operation.
template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicExch (auto const &acc, T *const addr, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic exchange operation.
template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicInc (auto const &acc, T *const addr, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic increment operation.
template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicMax (auto const &acc, T *const addr, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic max operation.
template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicMin (auto const &acc, T *const addr, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic min operation.
template<typename TOp, typename T, typename T_Scope = scope::Device>
constexpr auto atomicOp (auto const &acc, T *const addr, T const &compare, T const &value, T_Scope const scope=T_Scope()) -> T
 Executes the given operation atomically.
template<typename TOp, typename T, typename T_Scope = scope::Device>
constexpr auto atomicOp (auto const &acc, T *const addr, T const &value, T_Scope const scope=T_Scope()) -> T
 Executes the given operation atomically.
template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicOr (auto const &acc, T *const addr, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic or operation.
template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicSub (auto const &acc, T *const addr, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic sub operation.
template<typename T, typename T_Scope = scope::Device>
constexpr auto atomicXor (auto const &acc, T *const addr, T const &value, T_Scope const hier=T_Scope()) -> T
 Executes an atomic xor operation.
template<typename T, size_t T_uniqueId>
constexpr decltype(auto) declareSharedMdArray (concepts::Acc auto const &acc, alpaka::concepts::CVector auto const &extent)
 creates an M-dimensional array
template<typename T, size_t T_uniqueId>
constexpr decltype(auto) declareSharedVar (concepts::Acc auto const &acc)
 Create a variable located in the thread blocks shared memory.
template<typename T>
constexpr auto getDynSharedMem (concepts::Acc auto const &acc) -> T *
 Get block shared dynamic memory.
template<typename T>
void isSupportedByAtomicAtomicRef ()
constexpr void memFence (auto const &acc, concepts::Scope auto const scope, concepts::MemoryOrder auto const order)
template<alpaka::concepts::Layer T_Scope>
constexpr void sync (concepts::Acc auto const &acc, T_Scope scope)
 Synchronize all threads within a given scope.
constexpr void syncBlockThreads (concepts::Acc auto const &acc)
 Synchronize all threads within a thread block.
range-based loop indexable index container
template<concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
ALPAKA_FN_HOST_ACC constexpr auto makeIdxMap (auto const &acc, auto const workGroup, auto const range, T_Traverse traverse=T_Traverse{}, T_IdxLayout idxLayout=T_IdxLayout{})
 Creates an index container.
template<concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
ALPAKA_FN_HOST_ACC constexpr auto makeIdxMap (auto const &acc, auto const workGroup, auto const range, alpaka::concepts::BoundaryDirection auto const &bd, T_Traverse traverse=T_Traverse{}, T_IdxLayout idxLayout=T_IdxLayout{})
 Specialization for an index container with a given boundary direction of the volume described by the range.
template<typename T_ScalarIdxType, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
ALPAKA_FN_HOST_ACC constexpr auto makeIdxMap (auto const &acc, auto const workGroup, auto const range, T_Traverse traverse=T_Traverse{}, T_IdxLayout idxLayout=T_IdxLayout{})
 Creates an index container.

Variables

template<typename T>
constexpr bool isOrigin_v = trait::IsOrigin<T>::value
template<typename T>
constexpr bool isUnit_v = trait::IsUnit<T>::value
constexpr auto linearized = MultiDimensional<false>{}

Detailed Description

functionality which is usable on the accelerator compute device from within a kernel.

Provides scopes for atomic and memory fence operations, analogous to NVIDIA CUDA's atomic and fence scopes.

This namespace defines the visibility scopes for atomic operations and memory fences, which control the visibility of memory operations across threads, blocks, and devices. The provided scopes are:

  • Block: Visibility within a thread block.
  • Device: Visibility across all thread blocks on the same device.
  • System: System-wide visibility, mapped to the strongest available atomic/fence by the backend.
See also
alpaka::onAcc::atomicAdd, alpaka::onAcc::memFence

Function Documentation

◆ atomicAdd()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicAdd ( auto const & acc,
T *const addr,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic add operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 66 of file atomic.hpp.

◆ atomicAnd()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicAnd ( auto const & acc,
T *const addr,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic and operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 143 of file atomic.hpp.

◆ atomicCas()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicCas ( auto const & acc,
T *const addr,
T const & compare,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic compare-and-swap operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
compareThe comparison value used in the atomic operation.
valueThe value used in the atomic operation.

Definition at line 177 of file atomic.hpp.

◆ atomicDec()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicDec ( auto const & acc,
T *const addr,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic decrement operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 132 of file atomic.hpp.

◆ atomicExch()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicExch ( auto const & acc,
T *const addr,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic exchange operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 110 of file atomic.hpp.

◆ atomicInc()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicInc ( auto const & acc,
T *const addr,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic increment operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 121 of file atomic.hpp.

◆ atomicMax()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicMax ( auto const & acc,
T *const addr,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic max operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 99 of file atomic.hpp.

◆ atomicMin()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicMin ( auto const & acc,
T *const addr,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic min operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 88 of file atomic.hpp.

◆ atomicOp() [1/2]

template<typename TOp, typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicOp ( auto const & acc,
T *const addr,
T const & compare,
T const & value,
T_Scope const scope = T_Scope() ) -> T
constexpr

Executes the given operation atomically.

Template Parameters
TOpThe operation type.
TThe value type.
Parameters
addrThe value to change atomically.
compareThe comparison value used in the atomic operation.
valueThe value used in the atomic operation.

Definition at line 44 of file atomic.hpp.

◆ atomicOp() [2/2]

template<typename TOp, typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicOp ( auto const & acc,
T *const addr,
T const & value,
T_Scope const scope = T_Scope() ) -> T
constexpr

Executes the given operation atomically.

Template Parameters
TOpThe operation type.
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 26 of file atomic.hpp.

◆ atomicOr()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicOr ( auto const & acc,
T *const addr,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic or operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 154 of file atomic.hpp.

◆ atomicSub()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicSub ( auto const & acc,
T *const addr,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic sub operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 77 of file atomic.hpp.

◆ atomicXor()

template<typename T, typename T_Scope = scope::Device>
auto alpaka::onAcc::atomicXor ( auto const & acc,
T *const addr,
T const & value,
T_Scope const hier = T_Scope() ) -> T
constexpr

Executes an atomic xor operation.

Template Parameters
TThe value type.
Parameters
addrThe value to change atomically.
valueThe value used in the atomic operation.

Definition at line 165 of file atomic.hpp.

◆ declareSharedMdArray()

template<typename T, size_t T_uniqueId>
decltype(auto) alpaka::onAcc::declareSharedMdArray ( concepts::Acc auto const & acc,
alpaka::concepts::CVector auto const & extent )
constexpr

creates an M-dimensional array

// creates a MdSpan view to a float value, do NOT use a reference here
constexpr decltype(auto) declareSharedVar(concepts::Acc auto const &acc)
Create a variable located in the thread blocks shared memory.
Definition Acc.hpp:152
Vec< T, sizeof...(T_values), detail::CVec< T, T_values... > > CVec
A vector with compile-time known values.
Definition CVec.hpp:31
Attention
The data is not initialized it can contains garbage.
Template Parameters
Ttype which should be created, the constructor is not called
T_uniqueIdid those is unique inside a kernel. Reusing the id will return the same memory declared before with the same id.
Parameters
extentM-dimensional extent in elements for each dimension, 1 - M dimensions are supported
Returns
MdSpan non owning view to the corresponding data, you should NOT store a reference to the handle

Definition at line 173 of file Acc.hpp.

◆ declareSharedVar()

template<typename T, size_t T_uniqueId>
decltype(auto) alpaka::onAcc::declareSharedVar ( concepts::Acc auto const & acc)
constexpr

Create a variable located in the thread blocks shared memory.

// creates a reference to a float value
Attention
The data is not initialized; it can contain garbage.
Template Parameters
TThe type that should be created; the constructor is not called
T_uniqueIdID that is unique inside a kernel. Reusing the id will return the same memory declared before with the same id.
Returns
Result should be taken by reference

Definition at line 152 of file Acc.hpp.

◆ getDynSharedMem()

template<typename T>
auto alpaka::onAcc::getDynSharedMem ( concepts::Acc auto const & acc) -> T *
constexpr

Get block shared dynamic memory.

The available size of the memory can be defined by specializing 'onHost::trait::GetDynSharedMemBytes' or adding a public member variable 'uint32_t dynSharedMemBytes' for a kernel. The Memory can be accessed by all threads within a block. Access to the memory is not thread safe.

Template Parameters
TThe element type.
Returns
Pointer to pre-allocated contiguous memory.

Definition at line 197 of file Acc.hpp.

◆ isSupportedByAtomicAtomicRef()

template<typename T>
void alpaka::onAcc::isSupportedByAtomicAtomicRef ( )

Definition at line 47 of file atomic.hpp.

◆ makeIdxMap() [1/3]

template<concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
ALPAKA_FN_HOST_ACC constexpr auto alpaka::onAcc::makeIdxMap ( auto const & acc,
auto const workGroup,
auto const range,
alpaka::concepts::BoundaryDirection auto const & bd,
T_Traverse traverse = T_Traverse{},
T_IdxLayout idxLayout = T_IdxLayout{} )
constexpr

Specialization for an index container with a given boundary direction of the volume described by the range.

Definition at line 75 of file interface.hpp.

◆ makeIdxMap() [2/3]

template<typename T_ScalarIdxType, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
ALPAKA_FN_HOST_ACC constexpr auto alpaka::onAcc::makeIdxMap ( auto const & acc,
auto const workGroup,
auto const range,
T_Traverse traverse = T_Traverse{},
T_IdxLayout idxLayout = T_IdxLayout{} )
constexpr

Creates an index container.

The traversal policy (T_Traverse) defines how the next valid index is found for a worker and defaults to traverse::Flat. The mapping policy (T_IdxLayout) defines how the index is mapped to worker threads and defaults to layout::Optimized.

Template Parameters
T_ScalarIdxTypescalar index type sed for the indices inside the iterator
Parameters
workGroupDescription of the participating thread group. More than one thread can have the same index within the group; all workers with the same id obtain the same index as result.
rangeIndex range description.
traversePolicy describing how the next value can be found.
idxLayoutPolicy describing how real worker threads will be mapped to the range.
Returns
A index container that can be used in a range-based for loop.

Definition at line 113 of file interface.hpp.

◆ makeIdxMap() [3/3]

template<concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
ALPAKA_FN_HOST_ACC constexpr auto alpaka::onAcc::makeIdxMap ( auto const & acc,
auto const workGroup,
auto const range,
T_Traverse traverse = T_Traverse{},
T_IdxLayout idxLayout = T_IdxLayout{} )
constexpr

Creates an index container.

The index data type is deduced from the supplied range. The traversal policy (T_Traverse) defines how the next valid index is found for a worker and defaults to traverse::Flat. The mapping policy (T_IdxLayout) defines how the index is mapped to worker threads and defaults to layout::Optimized.

Parameters
workGroupDescription of the participating thread group. More than one thread can have the same index within the group; all workers with the same id obtain the same index as result.
rangeIndex range description.
traversePolicy describing how the next value can be found.
idxLayoutPolicy describing how real worker threads will be mapped to the range.
Returns
A index container that can be used in a range-based for loop.

Definition at line 57 of file interface.hpp.

◆ memFence()

void alpaka::onAcc::memFence ( auto const & acc,
concepts::Scope auto const scope,
concepts::MemoryOrder auto const order )
constexpr

Definition at line 18 of file memFence.hpp.

◆ sync()

template<alpaka::concepts::Layer T_Scope>
void alpaka::onAcc::sync ( concepts::Acc auto const & acc,
T_Scope scope )
constexpr

Synchronize all threads within a given scope.

Definition at line 126 of file Acc.hpp.

◆ syncBlockThreads()

void alpaka::onAcc::syncBlockThreads ( concepts::Acc auto const & acc)
constexpr

Synchronize all threads within a thread block.

Definition at line 132 of file Acc.hpp.

Variable Documentation

◆ isOrigin_v

template<typename T>
bool alpaka::onAcc::isOrigin_v = trait::IsOrigin<T>::value
constexpr

Definition at line 88 of file tag.hpp.

◆ isUnit_v

template<typename T>
bool alpaka::onAcc::isUnit_v = trait::IsUnit<T>::value
constexpr

Definition at line 91 of file tag.hpp.

◆ linearized

auto alpaka::onAcc::linearized = MultiDimensional<false>{}
constexpr

Definition at line 21 of file WorkerGroup.hpp.