检测 Nvidia 的 NVC++(不是 NVCC)编译器和编译器版本

Detect Nvidia's NVC++ (not NVCC) compiler and compiler version

我正在使用 Nvidia 的 HPC 编译器 nvc++

有没有办法检测程序是用这个特定的编译器和版本编译的?

我在手册中找不到任何内容 https://docs.nvidia.com/hpc-sdk/index.html

另一个 Nvidia 相关的编译器 nvcc 有这些宏

__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. 

但我找不到 nvc++ 的等效项。 strings 命令没有显示任何合适的宏名称候选者。

$ strings /opt/nvidia/hpc_sdk/Linux_x86_64/22.1/compilers/bin/nvc++ | grep D
_ZNSt13basic_filebufIcSt11char_traitsIcEED1Ev
_ZNSt8ios_base4InitD1Ev
_ZNSt6localeD1Ev
_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
_ZNSt8ios_baseD2Ev
_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
_ZNSt12__basic_fileIcED1Ev
D$(%
Dt
D$(D
AWAVAUATD
D$ -
D5rs"
D5gc"
D5P`"
D$ I
D[=11=]~
D[=11=]I
D$PE
D$ L
D$@L
D[=11=]D
DH
D$,L
D$TH
D$TH
D[=11=]H
D$,L
D$XH
D$XL
ED$\
L$$D
D$,D
=JD"
D$(L
DH
L$(D
L$(D
DH
D;%o5"
D9l$
D[=11=]H
DH
D[=11=]H+E
DH+E
D$H%
$ D
D$.E
d$(D
D$HH
D$ Hc
$ D
D$H%
D$H%
D$H%
$ D
D$/H
$ D
D$H%
D$HH
D$@L
)D$P
D$@L
)D$P
D$@L
)D$P
D9t$
|$ D
t\<:tX<,tTD;t$(
D$,A
D$,H
D$DH
T$DD
D$DH
L$DE
D$ H
D$DH
D$(L
D$DH
D$DH
D$<L
D$DH
D$@-H
D$@-A
L$DH
|$DH
D$<1
D$DH
D$DH
D
L$dD
D$hA
HcD$h
D$xA
D$p1
D$pH
HcD$hH
HcD$hL
HcD$hH
HcD$hH
D$pL
t(D;
L$pD
HcD$h
HcD$hL
HcD$hL
HcD$h1
|$lD
|$xD
D$|H
D$pH
D$`H
D$hum
L$pD
D$ H
D$|H
D$ E
ATUD
=fD!
=   D!
$HcD$
<"tD
gfffD
5cAMD
D$  H
D$  H
D$  H
D$  H
D$  H
D$  H
D$  H
D$  H
D$/H
D$>f
D%
ADDARGS
PRINTRESTARTCMD
DNOERROR
DRYRUN
HIDDEN
Don't include default command line options
subprocess TERMINATED by signal %d
Killing child PID %d
WAITID
%s TERMINATED by signal %d
RUNCMD
OVERRIDESUFFIX
Deferred Error Messages
Temp Directories
RC file %s line %d: error in %s statement at %s, expecting ID
DRIVERNAME
DRIVERCOMMAND
DRIVERDIR
DRIVERHOST
DRIVERLANG
CURDIR
Driver ran out of memory at include statement
TMPDIR
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+
cuDriverGetVersion
cuDeviceGetCount
cuDeviceGet
cuDeviceGetAttribute
Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.
NVIDIA Compilers and Tools
Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.
DisablePhase
DeferredError
DoRestart
RestartNewdriverDir
DeferRestart
RmDir
DoAssignment
DoAction
DoExecute
AddDefaultAttribute.isra.1
__FRAME_END__
__JCR_END__
__GNU_EH_FRAME_HDR
_DYNAMIC
FindDriverName
DriverDirOrig
PrintDeferredErrors
DefAction
DriverDirLink
_ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4
DriverLang
__TMC_END__
_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@@GLIBCXX_3.4
DriverDir
_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@@GLIBCXX_3.4
AddDriverName
_ZNSt8ios_baseD2Ev@@GLIBCXX_3.4
_ZNSt12__basic_fileIcED1Ev@@GLIBCXX_3.4
DriverNameLink
DeferredErrorList
_ZNSt13basic_filebufIcSt11char_traitsIcEED1Ev@@GLIBCXX_3.4
TempDirList
_ZNSt6localeD1Ev@@GLIBCXX_3.4
STDERR

在随机 third-party 图书馆中意外找到它们 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