alpaka
Abstraction Library for Parallel Kernel Acceleration
BoostPredef.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 <boost/predef.h>
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 //---------------------------------------HIP-----------------------------------
16 // __HIP__ is defined by both hip-clang and vanilla clang in HIP mode.
17 // https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_porting_guide.md#compiler-defines-summary
18 #if !defined(BOOST_LANG_HIP)
19 # if defined(__HIP__)
20 /* BOOST_LANG_CUDA is enabled when either __CUDACC__ (nvcc) or __CUDA__ (clang) are defined. This occurs when
21  nvcc / clang encounter a CUDA source file. Since there are no HIP source files we treat every source file
22  as HIP when we are using a HIP-capable compiler. */
23 # include <hip/hip_version.h>
24 // HIP doesn't give us a patch level for the last entry, just a gitdate
25 # define BOOST_LANG_HIP BOOST_VERSION_NUMBER(HIP_VERSION_MAJOR, HIP_VERSION_MINOR, 0)
26 # else
27 # define BOOST_LANG_HIP BOOST_VERSION_NUMBER_NOT_AVAILABLE
28 # endif
29 #endif
30 
31 // HSA device architecture detection (HSA generated via HIP(clang))
32 #if !defined(BOOST_ARCH_HSA)
33 # if defined(__HIP_DEVICE_COMPILE__) && __HIP_DEVICE_COMPILE__ == 1 && defined(__HIP__)
34 // __HIP_DEVICE_COMPILE__ does not represent feature capability of target device like CUDA_ARCH.
35 // For feature detection there are special macros, see ROCm's HIP porting guide.
36 # define BOOST_ARCH_HSA BOOST_VERSION_NUMBER_AVAILABLE
37 # else
38 # define BOOST_ARCH_HSA BOOST_VERSION_NUMBER_NOT_AVAILABLE
39 # endif
40 #endif
41 
42 // HIP compiler detection
43 #if !defined(BOOST_COMP_HIP)
44 # if defined(__HIP__) // Defined by hip-clang and vanilla clang in HIP mode.
45 # include <hip/hip_version.h>
46 // HIP doesn't give us a patch level for the last entry, just a gitdate
47 # define BOOST_COMP_HIP BOOST_VERSION_NUMBER(HIP_VERSION_MAJOR, HIP_VERSION_MINOR, 0)
48 # else
49 # define BOOST_COMP_HIP BOOST_VERSION_NUMBER_NOT_AVAILABLE
50 # endif
51 #endif
52 
53 // clang CUDA compiler detection
54 // Currently __CUDA__ is only defined by clang when compiling CUDA code.
55 #if defined(__clang__) && defined(__CUDA__)
56 # define BOOST_COMP_CLANG_CUDA BOOST_COMP_CLANG
57 #else
58 # define BOOST_COMP_CLANG_CUDA BOOST_VERSION_NUMBER_NOT_AVAILABLE
59 #endif
60 
61 // PGI and NV HPC SDK compiler detection
62 // As of Boost 1.74, Boost.Predef's compiler detection is a bit weird. Recent PGI compilers will be identified as
63 // BOOST_COMP_PGI_EMULATED. Boost.Predef has lackluster front-end support and mistakes the EDG front-end
64 // for an actual compiler.
65 // TODO: Whenever you look at this code please check whether https://github.com/boostorg/predef/issues/28 and
66 // https://github.com/boostorg/predef/issues/51 have been resolved.
67 // BOOST_COMP_PGI_EMULATED is defined by boost instead of BOOST_COMP_PGI
68 #if defined(BOOST_COMP_PGI) && defined(BOOST_COMP_PGI_EMULATED)
69 # undef BOOST_COMP_PGI
70 # define BOOST_COMP_PGI BOOST_COMP_PGI_EMULATED
71 #endif
72 
73 // Intel LLVM compiler detection
74 #if !defined(BOOST_COMP_ICPX)
75 # if defined(SYCL_LANGUAGE_VERSION) && defined(__INTEL_LLVM_COMPILER)
76 // The version string for icpx 2023.1.0 is 20230100. In Boost.Predef this becomes (53,1,0).
77 # define BOOST_COMP_ICPX BOOST_PREDEF_MAKE_YYYYMMDD(__INTEL_LLVM_COMPILER)
78 # endif
79 #endif