Reputation: 16270
I am using Nvidia's HPC compiler nvc++
.
Is there a way to detect that the program is being compile with this specific compiler and the version?
I couldn't find anything in the manual https://docs.nvidia.com/hpc-sdk/index.html.
Another Nvidia-related compiler nvcc
has these macros
__NVCC__
Defined when compiling C/C++/CUDA source files.
__CUDACC__
Defined when compiling CUDA source files.
__CUDACC_RDC__
Defined when compiling CUDA source files in relocatable device code mode (see NVCC Options for Separate Compilation).
__CUDACC_EWP__
Defined when compiling CUDA source files in extensible whole program mode (see Options for Specifying Behavior of Compiler/Linker).
__CUDACC_DEBUG__
Defined when compiling CUDA source files in the device-debug mode (see Options for Specifying Behavior of Compiler/Linker).
__CUDACC_RELAXED_CONSTEXPR__
Defined when the --expt-relaxed-constexpr flag is specified on the command line. Refer to CUDA C++ Programming Guide for more details.
__CUDACC_EXTENDED_LAMBDA__
Defined when the --expt-extended-lambda or --extended-lambda flag is specified on the command line. Refer to CUDA C++ Programming Guide for more details.
__CUDACC_VER_MAJOR__
Defined with the major version number of nvcc.
__CUDACC_VER_MINOR__
Defined with the minor version number of nvcc.
__CUDACC_VER_BUILD__
Defined with the build version number of nvcc.
__NVCC_DIAG_PRAGMA_SUPPORT__
Defined when the CUDA frontend compiler supports diagnostic control with the nv_diag_suppress, nv_diag_error, nv_diag_warning, nv_diag_default, nv_diag_once, nv_diagnostic pragmas.
but I couldn't find the equivalent for nvc++
.
The strings
command didn't show any good candidate for macro names.
$ strings /opt/nvidia/hpc_sdk/Linux_x86_64/22.1/compilers/bin/nvc++ | grep D
Upvotes: 6
Views: 2500
Reputation: 16270
__NVCOMPILER
__NVCOMPILER_MAJOR__
__NVCOMPILER_MINOR__
Found them accidentally in a random third-party library https://github.com/fmtlib/fmt/blob/master/include/fmt/core.h
#ifdef __NVCOMPILER
# define FMT_NVCOMPILER_VERSION \
(__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__)
#else
# define FMT_NVCOMPILER_VERSION 0
#endif
Upvotes: 8