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
// ALPAKA_ARCH_PTX is a misnomer as it holds the compute capability version (the virtual GPU architecture) and not the
85
// PTX ISA version. This misnomer exists in CUDA as well. https://github.com/NVIDIA/cccl/issues/4081
86
#if !defined(ALPAKA_ARCH_PTX)
87
# if defined(__CUDA_ARCH__)
88
# define ALPAKA_ARCH_PTX ALPAKA_VRP_TO_VERSION(__CUDA_ARCH__)
89
# else
90
# define ALPAKA_ARCH_PTX ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
91
# endif
92
#endif
93
94
/** HIP device compile
95
*
96
* The version on the host side will always be ALPAKA_VERSION_NUMBER_NOT_AVAILABLE.
97
* On the device side unknown version will be set to ALPAKA_VERSION_NUMBER_NOT_AVAILABLE.
98
*
99
* Rules:
100
* - the last two digits will be handled as HEX values and support 0-9 and a-f
101
* - gfx9xy (numeric): 9xy -> ALPAKA_VERSION_NUMBER(9,x,y)
102
* - gfx10xy / gfx11xy: stxy -> ALPAKA_VERSION_NUMBER(st,x,y)
103
* - Suffix: a == 10, b == 11, c == 12
104
* - gfx90a -> ALPAKA_VERSION_NUMBER(9,0,10)
105
* - gfx90c -> ALPAKA_VERSION_NUMBER(9,0,12)
106
*/
107
#if !defined(ALPAKA_ARCH_AMD)
108
# if defined(__HIP__) && defined(__HIP_DEVICE_COMPILE__) && __HIP_DEVICE_COMPILE__ == 1
109
# include "
alpaka/core/HipConfig.hpp
"
110
# define ALPAKA_ARCH_AMD ALPAKA_AMDGPU_ARCH
111
# else
112
# define ALPAKA_ARCH_AMD ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
113
# endif
114
#endif
115
116
/** HSA device compile
117
*
118
* This version is equal to ALPAKA_ARCH_AMD and is only carried for backwards compatibility to older ALPAKA versions.
119
*/
120
#define ALPAKA_ARCH_HSA ALPAKA_ARCH_AMD
121
122
// ######## compiler ########
123
124
// HIP compiler detection
125
#if !defined(ALPAKA_COMP_HIP)
126
# if defined(__HIP__)
// Defined by hip-clang and vanilla clang in HIP mode.
127
# include <hip/hip_version.h>
128
// HIP doesn't give us a patch level for the last entry, just a gitdate
129
# define ALPAKA_COMP_HIP ALPAKA_VERSION_NUMBER(HIP_VERSION_MAJOR, HIP_VERSION_MINOR, 0)
130
# else
131
# define ALPAKA_COMP_HIP ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
132
# endif
133
#endif
134
135
// nvcc compiler
136
#if defined(__NVCC__)
137
# define ALPAKA_COMP_NVCC ALPAKA_VERSION_NUMBER(__CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, __CUDACC_VER_BUILD__)
138
#else
139
# define ALPAKA_COMP_NVCC ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
140
#endif
141
142
// clang compiler
143
#if defined(__clang__)
144
# define ALPAKA_COMP_CLANG ALPAKA_VERSION_NUMBER(__clang_major__, __clang_minor__, __clang_patchlevel__)
145
#else
146
# define ALPAKA_COMP_CLANG ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
147
#endif
148
149
// MSVC compiler
150
#if defined(_MSC_VER)
151
# define ALPAKA_COMP_MSVC \
152
ALPAKA_VERSION_NUMBER((_MSC_FULL_VER) % 10'000'000, ((_MSC_FULL_VER) / 100000) % 100, (_MSC_FULL_VER) % 100000)
153
#else
154
# define ALPAKA_COMP_MSVC ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
155
#endif
156
157
// gnu compiler (excluding compilers which emulates gnu compiler like clang)
158
#if defined(__GNUC__) && !defined(__clang__)
159
# if defined(__GNUC_PATCHLEVEL__)
160
# define ALPAKA_COMP_GNUC ALPAKA_VERSION_NUMBER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
161
# else
162
# define ALPAKA_COMP_GNUC ALPAKA_VERSION_NUMBER(__GNUC__, __GNUC_MINOR__, 0)
163
# endif
164
#else
165
# define ALPAKA_COMP_GNUC ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
166
#endif
167
168
// IBM compiler
169
// only clang based is supported
170
#if defined(__ibmxl__)
171
# define ALPAKA_COMP_IBM ALPAKA_VERSION_NUMBER(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
172
#else
173
# define ALPAKA_COMP_IBM ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
174
#endif
175
176
// clang CUDA compiler detection
177
// Currently __CUDA__ is only defined by clang when compiling CUDA code.
178
#if defined(__clang__) && defined(__CUDA__)
179
# define ALPAKA_COMP_CLANG_CUDA ALPAKA_VERSION_NUMBER(__clang_major__, __clang_minor__, __clang_patchlevel__)
180
#else
181
# define ALPAKA_COMP_CLANG_CUDA ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
182
#endif
183
184
// PGI and NV HPC SDK compiler detection
185
#if defined(__PGI)
186
# define ALPAKA_COMP_PGI ALPAKA_VERSION_NUMBER(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
187
#else
188
# define ALPAKA_COMP_PGI ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
189
#endif
190
191
// Intel LLVM compiler detection
192
#if !defined(ALPAKA_COMP_ICPX)
193
# if defined(SYCL_LANGUAGE_VERSION) && defined(__INTEL_LLVM_COMPILER)
194
// The version string for icpx 2023.1.0 is 20230100. In Boost.Predef this becomes (53,1,0).
195
# define ALPAKA_COMP_ICPX ALPAKA_YYYYMMDD_TO_VERSION(__INTEL_LLVM_COMPILER)
196
# else
197
# define ALPAKA_COMP_ICPX ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
198
# endif
199
#endif
200
201
// ######## C++ language ########
202
203
//---------------------------------------HIP-----------------------------------
204
// __HIP__ is defined by both hip-clang and vanilla clang in HIP mode.
205
// https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_porting_guide.md#compiler-defines-summary
206
#if !defined(ALPAKA_LANG_HIP)
207
# if defined(__HIP__)
208
# include <hip/hip_version.h>
209
// HIP doesn't give us a patch level for the last entry, just a gitdate
210
# define ALPAKA_LANG_HIP ALPAKA_VERSION_NUMBER(HIP_VERSION_MAJOR, HIP_VERSION_MINOR, 0)
211
# else
212
# define ALPAKA_LANG_HIP ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
213
# endif
214
#endif
215
216
// CUDA
217
#if !defined(ALPAKA_LANG_CUDA)
218
# if defined(__CUDACC__) || defined(__CUDA__)
219
# include <cuda.h>
220
// CUDA doesn't give us a patch level for the last entry, just zero.
221
# define ALPAKA_LANG_CUDA ALPAKA_VVRRP_TO_VERSION(CUDART_VERSION)
222
# else
223
# define ALPAKA_LANG_CUDA ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
224
# endif
225
#endif
226
227
// Intel OneAPI Sycl GPU
228
#if !defined(ALPAKA_LANG_SYCL)
229
# if defined(SYCL_LANGUAGE_VERSION)
230
# define ALPAKA_LANG_SYCL ALPAKA_YYYYMMDD_TO_VERSION(SYCL_LANGUAGE_VERSION)
231
# else
232
# define ALPAKA_LANG_SYCL ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
233
# endif
234
# if(ALPAKA_COMP_ICPX)
235
// ONE API must be detected via the ICPX compiler see
236
// 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
237
# define ALPAKA_LANG_ONEAPI ALPAKA_COMP_ICPX
238
# endif
239
#endif
240
241
// OpenMP
242
#if !defined(ALPAKA_OMP)
243
# if defined(_OPENMP)
244
# include <omp.h>
245
# endif
246
# if defined(_OPENMP)
247
# define ALPAKA_OMP ALPAKA_YYYYMM_TO_VERSION(_OPENMP)
248
# else
249
# define ALPAKA_OMP ALPAKA_VERSION_NUMBER_NOT_AVAILABLE
250
# endif
251
#endif
HipConfig.hpp
PP.hpp
include
alpaka
core
Config.hpp
Generated on Tue Sep 22 2026 12:51:57 for alpaka by
1.12.0