alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
Config.hpp
Go to the documentation of this file.
1
/* Copyright 2023 Benjamin Worpitz, Matthias Werner, René Widera, Sergei Bastrakov, Jeffrey Kelling,
2
* Bernhard Manfred Gruber, Jan Stephan
3
* SPDX-License-Identifier: MPL-2.0
4
*/
5
6
#pragma once
7
8
#include "
alpaka/core/PP.hpp
"
9
10
#ifdef __INTEL_COMPILER
11
# warning \
12
"The Intel Classic compiler (icpc) is no longer supported. Please upgrade to the Intel LLVM compiler (ipcx)."
13
#endif
14
15
// ######## detect operating systems ########
16
17
// WINDOWS
18
#if !defined(ALPAKA_OS_WINDOWS)
19
# if defined(_WIN64) || defined(__MINGW64__)
20
# define ALPAKA_OS_WINDOWS 1
21
# else
22
# define ALPAKA_OS_WINDOWS 0
23
# endif
24
#endif
25
26
27
// Linux
28
#if !defined(ALPAKA_OS_LINUX)
29
# if defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
30
# define ALPAKA_OS_LINUX 1
31
# else
32
# define ALPAKA_OS_LINUX 0
33
# endif
34
#endif
35
36
// Apple
37
#if !defined(ALPAKA_OS_IOS)
38
# if defined(__APPLE__)
39
# define ALPAKA_OS_IOS 1
40
# else
41
# define ALPAKA_OS_IOS 0
42
# endif
43
#endif
44
45
// Cygwin
46
#if !defined(ALPAKA_OS_CYGWIN)
47
# if defined(__CYGWIN__)
48
# define ALPAKA_OS_CYGWIN 1
49
# else
50
# define ALPAKA_OS_CYGWIN 0
51
# endif
52
#endif
53
54
// ### architectures
55
56
// X86
57
#if !defined(ALPAKA_ARCH_X86)
58
# if defined(__x86_64__) || defined(_M_X64)
59
# define ALPAKA_ARCH_X86 1
60
# else
61
# define ALPAKA_ARCH_X86 0
62
# endif
63
#endif
64
65
// RISCV
66
#if !defined(ALPAKA_ARCH_RISCV)
67
# if defined(__riscv)
68
# define ALPAKA_ARCH_RISCV 1
69
# else
70
# define ALPAKA_ARCH_RISCV 0
71
# endif
72
#endif
73
74
// ARM
75
#if !defined(ALPAKA_ARCH_ARM)
76
# if defined(__ARM_ARCH) || defined(__arm__) || defined(__arm64)
77
# define ALPAKA_ARCH_ARM 1
78
# else
79
# define ALPAKA_ARCH_ARM 0
80
# endif
81
#endif
82
83
// NVIDIA device compile
84
#if !defined(ALPAKA_ARCH_PTX)
85
# if defined(__CUDA_ARCH__)
86
# define ALPAKA_ARCH_PTX ALPAKA_VRP_TO_VERSION(__CUDA_ARCH__)
87
# else
88
# define ALPAKA_ARCH_PTX ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
89
# endif
90
#endif
91
92
/** HIP device compile
93
*
94
* The version on the host side will always be ALPAKA_VERSION_NUMBER_NOT_AVAILABLE.
95
* On the device side unknown version will be set to ALPAKA_VERSION_NUMBER_NOT_AVAILABLE.
96
*
97
* Rules:
98
* - the last two digits will be handled as HEX values and support 0-9 and a-f
99
* - gfx9xy (numeric): 9xy -> ALPAKA_VERSION_NUMBER(9,x,y)
100
* - gfx10xy / gfx11xy: stxy -> ALPAKA_VERSION_NUMBER(st,x,y)
101
* - Suffix: a == 10, b == 11, c == 12
102
* - gfx90a -> ALPAKA_VERSION_NUMBER(9,0,10)
103
* - gfx90c -> ALPAKA_VERSION_NUMBER(9,0,12)
104
*/
105
#if !defined(ALPAKA_ARCH_AMD)
106
# if defined(__HIP__) && defined(__HIP_DEVICE_COMPILE__) && __HIP_DEVICE_COMPILE__ == 1
107
# define ALPAKA_ARCH_AMD ALPAKA_AMDGPU_ARCH
108
# else
109
# define ALPAKA_ARCH_AMD ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
110
# endif
111
#endif
112
113
/** HSA device compile
114
*
115
* This version is equal to ALPAKA_ARCH_AMD and is only carried for backwards compatibility to older ALPAKA versions.
116
*/
117
#define ALPAKA_ARCH_HSA ALPAKA_ARCH_AMD
118
119
// ######## compiler ########
120
121
// HIP compiler detection
122
#if !defined(ALPAKA_COMP_HIP)
123
# if defined(__HIP__)
// Defined by hip-clang and vanilla clang in HIP mode.
124
# include <hip/hip_version.h>
125
// HIP doesn't give us a patch level for the last entry, just a gitdate
126
# define ALPAKA_COMP_HIP ALPAKA_VERSION_NUMBER(HIP_VERSION_MAJOR, HIP_VERSION_MINOR, 0)
127
# else
128
# define ALPAKA_COMP_HIP ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
129
# endif
130
#endif
131
132
// nvcc compiler
133
#if defined(__NVCC__)
134
# define ALPAKA_COMP_NVCC ALPAKA_VERSION_NUMBER(__CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, __CUDACC_VER_BUILD__)
135
#else
136
# define ALPAKA_COMP_NVCC ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
137
#endif
138
139
// clang compiler
140
#if defined(__clang__)
141
# define ALPAKA_COMP_CLANG ALPAKA_VERSION_NUMBER(__clang_major__, __clang_minor__, __clang_patchlevel__)
142
#else
143
# define ALPAKA_COMP_CLANG ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
144
#endif
145
146
// MSVC compiler
147
#if defined(_MSC_VER)
148
# define ALPAKA_COMP_MSVC \
149
ALPAKA_VERSION_NUMBER((_MSC_FULL_VER) % 10'000'000, ((_MSC_FULL_VER) / 100000) % 100, (_MSC_FULL_VER) % 100000)
150
#else
151
# define ALPAKA_COMP_MSVC ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
152
#endif
153
154
// gnu compiler (excluding compilers which emulates gnu compiler like clang)
155
#if defined(__GNUC__) && !defined(__clang__)
156
# if defined(__GNUC_PATCHLEVEL__)
157
# define ALPAKA_COMP_GNUC ALPAKA_VERSION_NUMBER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
158
# else
159
# define ALPAKA_COMP_GNUC ALPAKA_VERSION_NUMBER(__GNUC__, __GNUC_MINOR__, 0)
160
# endif
161
#else
162
# define ALPAKA_COMP_GNUC ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
163
#endif
164
165
// IBM compiler
166
// only clang based is supported
167
#if defined(__ibmxl__)
168
# define ALPAKA_COMP_IBM ALPAKA_VERSION_NUMBER(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
169
#else
170
# define ALPAKA_COMP_IBM ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
171
#endif
172
173
// clang CUDA compiler detection
174
// Currently __CUDA__ is only defined by clang when compiling CUDA code.
175
#if defined(__clang__) && defined(__CUDA__)
176
# define ALPAKA_COMP_CLANG_CUDA ALPAKA_VERSION_NUMBER(__clang_major__, __clang_minor__, __clang_patchlevel__)
177
#else
178
# define ALPAKA_COMP_CLANG_CUDA ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
179
#endif
180
181
// PGI and NV HPC SDK compiler detection
182
#if defined(__PGI)
183
# define ALPAKA_COMP_PGI ALPAKA_VERSION_NUMBER(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
184
#else
185
# define ALPAKA_COMP_PGI ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
186
#endif
187
188
// Intel LLVM compiler detection
189
#if !defined(ALPAKA_COMP_ICPX)
190
# if defined(SYCL_LANGUAGE_VERSION) && defined(__INTEL_LLVM_COMPILER)
191
// The version string for icpx 2023.1.0 is 20230100. In Boost.Predef this becomes (53,1,0).
192
# define ALPAKA_COMP_ICPX ALPAKA_YYYYMMDD_TO_VERSION(__INTEL_LLVM_COMPILER)
193
# else
194
# define ALPAKA_COMP_ICPX ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
195
# endif
196
#endif
197
198
// ######## C++ language ########
199
200
//---------------------------------------HIP-----------------------------------
201
// __HIP__ is defined by both hip-clang and vanilla clang in HIP mode.
202
// https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_porting_guide.md#compiler-defines-summary
203
#if !defined(ALPAKA_LANG_HIP)
204
# if defined(__HIP__)
205
# include <hip/hip_version.h>
206
// HIP doesn't give us a patch level for the last entry, just a gitdate
207
# define ALPAKA_LANG_HIP ALPAKA_VERSION_NUMBER(HIP_VERSION_MAJOR, HIP_VERSION_MINOR, 0)
208
# else
209
# define ALPAKA_LANG_HIP ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
210
# endif
211
#endif
212
213
// CUDA
214
#if !defined(ALPAKA_LANG_CUDA)
215
# if defined(__CUDACC__) || defined(__CUDA__)
216
# include <cuda.h>
217
// CUDA doesn't give us a patch level for the last entry, just zero.
218
# define ALPAKA_LANG_CUDA ALPAKA_VVRRP_TO_VERSION(CUDART_VERSION)
219
# else
220
# define ALPAKA_LANG_CUDA ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
221
# endif
222
#endif
223
224
// Intel OneAPI Sycl GPU
225
#if !defined(ALPAKA_LANG_SYCL)
226
# if defined(SYCL_LANGUAGE_VERSION)
227
# define ALPAKA_LANG_SYCL ALPAKA_YYYYMMDD_TO_VERSION(SYCL_LANGUAGE_VERSION)
228
# else
229
# define ALPAKA_LANG_SYCL ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
230
# endif
231
# if(ALPAKA_COMP_ICPX)
232
// ONE API must be detected via the ICPX compiler see
233
// https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-2/use-predefined-macros-to-specify-intel-compilers.html
234
# define ALPAKA_LANG_ONEAPI ALPAKA_COMP_ICPX
235
# endif
236
#endif
237
238
// OpenMP
239
#if !defined(ALPAKA_OMP)
240
# if defined(_OPENMP)
241
# include <omp.h>
242
# endif
243
# if defined(_OPENMP)
244
# define ALPAKA_OMP ALPAKA_YYYYMM_TO_VERSION(_OPENMP)
245
# else
246
# define ALPAKA_OMP ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
247
# endif
248
#endif
PP.hpp
include
alpaka
core
Config.hpp
Generated on Tue Nov 25 2025 09:20:20 for alpaka by
1.9.8