alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
tag.hpp
Go to the documentation of this file.
1/* Copyright 2024 René Widera
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
7#include "alpaka/core/PP.hpp"
8#include "alpaka/core/Tag.hpp"
10#include "alpaka/unused.hpp"
11
12#include <cassert>
13#include <string>
14#include <tuple>
15
16namespace alpaka
17{
18 namespace object
19 {
20 struct Api
21 {
22 };
23
24 constexpr Api api;
25
27 {
28 };
29
31
33
34 ALPAKA_TAG(launchedWidthFrameSpec);
35
36 ALPAKA_TAG(dynSharedMemBytes);
37
38 struct WarpSize
39 {
40 };
41
42 constexpr WarpSize warpSize;
43 } // namespace object
44
45 namespace queueKind
46 {
47 namespace detail
48 {
49 struct QueueKindBase
50 {
51 };
52 } // namespace detail
53
54 namespace trait
55 {
56 template<typename T_QueueKind>
57 struct IsQueueKind : std::is_base_of<detail::QueueKindBase, T_QueueKind>
58 {
59 };
60 } // namespace trait
61
62 template<typename T_QueueKind>
64 } // namespace queueKind
65
66 namespace concepts
67 {
68 /** Concept to check if a type is a queue kind
69 *
70 * @details
71 * Example queue kinds are alpaka::queueKind::Blocking or alpaka::queueKind::NonBlocking.
72 */
73 template<typename T_QueueKind>
75 } // namespace concepts
76
77 namespace queueKind
78 {
80 {
81 return std::is_same_v<ALPAKA_TYPEOF(lhs), ALPAKA_TYPEOF(rhs)>;
82 }
83
85 {
86 return !(lhs == rhs);
87 }
88
89 /** Queue should block during the task execution
90 */
91 struct Blocking : detail::QueueKindBase
92 {
93 static std::string getName()
94 {
95 return "Blocking";
96 }
97 };
98
99 constexpr auto blocking = Blocking{};
100
101 /** Queue should process task asynchronously
102 */
103 struct NonBlocking : detail::QueueKindBase
104 {
105 static std::string getName()
106 {
107 return "NonBlocking";
108 }
109 };
110
111 constexpr auto nonBlocking = NonBlocking{};
112 } // namespace queueKind
113
114 namespace deviceKind
115 {
116 namespace detail
117 {
118 struct DeviceKindBase
119 {
120 };
121 } // namespace detail
122
123 namespace trait
124 {
125 template<typename T_DeviceKind>
126 struct IsDeviceKind : std::is_base_of<detail::DeviceKindBase, T_DeviceKind>
127 {
128 };
129 } // namespace trait
130
131 template<typename T_DeviceKind>
133 } // namespace deviceKind
134
135 namespace concepts
136 {
137 /** @brief Concept to check if something is a device kind
138 *
139 * @details
140 * A device kind in alpaka is a type of acceleration device, such as a GPU vendor. Examples are
141 * alpaka::deviceKind::amdGpu or alpaka::deviceKind::cpu. Together with an alpaka::onHost::Api, it can make
142 * up an alpaka::onHost::Device.
143 */
144 template<typename T_DeviceKind>
146 } // namespace concepts
147
148 namespace deviceKind
149 {
150 constexpr bool operator==(concepts::DeviceKind auto lhs, concepts::DeviceKind auto rhs)
151 {
152 return std::is_same_v<ALPAKA_TYPEOF(lhs), ALPAKA_TYPEOF(rhs)>;
153 }
154
155 constexpr bool operator!=(concepts::DeviceKind auto lhs, concepts::DeviceKind auto rhs)
156 {
157 return !(lhs == rhs);
158 }
159
160 struct Cpu : detail::DeviceKindBase
161 {
162 static std::string getName()
163 {
164 return "Cpu";
165 }
166 };
167
168 constexpr auto cpu = Cpu{};
169
170 struct NumaCpu : detail::DeviceKindBase
171 {
172 static std::string getName()
173 {
174 return "NumaCpu";
175 }
176 };
177
178 constexpr auto numaCpu = NumaCpu{};
179
180 struct AmdGpu : detail::DeviceKindBase
181 {
182 static std::string getName()
183 {
184 return "AmdGpu";
185 }
186 };
187
188 constexpr auto amdGpu = AmdGpu{};
189
190 struct NvidiaGpu : detail::DeviceKindBase
191 {
192 static std::string getName()
193 {
194 return "NvidiaGpu";
195 }
196 };
197
198 constexpr auto nvidiaGpu = NvidiaGpu{};
199
200 struct IntelGpu : detail::DeviceKindBase
201 {
202 static std::string getName()
203 {
204 return "IntelGpu";
205 }
206 };
207
208 constexpr auto intelGpu = IntelGpu{};
209
210 constexpr auto allDevices = std::make_tuple(cpu, numaCpu, amdGpu, nvidiaGpu, intelGpu);
211
212 } // namespace deviceKind
213
214 namespace layer
215 {
216 namespace detail
217 {
218 struct LayerBase
219 {
220 };
221 } // namespace detail
222
223 namespace trait
224 {
225 template<typename T_Layer>
226 struct IsLayer : std::is_base_of<detail::LayerBase, T_Layer>
227 {
228 };
229 } // namespace trait
230
231 template<typename T_Layer>
233 } // namespace layer
234
235 namespace concepts
236 {
237 /** @brief Concept to check for a compute layer of an accelerator
238 *
239 * @details
240 * A layer is one specific part of the compute hierarchy of accelerators, for example alpaka::layer::Thread or
241 * alpaka::layer::Block.
242 */
243 template<typename T_Layer>
245 } // namespace concepts
246
247 namespace layer
248 {
249 struct Thread : detail::LayerBase
250 {
251 };
252
253 constexpr auto thread = Thread{};
254
255 struct Block : detail::LayerBase
256 {
257 };
258
259 constexpr auto block = Block{};
260
261 ALPAKA_TAG(shared);
262 ALPAKA_TAG(dynShared);
263 } // namespace layer
264
265 namespace action
266 {
267 ALPAKA_TAG(threadBlockSync);
268 } // namespace action
269
270 struct Empty
271 {
272 };
273
274 namespace exec
275 {
276 namespace trait
277 {
278 template<typename T_Executor>
279 struct IsSeqExecutor : std::false_type
280 {
281 };
282 } // namespace trait
283
284 template<typename T_Exec>
286 } // namespace exec
287
288 /** check if a executor can only be used with a single thread per block
289 *
290 * @return true if a block can only have a single thread, else false
291 */
292 template<typename T_Exec>
293 consteval bool isSeqExecutor(T_Exec exec)
294 {
295 alpaka::unused(exec);
297 }
298} // namespace alpaka
#define ALPAKA_TAG(name)
Definition Tag.hpp:16
#define ALPAKA_TYPEOF(...)
Get the type of instance.
Definition common.hpp:154
Concept to check if something is a device kind.
Definition tag.hpp:145
Concept to check for a compute layer of an accelerator.
Definition tag.hpp:244
Concept to check if a type is a queue kind.
Definition tag.hpp:74
constexpr auto allDevices
Definition tag.hpp:210
constexpr auto intelGpu
Definition tag.hpp:208
constexpr bool operator==(concepts::DeviceKind auto lhs, concepts::DeviceKind auto rhs)
Definition tag.hpp:150
constexpr bool operator!=(concepts::DeviceKind auto lhs, concepts::DeviceKind auto rhs)
Definition tag.hpp:155
constexpr auto amdGpu
Definition tag.hpp:188
constexpr bool isDeviceKind_v
Definition tag.hpp:132
constexpr auto cpu
Definition tag.hpp:168
constexpr auto numaCpu
Definition tag.hpp:178
constexpr auto nvidiaGpu
Definition tag.hpp:198
constexpr bool isSeqExecutor_v
Definition tag.hpp:285
constexpr auto block
Definition tag.hpp:259
constexpr auto thread
Definition tag.hpp:253
constexpr bool isLayer_v
Definition tag.hpp:232
constexpr WarpSize warpSize
Definition tag.hpp:42
constexpr DeviceKind deviceKind
Definition tag.hpp:30
constexpr Api api
Definition tag.hpp:24
constexpr bool operator!=(alpaka::concepts::QueueKind auto lhs, alpaka::concepts::QueueKind auto rhs)
Definition tag.hpp:84
constexpr auto blocking
Definition tag.hpp:99
constexpr auto nonBlocking
Definition tag.hpp:111
constexpr bool operator==(alpaka::concepts::QueueKind auto lhs, alpaka::concepts::QueueKind auto rhs)
Definition tag.hpp:79
constexpr bool isQueueKind_v
Definition tag.hpp:63
main alpaka namespace.
Definition alpaka.hpp:76
consteval bool isSeqExecutor(T_Exec exec)
check if a executor can only be used with a single thread per block
Definition tag.hpp:293
static std::string getName()
Definition tag.hpp:182
static std::string getName()
Definition tag.hpp:162
static std::string getName()
Definition tag.hpp:202
static std::string getName()
Definition tag.hpp:172
static std::string getName()
Definition tag.hpp:192
Queue should block during the task execution.
Definition tag.hpp:92
static std::string getName()
Definition tag.hpp:93
Queue should process task asynchronously.
Definition tag.hpp:104
static std::string getName()
Definition tag.hpp:105