20 template<
typename T_Storage,
typename T_Type>
30 template<
typename T_Api, alpaka::concepts::DeviceKind T_DeviceKind>
44 template<
typename T_Platform>
49 return platform.getDeviceCount();
56 template<
typename T_Platform>
61 return platform.makeDevice(idx);
68 template<
typename T_Any>
73 return any.getDevice();
85 template<
typename T_Any>
90 return any.getNativeHandle();
102 template<
typename T_Device, alpaka::concepts::QueueKind T_QueueKind>
107 return device.makeQueue(T_QueueKind{});
114 template<
typename T_Device>
119 return device.makeEvent();
126 template<
typename T_Any>
143 template<
typename T_Queue,
typename T_Event>
148 queue.waitFor(event);
160 template<
typename T_Any>
165 return any.isEventComplete();
177 template<
typename T_Queue>
182 return queue.isQueueEmpty();
200 void operator()(T_Queue& queue, T_LaunchCfg
const& launchCfg, T_KernelBundle
const& kernelBundle)
const
202 queue.enqueue(launchCfg, kernelBundle);
206 template<
typename T_Queue,
typename T_Task>
211 queue.enqueueHostFn(task);
215 template<
typename T_Queue,
typename T_Task>
220 queue.enqueueHostFnDeferred(task);
224 template<
typename T_Queue,
typename T_Task>
229 queue.enqueueNativeFn(
fn);
233 template<
typename T_Queue,
typename T_Event>
238 queue.enqueue(event);
253 template<
typename TKernelFn,
typename... TArgs>
274 T_Device
const& device,
275 T_FrameSpec
const& frameSpec,
276 T_KernelBundle
const& kernelBundle)
const
278 alpaka::unused(device, frameSpec.getExecutor(), kernelBundle);
279 return ThreadSpec{frameSpec.getNumFrames(), frameSpec.getFrameExtents(), frameSpec.getExecutor()};
284 template<
typename TKernelFn,
typename... TArgs>
290 return AdjustThreadSpec::
299 template<
typename T_Any>
302 decltype(
auto)
operator()(
auto&& any)
const
304 return std::data(any);
308 static decltype(
auto)
data(
auto&& any)
313 template<
typename T_Any>
322 template<
typename T_Type,
typename T_Any,
typename T_Extents>
331 template<
typename T_Type,
typename T_Any,
typename T_Extents>
340 template<
typename T_Type,
typename T_Any,
typename T_Extents>
349 template<
typename T_Type,
typename T_Any,
typename T_Extents>
366 template<
typename T_Device,
typename T_Any>
372 template<
typename T_DataApi, alpaka::concepts::DeviceKind T_DeviceKind,
typename T_Any>
384 template<
typename T_Queue,
typename T_Dest,
typename T_Source,
typename T_Extents>
387 void operator()(T_Queue& queue,
auto&&, T_Source
const&, T_Extents
const&)
const;
393 template<
typename T_Queue,
typename T_Dest,
typename T_Source>
408 template<
typename T_Queue,
typename T_Dest,
typename T_Extents>
411 void operator()(T_Queue& queue,
auto&&, uint8_t, T_Extents
const&)
const;
417 template<
typename T_Queue,
typename T_Dest,
typename T_Value,
typename T_Extents>
420 void operator()(T_Queue& queue,
auto&&, T_Value, T_Extents
const&)
const;
426 template<
typename T_Any>
437 template<
typename T_Any>
442 return device.getFreeGlobalMemBytes();
454 template<
typename T_Any>
457 decltype(
auto)
operator()(
auto&& any)
const
459 return any.getExtents();
469 template<
typename T_Any>
477 template<
typename T_Any>
480 decltype(
auto)
operator()(
auto&& any)
const
482 return any.getPitches();
492 template<
typename T_Any>
503 auto const& internalDevice,
507 static_assert(executor !=
exec::anyExecutor,
"'exec::anyExecutor' can not be used here");
508 Vec extentMd = extents;
514 IndexType warpSize =
static_cast<IndexType
>(props.warpSize);
516 IndexType numFrameElements = 512;
519 ExtentVecType frameExtents = ExtentVecType::fill(1).rAssign(fastDimensionValue);
520 numFrameElements /= frameExtents.x();
522 while(numFrameElements > IndexType{1})
524 uint32_t maxIdx = ExtentVecType::dim() - 1u;
525 IndexType maxValue = 0;
526 for(
auto i = 0u; i < ExtentVecType::dim(); ++i)
528 auto v = extentMd[i] / frameExtents[i] / IndexType{2};
536 auto v = extentMd[maxIdx] / frameExtents[maxIdx] / IndexType{2};
537 if(v >= IndexType{1})
538 frameExtents[maxIdx] *= IndexType{2};
541 numFrameElements /= IndexType{2};
544 ExtentVecType numFrames =
divExZero(extentMd, frameExtents);
545 auto frameSpec =
FrameSpec{numFrames, frameExtents, executor};
556 template<
typename T_DataType>
558 auto const& internalDevice,
562 static_assert(executor !=
exec::anyExecutor,
"'exec::anyExecutor' can not be used here");
563 Vec extentMd = extents;
571 ExtentVecType frameExtents =
getFrameSpec(internalDevice, executor, extents).getFrameExtents();
573 IndexType elementsPerFrameItem
579 ExtentVecType numFrames
580 =
divExZero(extentMd, frameExtents * frameExtents.
fill(1).rAssign(elementsPerFrameItem));
#define ALPAKA_ASSERT(...)
The assert can be explicit disabled by defining NDEBUG.
The class used to bind kernel function object and arguments together. Once an instance of this class ...
#define ALPAKA_TYPEOF(...)
Get the type of instance.
Concept to check if something is a device kind.
Concept to check for an executor.
Concept to check if a type is a KernelBundle.
Concept to check if a type is a vector or scalar variable.
Concept to check if a type is a FrameSpec.
Concept to check if a type is a ThreadSpec or a FrameSpec.
constexpr AnyExecutor anyExecutor
Automatic executor selection.
alpaka'S function interface
constexpr auto getDeviceKind(auto &&any) -> decltype(GetDeviceType::Op< ALPAKA_TYPEOF(any)>{}(any))
constexpr auto getApi(auto &&any) -> decltype(GetApi::Op< ALPAKA_TYPEOF(any)>{}(any))
static auto adjustThreadSpec(auto const &device, onHost::concepts::FrameSpec auto const &frameSpec, KernelBundle< TKernelFn, TArgs... > const &kernelBundle)
constexpr auto getSimdFrameSpec(auto const &internalDevice, alpaka::concepts::Executor auto executor, alpaka::concepts::VectorOrScalar auto const &extents)
Provides a SIMD optimized frame specification.
bool isEventComplete(auto &&any)
static auto makePlatform(auto api, alpaka::concepts::DeviceKind auto deviceType)
bool isQueueEmpty(auto &queue)
DeviceProperties getDeviceProperties(auto const &platform, uint32_t idx)
constexpr auto getDevice(auto &&any)
auto getNativeHandle(auto &&any)
void enqueueHostFnDeferred(auto &queue, auto const &task)
void waitFor(auto &queue, auto &event)
constexpr auto getFrameSpec(auto const &internalDevice, alpaka::concepts::Executor auto executor, alpaka::concepts::VectorOrScalar auto const &extents)
Provide a frame specification for the given extents.
auto getExtents(auto &&any)
void enqueue(auto &queue, onHost::concepts::ThreadOrFrameSpec auto const &launchCfg, KernelBundle< TKernelFn, TArgs... > const &kernelBundle)
void enqueueHostFn(auto &queue, auto const &task)
auto getPitches(auto &&any)
Functionality which is usable on the host CPU controller thread.
std::shared_ptr< T > Handle
void reduce(Queue< T_Device, T_QueueKind > const &queue, alpaka::concepts::Executor auto const exec, DataType const &neutralElement, alpaka::concepts::IMdSpan auto out, auto &&binaryReduceFn, auto &&in)
accumulate the results into a scalar value.
typename GetValueType< T >::type GetValueType_t
ALPAKA_FN_HOST_ACC constexpr auto divExZero(Integral a, Integral b) -> Integral
Returns the max(a / b, 1) as integer.
consteval uint32_t getNumElemPerThread(concepts::Api auto const api, alpaka::concepts::DeviceKind auto const deviceType)
Get the number of elements to compute per thread.
constexpr T roundDownToPowerOfTwo(T value)
round to the next power of two which is equal or lower to the value
static constexpr auto fill(concepts::Convertible< T_Type > auto const &value)
Creates a Vec where all dimensions are set to the same value.
constexpr decltype(auto) x()
named member access
Helper class to provide access to device global memory variables.
Device/Api-agnostic description of the logical parallelism exposed to a kernel.
Backend-specific description of the actual block and thread launch shape.
auto operator()(T_Device const &device, T_FrameSpec const &frameSpec, T_KernelBundle const &kernelBundle) const
void operator()(T_Any &any, T_Extents const &) const
void operator()(T_Any &any, T_Extents const &) const
void operator()(T_Any &any, T_Extents const &) const
void operator()(T_Any &any, T_Extents const &) const
static decltype(auto) data(auto &&any)
static decltype(auto) data(Handle< T_Any > &&anyHandle)
void operator()(T_Queue &queue, T_Event &event) const
void operator()(T_Queue &queue, T_Task const &task) const
void operator()(T_Queue &queue, T_Task const &task) const
void operator()(T_Queue &queue, T_LaunchCfg const &launchCfg, T_KernelBundle const &kernelBundle) const
void operator()(T_Queue &queue, T_Task const &fn) const
void operator()(T_Queue &queue, auto &&, T_Value, T_Extents const &) const
uint32_t operator()(T_Platform &platform) const
DeviceProperties operator()(auto const &device) const
DeviceProperties operator()(auto const &platform, uint32_t idx) const
auto operator()(T_Any const &any) const
size_t operator()(auto const &device) const
auto operator()(T_Any const &any) const
bool operator()(T_Device &device, T_Any const &any) const
bool operator()(T_DataApi, T_DeviceKind, T_Any const &) const
checks if a view can be accessed from the given device
bool operator()(T_Any &any)
bool operator()(T_Queue &queue)
auto operator()(auto &platform, uint32_t idx) const
auto operator()(T_Device &device) const
auto operator()(T_Device &device, T_QueueKind) const
void operator()(T_Queue &queue, T_Dest &&, T_Source &&) const
copy data from or to the device global memory
void operator()(T_Queue &queue, auto &&, T_Source const &, T_Extents const &) const
void operator()(T_Queue &queue, auto &&, uint8_t, T_Extents const &) const
void operator()(T_Queue &queue, T_Event &event)
void operator()(T_Any &any)