alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
trait.hpp
Go to the documentation of this file.
1/* Copyright 2025 René Widera
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
7
10#include "alpaka/tag.hpp"
11
12#include <cstdint>
13
14namespace alpaka
15{
16 namespace onAcc::internal
17 {
18 namespace trait
19 {
20 struct AutoIndexMapping
21 {
22 template<typename T_Acc, typename T_Api, alpaka::concepts::DeviceKind T_DeviceKind>
23 struct Op
24 {
25 constexpr auto operator()(T_Acc const&, T_Api, T_DeviceKind) const
26 {
27 return layout::Strided{};
28 }
29 };
30 };
31 } // namespace trait
32
33 constexpr auto adjustMapping(auto const& acc)
34 {
35 return trait::AutoIndexMapping::
36 Op<ALPAKA_TYPEOF(acc), ALPAKA_TYPEOF(acc.getApi()), ALPAKA_TYPEOF(acc.getDeviceKind())>{}(
37 acc,
38 acc.getApi(),
39 acc.getDeviceKind());
40 }
41
42 } // namespace onAcc::internal
43
44 namespace internal
45 {
46 /** Specialize the trait for DataSource class if the object is copyable.
47 *
48 * @tparam TDataSource The DataSource class.
49 *
50 * @details
51 *
52 * The trait is used in the alpaka::internal::concepts::CopyConstructableDataSource concept to check whether
53 * the copy constructor respects the const correctness of the data type.
54 *
55 * Example specialization:
56 *
57 * @code
58 * template<typename T_Type>
59 * struct CopyConstructableDataSource<Storage<T_Type> : std::true_type {
60 * using InnerMutable = Storage<std::remove_const_t<T_Type>>;
61 * using InnerConst = Storage<std::add_const_t<T_Type>>;
62 * };
63 * @endcode
64 */
65 template<typename TDataSource>
66 struct CopyConstructableDataSource : std::false_type
67 {
68 };
69
70 }; // namespace internal
71} // namespace alpaka
#define ALPAKA_TYPEOF(...)
Get the type of instance.
Definition common.hpp:153
main alpaka namespace.
Definition alpaka.hpp:76