alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
Traits.hpp
Go to the documentation of this file.
1/* Copyright 2026 Axel Huebl, Benjamin Worpitz, René Widera, Sergei Bastrakov, Jan Stephan, Bernhard Manfred Gruber,
2 * Andrea Bocci, Aurora Perego, Mehmet Yusufoglu
3 * SPDX-License-Identifier: MPL-2.0
4 */
5
6#pragma once
7
8#include "alpaka/acc/Tag.hpp"
12#include "alpaka/core/Debug.hpp"
15#include "alpaka/dim/Traits.hpp"
16#include "alpaka/idx/Traits.hpp"
19#include "alpaka/vec/Vec.hpp"
21
22#include <type_traits>
23
24//! The alpaka accelerator library.
25namespace alpaka
26{
27 //! The kernel traits.
28 namespace trait
29 {
30 //! The kernel execution task creation trait.
31 template<
32 typename TAcc,
33 typename TWorkDiv,
34 typename TKernelFnObj,
35 typename... TArgs/*,
36 typename TSfinae = void*/>
38
39 //! The cooperative kernel execution task creation trait.
40 template<
41 typename TAcc,
42 typename TWorkDiv,
43 typename TKernelFnObj,
44 typename... TArgs/*,
45 typename TSfinae = void*/>
47
48 //! Get maximum requested blocks for cooperative kernel trait.
49 template<typename TAcc, typename TDev, typename TKernelFnObj, typename TDim, typename TIdx, typename... TArgs>
51
52 //! The trait for getting the size of the block shared dynamic memory of a kernel.
53 //!
54 //! \tparam TKernelFnObj The kernel function object.
55 //! \tparam TAcc The accelerator.
56 //!
57 //! The default implementation returns 0.
58 template<typename TKernelFnObj, typename TAcc, typename TSfinae = void>
60 {
61#if ALPAKA_COMP_CLANG
62# pragma clang diagnostic push
63# pragma clang diagnostic ignored \
64 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
65#endif
66 //! \param kernelFnObj The kernel object for which the block shared memory size should be calculated.
67 //! \param blockThreadExtent The block thread extent.
68 //! \param threadElemExtent The thread element extent.
69 //! \tparam TArgs The kernel invocation argument types pack.
70 //! \param args,... The kernel invocation arguments.
71 //! \return The size of the shared memory allocated for a block in bytes.
72 //! The default version always returns zero.
73#if ALPAKA_COMP_CLANG
74# pragma clang diagnostic pop
75#endif
77 template<typename TDim, typename... TArgs>
79 [[maybe_unused]] TKernelFnObj const& kernelFnObj,
80 [[maybe_unused]] Vec<TDim, Idx<TAcc>> const& blockThreadExtent,
81 [[maybe_unused]] Vec<TDim, Idx<TAcc>> const& threadElemExtent,
82 [[maybe_unused]] TArgs const&... args) -> std::size_t
83 {
84 return 0u;
85 }
86 };
87
88 //! \brief The structure template to access to the functions attributes of a kernel function object.
89 //! \tparam TAcc The accelerator type
90 //! \tparam TKernelFnObj Kernel function object type.
91 //! \tparam TArgs Kernel function object argument types as a parameter pack.
92 template<typename TAcc, typename TDev, typename TKernelFnObj, typename... TArgs>
94 {
95 //! \param dev The device instance
96 //! \param kernelFn The kernel function object which should be executed.
97 //! \param args The kernel invocation arguments.
98 //! \return KernelFunctionAttributes data structure instance. The default version always returns the
99 //! instance with fields which are set to zero.
101 [[maybe_unused]] TDev const& dev,
102 [[maybe_unused]] TKernelFnObj const& kernelFn,
103 [[maybe_unused]] TArgs&&... args) -> alpaka::KernelFunctionAttributes
104 {
105 std::string const str
106 = std::string(__func__) + " function is not specialised for the given arguments.\n";
107 throw std::invalid_argument{str};
108 }
109 };
110
111 //! The trait for getting the warp size required by a kernel.
112 //!
113 //! \tparam TKernelFnObj The kernel function object.
114 //! \tparam TAcc The accelerator.
115 //!
116 //! The default implementation returns 0, which lets the accelerator compiler and runtime choose the warp size.
117 template<typename TKernelFnObj, typename TAcc, typename TSfinae = void>
118 struct WarpSize : std::integral_constant<std::uint32_t, 0>
119 {
120 };
121
122 //! This is a shortcut for the trait defined above
123 template<typename TKernelFnObj, typename TAcc>
124 inline constexpr std::uint32_t warpSize = WarpSize<TKernelFnObj, TAcc>::value;
125
126 //! The trait for getting the schedule to use when a kernel is run using the CpuOmp2Blocks accelerator.
127 //!
128 //! Has no effect on other accelerators.
129 //!
130 //! A user could either specialize this trait for their kernel, or define a public static member
131 //! ompScheduleKind of type alpaka::omp::Schedule, and additionally also int member ompScheduleChunkSize. In
132 //! the latter case, alpaka never odr-uses these members.
133 //!
134 //! In case schedule kind and chunk size are compile-time constants, setting then inside kernel may benefit
135 //! performance.
136 //!
137 //! \tparam TKernelFnObj The kernel function object.
138 //! \tparam TAcc The accelerator.
139 //!
140 //! The default implementation behaves as if the trait was not specialized.
141 template<typename TKernelFnObj, typename TAcc, typename TSfinae = void>
143 {
144 private:
145 //! Type returned when the trait is not specialized
146 struct TraitNotSpecialized
147 {
148 };
149
150 public:
151#if ALPAKA_COMP_CLANG
152# pragma clang diagnostic push
153# pragma clang diagnostic ignored \
154 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
155#endif
156 //! \param kernelFnObj The kernel object for which the schedule should be returned.
157 //! \param blockThreadExtent The block thread extent.
158 //! \param threadElemExtent The thread element extent.
159 //! \tparam TArgs The kernel invocation argument types pack.
160 //! \param args,... The kernel invocation arguments.
161 //! \return The OpenMP schedule information as an alpaka::omp::Schedule object,
162 //! returning an object of any other type is treated as if the trait is not specialized.
163#if ALPAKA_COMP_CLANG
164# pragma clang diagnostic pop
165#endif
167 template<typename TDim, typename... TArgs>
169 [[maybe_unused]] TKernelFnObj const& kernelFnObj,
170 [[maybe_unused]] Vec<TDim, Idx<TAcc>> const& blockThreadExtent,
171 [[maybe_unused]] Vec<TDim, Idx<TAcc>> const& threadElemExtent,
172 [[maybe_unused]] TArgs const&... args) -> TraitNotSpecialized
173 {
174 return TraitNotSpecialized{};
175 }
176 };
177 } // namespace trait
178
179#if ALPAKA_COMP_CLANG
180# pragma clang diagnostic push
181# pragma clang diagnostic ignored \
182 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
183#endif
184//! \tparam TAcc The accelerator type.
185//! \param kernelFnObj The kernel object for which the block shared memory size should be calculated.
186//! \param blockThreadExtent The block thread extent.
187//! \param threadElemExtent The thread element extent.
188//! \param args,... The kernel invocation arguments.
189//! \return The size of the shared memory allocated for a block in bytes.
190//! The default implementation always returns zero.
191#if ALPAKA_COMP_CLANG
192# pragma clang diagnostic pop
193#endif
195 template<typename TAcc, typename TKernelFnObj, typename TDim, typename... TArgs>
196
198 TKernelFnObj const& kernelFnObj,
199 Vec<TDim, Idx<TAcc>> const& blockThreadExtent,
200 Vec<TDim, Idx<TAcc>> const& threadElemExtent,
201 TArgs const&... args) -> std::size_t
202 {
204 kernelFnObj,
205 blockThreadExtent,
206 threadElemExtent,
207 args...);
208 }
209
210 //! \tparam TAcc The accelerator type.
211 //! \tparam TDev The device type.
212 //! \param dev The device instance
213 //! \param kernelFnObj The kernel function object which should be executed.
214 //! \param args The kernel invocation arguments.
215 //! \return KernelFunctionAttributes instance. Instance is filled with values returned by the accelerator API
216 //! depending on the specific kernel. The default version always returns the instance with fields which are set to
217 //! zero.
219 template<typename TAcc, typename TDev, typename TKernelFnObj, typename... TArgs>
220 ALPAKA_FN_HOST auto getFunctionAttributes(TDev const& dev, TKernelFnObj const& kernelFnObj, TArgs&&... args)
222 {
224 dev,
225 kernelFnObj,
226 std::forward<TArgs>(args)...);
227 }
228
229#if ALPAKA_COMP_CLANG
230# pragma clang diagnostic push
231# pragma clang diagnostic ignored \
232 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
233#endif
234 //! \tparam TAcc The accelerator type.
235 //! \param device The device for which the maximum block count should be calculated.
236 //! \param kernelFnObj The kernel object for which the maximum block count should be calculated.
237 //! \param blockThreadExtent The block thread extent.
238 //! \param threadElemExtent The thread element extent.
239 //! \param args... The kernel invocation arguments.
240 //! \return The maximum block count with which the device can launch the specified cooperative kernel with
241 //! specified extents.
242 //!
243#if ALPAKA_COMP_CLANG
244# pragma clang diagnostic pop
245#endif
247 template<typename TAcc, typename TDev, typename TKernelFnObj, typename TDim, typename TIdx, typename... TArgs>
249 TDev const& device,
250 TKernelFnObj const& kernelFnObj,
251 alpaka::Vec<TDim, TIdx> const& blockThreadExtent,
252 alpaka::Vec<TDim, TIdx> const& threadElemExtent,
253 TArgs const&... args) -> int
254 {
256 kernelFnObj,
257 device,
258 blockThreadExtent,
259 threadElemExtent,
260 args...);
261 }
262
263 //! Returns the maximum block aount for cooperative kernle launch on the device.
264 //! Note that grid sync and other cooperative launch fucntioanlity is not guaranteed to work if you don't use
265 //! createTaskCooperativeKernel()
266#if ALPAKA_COMP_CLANG
267# pragma clang diagnostic push
268# pragma clang diagnostic ignored \
269 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
270#endif
271 //! \tparam TAcc The accelerator type.
272 //! \param device The device for which the maximum block count should be calculated.
273 //! \param kernelFnObj The kernel object for which the maximum block count should be calculated.
274 //! \param blockThreadExtent The block thread extent.
275 //! \param threadElemExtent The thread element extent.
276 //! \param args... The kernel invocation arguments.
277 //! \return The maximum block count with which the device can launch the specified cooperative kernel with
278 //! specified extents.
279 //!
280#if ALPAKA_COMP_CLANG
281# pragma clang diagnostic pop
282#endif
284 template<typename TAcc, typename TDev, typename TKernelFnObj, typename TIdx, typename... TArgs>
285
287 TDev const& device,
288 TKernelFnObj const& kernelFnObj,
289 TIdx const& blockThreadExtent,
290 TIdx const& threadElemExtent,
291 TArgs const&... args) -> int
292 {
293 auto const v_blockThreadExtent = Vec<DimInt<1>, TIdx>(blockThreadExtent);
294 auto const v_threadElemExtent = Vec<DimInt<1>, TIdx>(threadElemExtent);
296 kernelFnObj,
297 device,
298 v_blockThreadExtent,
299 v_threadElemExtent,
300 args...);
301 }
302
303#if ALPAKA_COMP_CLANG
304# pragma clang diagnostic push
305# pragma clang diagnostic ignored \
306 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
307#endif
308//! \tparam TAcc The accelerator type.
309//! \param kernelFnObj The kernel object for which the block shared memory size should be calculated.
310//! \param blockThreadExtent The block thread extent.
311//! \param threadElemExtent The thread element extent.
312//! \param args,... The kernel invocation arguments.
313//! \return The OpenMP schedule information as an alpaka::omp::Schedule object if the kernel specialized the
314//! OmpSchedule trait, an object of another type if the kernel didn't specialize the trait.
315#if ALPAKA_COMP_CLANG
316# pragma clang diagnostic pop
317#endif
318 template<typename TAcc, typename TKernelFnObj, typename TDim, typename... TArgs>
320 TKernelFnObj const& kernelFnObj,
321 Vec<TDim, Idx<TAcc>> const& blockThreadExtent,
322 Vec<TDim, Idx<TAcc>> const& threadElemExtent,
323 TArgs const&... args)
324 {
326 kernelFnObj,
327 blockThreadExtent,
328 threadElemExtent,
329 args...);
330 }
331
332#if ALPAKA_COMP_CLANG
333# pragma clang diagnostic push
334# pragma clang diagnostic ignored \
335 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
336#endif
337
338
339 //! Check if a type used as kernel argument is trivially copyable
340 //!
341 //! \attention In case this trait is specialized for a user type the user should be sure that the result of calling
342 //! the copy constructor is equal to use memcpy to duplicate the object. An existing destructor should be free
343 //! of side effects.
344 //!
345 //! It's implementation defined whether the closure type of a lambda is trivially copyable.
346 //! Therefor the default implementation is true for trivially copyable or empty (stateless) types.
347 //!
348 //! @tparam T type to check
349 //! @{
350 template<typename T, typename = void>
352 : std::bool_constant<std::is_empty_v<T> || std::is_trivially_copyable_v<T>>
353 {
354 };
355
356 template<typename T>
358
359 //! @}
360
361 namespace detail
362 {
363 // asserts that T is trivially copyable. We put this in a separate function so we can see which T would fail
364 // the test, when called from a fold expression.
365 template<typename T>
367 {
368 static_assert(isKernelArgumentTriviallyCopyable<T>, "The kernel argument T must be trivially copyable!");
369 }
370
371 template<typename TKernelFnObj, typename TAcc, typename... TArgs>
372 ALPAKA_FN_HOST_ACC auto checkKernelReturnType(TKernelFnObj const&, TAcc const&, TArgs&&...) -> void
373 {
374 static_assert(
375 std::is_invocable_r_v<void, TKernelFnObj const&, TAcc const&, TArgs&&...>,
376 "The kernel is not invocable with the given arguments!");
377 }
378 } // namespace detail
379
380 //! Check if the kernel type is trivially copyable
381 //!
382 //! \attention In case this trait is specialized for a user type the user should be sure that the result of calling
383 //! the copy constructor is equal to use memcpy to duplicate the object. An existing destructor should be free
384 //! of side effects.
385 //!
386 //! The default implementation is true for trivially copyable types (or for extended lambda expressions for CUDA).
387 //!
388 //! @tparam T type to check
389 //! @{
390 template<typename T, typename = void>
393 : std::bool_constant<
394 std::is_trivially_copyable_v<T> || __nv_is_extended_device_lambda_closure_type(T)
395 || __nv_is_extended_host_device_lambda_closure_type(T)>
396#else
397 : std::is_trivially_copyable<T>
398#endif
399 {
400 };
401
402 template<typename T>
404
405 //! @}
406
407#if ALPAKA_COMP_CLANG
408# pragma clang diagnostic push
409# pragma clang diagnostic ignored \
410 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
411#endif
412//! Creates a kernel execution task.
413//!
414//! \tparam TAcc The accelerator type.
415//! \param workDiv The index domain work division.
416//! \param kernelFnObj The kernel function object which should be executed.
417//! \param args,... The kernel invocation arguments.
418//! \return The kernel execution task.
419#if ALPAKA_COMP_CLANG
420# pragma clang diagnostic pop
421#endif
422 template<typename TAcc, typename TWorkDiv, typename TKernelFnObj, typename... TArgs>
423 ALPAKA_FN_HOST auto createTaskKernel(TWorkDiv const& workDiv, TKernelFnObj const& kernelFnObj, TArgs&&... args)
424 {
425#if ALPAKA_COMP_NVCC
426 static_assert(
428 "Kernels must be trivially copyable or an extended CUDA lambda expression!");
429#else
430 static_assert(isKernelTriviallyCopyable<TKernelFnObj>, "Kernels must be trivially copyable!");
431#endif
433 static_assert(
435 "The dimensions of TAcc and TWorkDiv have to be identical!");
436 static_assert(
437 std::is_same_v<Idx<std::decay_t<TWorkDiv>>, Idx<TAcc>>,
438 "The idx type of TAcc and the idx type of TWorkDiv have to be identical!");
439
440#if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
441 std::cout << __func__ << " workDiv: " << workDiv << ", kernelFnObj: " << core::demangled<decltype(kernelFnObj)>
442 << std::endl;
443#endif
445 workDiv,
446 kernelFnObj,
447 std::forward<TArgs>(args)...);
448 }
449
450#if ALPAKA_COMP_CLANG
451# pragma clang diagnostic push
452# pragma clang diagnostic ignored \
453 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
454#endif
455//! Creates a cooperative kernel execution task.
456//! Allows to use grid sync, but disables dynamic parallelism and enforces a hardware limit on the number of blocks.
457//!
458//! \tparam TAcc The accelerator type.
459//! \param workDiv The index domain work division.
460//! \param kernelFnObj The kernel function object which should be executed.
461//! \param args,... The kernel invocation arguments.
462//! \return The kernel execution task.
463#if ALPAKA_COMP_CLANG
464# pragma clang diagnostic pop
465#endif
466 template<typename TAcc, typename TWorkDiv, typename TKernelFnObj, typename... TArgs>
468 TWorkDiv const& workDiv,
469 TKernelFnObj const& kernelFnObj,
470 TArgs&&... args)
471 {
472#if ALPAKA_COMP_NVCC
473 static_assert(
475 "Kernels must be trivially copyable or an extended CUDA lambda expression!");
476#else
477 static_assert(isKernelTriviallyCopyable<TKernelFnObj>, "Kernels must be trivially copyable!");
478#endif
480 static_assert(
482 "The dimensions of TAcc and TWorkDiv have to be identical!");
483 static_assert(
484 std::is_same_v<Idx<std::decay_t<TWorkDiv>>, Idx<TAcc>>,
485 "The idx type of TAcc and the idx type of TWorkDiv have to be identical!");
486
487#if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
488 std::cout << __func__ << " workDiv: " << workDiv << ", kernelFnObj: " << core::demangled<decltype(kernelFnObj)>
489 << std::endl;
490#endif
492 workDiv,
493 kernelFnObj,
494 std::forward<TArgs>(args)...);
495 }
496
497#if ALPAKA_COMP_CLANG
498# pragma clang diagnostic push
499# pragma clang diagnostic ignored \
500 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
501#endif
502//! Executes the given kernel in the given queue.
503//!
504//! \tparam TAcc The accelerator type.
505//! \param queue The queue to enqueue the view copy task into.
506//! \param workDiv The index domain work division.
507//! \param kernelFnObj The kernel function object which should be executed.
508//! \param args,... The kernel invocation arguments.
509#if ALPAKA_COMP_CLANG
510# pragma clang diagnostic pop
511#endif
512 template<concepts::Acc TAcc, typename TQueue, typename TWorkDiv, typename TKernelFnObj, typename... TArgs>
513 ALPAKA_FN_HOST auto exec(TQueue& queue, TWorkDiv const& workDiv, TKernelFnObj const& kernelFnObj, TArgs&&... args)
514 -> void
515 {
516 enqueue(queue, createTaskKernel<TAcc>(workDiv, kernelFnObj, std::forward<TArgs>(args)...));
517 }
518
519#if ALPAKA_COMP_CLANG
520# pragma clang diagnostic push
521# pragma clang diagnostic ignored \
522 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
523#endif
524//! Executes the given kernel in the given queue.
525//!
526//! \tparam TTag The tag type.
527//! \param queue The queue to enqueue the view copy task into.
528//! \param workDiv The index domain work division.
529//! \param kernelFnObj The kernel function object which should be executed.
530//! \param args,... The kernel invocation arguments.
531#if ALPAKA_COMP_CLANG
532# pragma clang diagnostic pop
533#endif
534 template<concepts::Tag TTag, typename TQueue, typename TWorkDiv, typename TKernelFnObj, typename... TArgs>
535 ALPAKA_FN_HOST auto exec(TQueue& queue, TWorkDiv const& workDiv, TKernelFnObj const& kernelFnObj, TArgs&&... args)
536 -> void
537 {
539 enqueue(queue, createTaskKernel<Acc>(workDiv, kernelFnObj, std::forward<TArgs>(args)...));
540 }
541
542#if ALPAKA_COMP_CLANG
543# pragma clang diagnostic push
544# pragma clang diagnostic ignored \
545 "-Wdocumentation" // clang does not support the syntax for variadic template arguments "args,..."
546#endif
547//! Executes the given kernel in cooperative mode in the given queue.
548//!
549//! \tparam TTag The tag type.
550//! \param queue The queue to enqueue the view copy task into.
551//! \param workDiv The index domain work division.
552//! \param kernelFnObj The kernel function object which should be executed.
553//! \param args,... The kernel invocation arguments.
554#if ALPAKA_COMP_CLANG
555# pragma clang diagnostic pop
556#endif
557 template<concepts::Tag TTag, typename TQueue, typename TWorkDiv, typename TKernelFnObj, typename... TArgs>
559 TQueue& queue,
560 TWorkDiv const& workDiv,
561 TKernelFnObj const& kernelFnObj,
562 TArgs&&... args) -> void
563 {
564 enqueue(
565 queue,
566 createTaskCooperativeKernel<TagToAcc<TTag, Dim<std::decay_t<TWorkDiv>>, Idx<std::decay_t<TWorkDiv>>>>(
567 workDiv,
568 kernelFnObj,
569 std::forward<TArgs>(args)...));
570 }
571
572} // namespace alpaka
#define ALPAKA_COMP_NVCC
Definition Config.hpp:139
A n-dimensional vector.
Definition Vec.hpp:38
#define ALPAKA_FN_HOST
Definition Common.hpp:43
#define ALPAKA_FN_HOST_ACC
Definition Common.hpp:42
#define ALPAKA_NO_HOST_ACC_WARNING
Disable nvcc warning: 'calling a host function from host device function.' Usage: ALPAKA_NO_HOST_ACC_...
Definition Common.hpp:85
constexpr std::string_view demangled
ALPAKA_FN_HOST_ACC auto checkKernelReturnType(TKernelFnObj const &, TAcc const &, TArgs &&...) -> void
Definition Traits.hpp:372
void assertKernelArgIsTriviallyCopyable()
Definition Traits.hpp:366
constexpr std::uint32_t warpSize
This is a shortcut for the trait defined above.
Definition Traits.hpp:124
The alpaka accelerator library.
constexpr bool isKernelTriviallyCopyable
Definition Traits.hpp:403
typename trait::AccType< T >::type Acc
The accelerator type trait alias template to remove the ::type.
Definition Traits.hpp:83
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST auto getFunctionAttributes(TDev const &dev, TKernelFnObj const &kernelFnObj, TArgs &&... args) -> alpaka::KernelFunctionAttributes
Definition Traits.hpp:220
typename trait::IdxType< T >::type Idx
Definition Traits.hpp:29
ALPAKA_FN_HOST auto createTaskKernel(TWorkDiv const &workDiv, TKernelFnObj const &kernelFnObj, TArgs &&... args)
Creates a kernel execution task.
Definition Traits.hpp:423
ALPAKA_FN_HOST auto execCooperative(TQueue &queue, TWorkDiv const &workDiv, TKernelFnObj const &kernelFnObj, TArgs &&... args) -> void
Executes the given kernel in cooperative mode in the given queue.
Definition Traits.hpp:558
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getMaxActiveBlocks(TDev const &device, TKernelFnObj const &kernelFnObj, alpaka::Vec< TDim, TIdx > const &blockThreadExtent, alpaka::Vec< TDim, TIdx > const &threadElemExtent, TArgs const &... args) -> int
Definition Traits.hpp:248
ALPAKA_FN_HOST auto createTaskCooperativeKernel(TWorkDiv const &workDiv, TKernelFnObj const &kernelFnObj, TArgs &&... args)
Creates a cooperative kernel execution task. Allows to use grid sync, but disables dynamic parallelis...
Definition Traits.hpp:467
typename trait::TagToAcc< TTag, TDim, TIdx >::type TagToAcc
maps a tag type to an acc type
Definition Tag.hpp:76
ALPAKA_FN_HOST auto enqueue(TQueue &queue, TTask &&task) -> void
Queues the given task in the given queue.
Definition Traits.hpp:54
ALPAKA_FN_HOST auto exec(TQueue &queue, TWorkDiv const &workDiv, TKernelFnObj const &kernelFnObj, TArgs &&... args) -> void
Executes the given kernel in the given queue.
Definition Traits.hpp:513
ALPAKA_FN_HOST auto getOmpSchedule(TKernelFnObj const &kernelFnObj, Vec< TDim, Idx< TAcc > > const &blockThreadExtent, Vec< TDim, Idx< TAcc > > const &threadElemExtent, TArgs const &... args)
Definition Traits.hpp:319
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getBlockSharedMemDynSizeBytes(TKernelFnObj const &kernelFnObj, Vec< TDim, Idx< TAcc > > const &blockThreadExtent, Vec< TDim, Idx< TAcc > > const &threadElemExtent, TArgs const &... args) -> std::size_t
Definition Traits.hpp:197
constexpr bool isKernelArgumentTriviallyCopyable
Definition Traits.hpp:357
typename trait::DimType< T >::type Dim
The dimension type trait alias template to remove the ::type.
Definition Traits.hpp:19
Check if a type used as kernel argument is trivially copyable.
Definition Traits.hpp:353
Check if the kernel type is trivially copyable.
Definition Traits.hpp:399
Kernel function attributes struct. Attributes are filled by calling the API of the accelerator using ...
The trait for getting the size of the block shared dynamic memory of a kernel.
Definition Traits.hpp:60
ALPAKA_NO_HOST_ACC_WARNING static ALPAKA_FN_HOST_ACC auto getBlockSharedMemDynSizeBytes(TKernelFnObj const &kernelFnObj, Vec< TDim, Idx< TAcc > > const &blockThreadExtent, Vec< TDim, Idx< TAcc > > const &threadElemExtent, TArgs const &... args) -> std::size_t
Definition Traits.hpp:78
The cooperative kernel execution task creation trait.
Definition Traits.hpp:46
The kernel execution task creation trait.
Definition Traits.hpp:37
The structure template to access to the functions attributes of a kernel function object.
Definition Traits.hpp:94
static ALPAKA_FN_HOST auto getFunctionAttributes(TDev const &dev, TKernelFnObj const &kernelFn, TArgs &&... args) -> alpaka::KernelFunctionAttributes
Definition Traits.hpp:100
Get maximum requested blocks for cooperative kernel trait.
Definition Traits.hpp:50
The trait for getting the schedule to use when a kernel is run using the CpuOmp2Blocks accelerator.
Definition Traits.hpp:143
ALPAKA_NO_HOST_ACC_WARNING static ALPAKA_FN_HOST auto getOmpSchedule(TKernelFnObj const &kernelFnObj, Vec< TDim, Idx< TAcc > > const &blockThreadExtent, Vec< TDim, Idx< TAcc > > const &threadElemExtent, TArgs const &... args) -> TraitNotSpecialized
Definition Traits.hpp:168
The trait for getting the warp size required by a kernel.
Definition Traits.hpp:119