1/*
2Copyright Benjamin Worpitz 2018
3Distributed under the Boost Software License, Version 1.0.
4(See accompanying file LICENSE_1_0.txt or copy at
5http://www.boost.org/LICENSE_1_0.txt)
6*/
7
8#ifndef BOOST_PREDEF_COMPILER_NVCC_H
9#define BOOST_PREDEF_COMPILER_NVCC_H
10
11#include <boost/predef/version_number.h>
12#include <boost/predef/make.h>
13
14/*`
15[heading `BOOST_COMP_NVCC`]
16
17[@https://en.wikipedia.org/wiki/NVIDIA_CUDA_Compiler NVCC] compiler.
18Version number available as major, minor, and patch beginning with version 7.5.
19
20[table
21 [[__predef_symbol__] [__predef_version__]]
22
23 [[`__NVCC__`] [__predef_detection__]]
24
25 [[`__CUDACC_VER_MAJOR__`, `__CUDACC_VER_MINOR__`, `__CUDACC_VER_BUILD__`] [V.R.P]]
26 ]
27 */
28
29#define BOOST_COMP_NVCC BOOST_VERSION_NUMBER_NOT_AVAILABLE
30
31#if defined(__NVCC__)
32# if !defined(__CUDACC_VER_MAJOR__) || !defined(__CUDACC_VER_MINOR__) || !defined(__CUDACC_VER_BUILD__)
33# define BOOST_COMP_NVCC_DETECTION BOOST_VERSION_NUMBER_AVAILABLE
34# else
35# define BOOST_COMP_NVCC_DETECTION BOOST_VERSION_NUMBER(__CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, __CUDACC_VER_BUILD__)
36# endif
37#endif
38
39#ifdef BOOST_COMP_NVCC_DETECTION
40/*
41Always define BOOST_COMP_NVCC instead of BOOST_COMP_NVCC_EMULATED
42The nvcc compilation process is somewhat special as can be read here:
43https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#cuda-compilation-trajectory
44The nvcc compiler precompiles the input two times. Once for the device code
45being compiled by the cicc device compiler and once for the host code
46compiled by the real host compiler. NVCC uses gcc/clang/msvc/...
47depending on the host compiler being set on the command line.
48
49Predef (as a preprocessor only lib) detects the one doing the preprocessing
50as compiler and expects it to be the one doing the real compilation.
51This is not true for NVCC which is only doing the preprocessing and which
52is using another compiler for parts of its work. So for NVCC it should be
53allowed to set BOOST_COMP_NVCC additionally to the already detected host
54compiler because both is true: It is gcc/clang/... compiling the code, but it
55is also NVCC doing the preprocessing and adding some other quirks you may
56want to detect.
57
58This behavior is similar to what boost config is doing in `select_compiler_config.hpp`.
59There the NVCC detection is not handled as a real compiler (part of the
60#if-#elif) but as additional option before the real compiler.
61*/
62# undef BOOST_COMP_NVCC
63# define BOOST_COMP_NVCC BOOST_COMP_NVCC_DETECTION
64# define BOOST_COMP_NVCC_AVAILABLE
65# include <boost/predef/detail/comp_detected.h>
66#endif
67
68#define BOOST_COMP_NVCC_NAME "NVCC"
69
70#endif
71
72#include <boost/predef/detail/test.h>
73BOOST_PREDEF_DECLARE_TEST(BOOST_COMP_NVCC,BOOST_COMP_NVCC_NAME)
74