summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTin Huynh <ahuynh@nvidia.com>2020-08-25 19:54:13 -0700
committerBrad King <brad.king@kitware.com>2021-01-27 09:53:02 -0500
commit83ea49818f4d7a031d972e26e0cb1d561ed20d76 (patch)
tree11544d67f57130520afd5d019d71211013a286ec
parent9b96fbc358aba8110ba09d3ad2262223ec0f0167 (diff)
downloadcmake-83ea49818f4d7a031d972e26e0cb1d561ed20d76.tar.gz
NVHPC: Add support for NVIDIA HPC SDK compilers based on PGI
Identify the compilers as `NVHPC` to distinguish it from the older PGI compilers from which they evolved, and from other `NVIDIA` compilers. Fixes: #20887
-rw-r--r--Help/release/dev/nvhpc-compiler.rst4
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_ID.rst1
-rw-r--r--Modules/CMakeCompilerIdDetection.cmake1
-rw-r--r--Modules/CMakeFortranCompilerId.F.in17
-rw-r--r--Modules/Compiler/NVHPC-C.cmake3
-rw-r--r--Modules/Compiler/NVHPC-CXX.cmake3
-rw-r--r--Modules/Compiler/NVHPC-DetermineCompiler.cmake9
-rw-r--r--Modules/Compiler/NVHPC-Fortran.cmake3
-rw-r--r--Modules/Compiler/NVHPC.cmake15
-rw-r--r--Modules/Platform/Linux-NVHPC-C.cmake2
-rw-r--r--Modules/Platform/Linux-NVHPC-CXX.cmake2
-rw-r--r--Modules/Platform/Linux-NVHPC-Fortran.cmake2
-rw-r--r--Modules/Platform/Linux-NVHPC.cmake15
13 files changed, 77 insertions, 0 deletions
diff --git a/Help/release/dev/nvhpc-compiler.rst b/Help/release/dev/nvhpc-compiler.rst
new file mode 100644
index 0000000000..f1f60aeb00
--- /dev/null
+++ b/Help/release/dev/nvhpc-compiler.rst
@@ -0,0 +1,4 @@
+nvhpc-compiler
+--------------
+
+* The NVIDIA HPC SDK compilers are now supported with compiler id ``NVHPC``.
diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
index 8eb4fb612c..127061073a 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
@@ -26,6 +26,7 @@ include:
IAR = IAR Systems (iar.com)
Intel = Intel Compiler (intel.com)
MSVC = Microsoft Visual Studio (microsoft.com)
+ NVHPC = NVIDIA HPC SDK Compiler (nvidia.com)
NVIDIA = NVIDIA CUDA Compiler (nvidia.com)
OpenWatcom = Open Watcom (openwatcom.org)
PGI = The Portland Group (pgroup.com)
diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake
index a0f0dfacb6..d64804e9d1 100644
--- a/Modules/CMakeCompilerIdDetection.cmake
+++ b/Modules/CMakeCompilerIdDetection.cmake
@@ -61,6 +61,7 @@ function(compiler_id_detection outvar lang)
XLClang
XL
VisualAge
+ NVHPC
PGI
Cray
TI
diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in
index 7e8828b770..6ef798f20a 100644
--- a/Modules/CMakeFortranCompilerId.F.in
+++ b/Modules/CMakeFortranCompilerId.F.in
@@ -82,6 +82,23 @@
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
# endif
+#elif defined(__NVCOMPILER) || defined(__NVCOMPILER_LLVM__)
+ PRINT *, 'INFO:compiler[NVHPC]'
+# if defined(__NVCOMPILER_MAJOR__)
+# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__)
+# else
+# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
+# endif
+# if defined(__NVCOMPILER_MINOR__)
+# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__)
+# else
+# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
+# endif
+# if defined(__NVCOMPILER_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__)
+# elif defined(__PGIC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
+# endif
#elif defined(__PGI)
PRINT *, 'INFO:compiler[PGI]'
# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
diff --git a/Modules/Compiler/NVHPC-C.cmake b/Modules/Compiler/NVHPC-C.cmake
new file mode 100644
index 0000000000..d16c72b76e
--- /dev/null
+++ b/Modules/Compiler/NVHPC-C.cmake
@@ -0,0 +1,3 @@
+include(Compiler/PGI-C)
+include(Compiler/NVHPC)
+__compiler_nvhpc(C)
diff --git a/Modules/Compiler/NVHPC-CXX.cmake b/Modules/Compiler/NVHPC-CXX.cmake
new file mode 100644
index 0000000000..18ace8bfe6
--- /dev/null
+++ b/Modules/Compiler/NVHPC-CXX.cmake
@@ -0,0 +1,3 @@
+include(Compiler/PGI-CXX)
+include(Compiler/NVHPC)
+__compiler_nvhpc(CXX)
diff --git a/Modules/Compiler/NVHPC-DetermineCompiler.cmake b/Modules/Compiler/NVHPC-DetermineCompiler.cmake
new file mode 100644
index 0000000000..45b69e18eb
--- /dev/null
+++ b/Modules/Compiler/NVHPC-DetermineCompiler.cmake
@@ -0,0 +1,9 @@
+
+set(_compiler_id_pp_test "defined(__NVCOMPILER)")
+
+set(_compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__NVCOMPILER_MAJOR__)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__NVCOMPILER_MINOR__)
+# if defined(__NVCOMPILER_PATCHLEVEL__)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__NVCOMPILER_PATCHLEVEL__)
+# endif")
diff --git a/Modules/Compiler/NVHPC-Fortran.cmake b/Modules/Compiler/NVHPC-Fortran.cmake
new file mode 100644
index 0000000000..59755b3a71
--- /dev/null
+++ b/Modules/Compiler/NVHPC-Fortran.cmake
@@ -0,0 +1,3 @@
+include(Compiler/PGI-Fortran)
+include(Compiler/NVHPC)
+__compiler_nvhpc(Fortran)
diff --git a/Modules/Compiler/NVHPC.cmake b/Modules/Compiler/NVHPC.cmake
new file mode 100644
index 0000000000..70486705c1
--- /dev/null
+++ b/Modules/Compiler/NVHPC.cmake
@@ -0,0 +1,15 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# This module is shared by multiple languages; use include blocker.
+if(__COMPILER_NVHPC)
+ return()
+endif()
+set(__COMPILER_NVHPC 1)
+
+include(Compiler/PGI)
+
+macro(__compiler_nvhpc lang)
+ # Logic specific to NVHPC.
+endmacro()
diff --git a/Modules/Platform/Linux-NVHPC-C.cmake b/Modules/Platform/Linux-NVHPC-C.cmake
new file mode 100644
index 0000000000..4aab327110
--- /dev/null
+++ b/Modules/Platform/Linux-NVHPC-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/Linux-NVHPC)
+__linux_compiler_nvhpc(C)
diff --git a/Modules/Platform/Linux-NVHPC-CXX.cmake b/Modules/Platform/Linux-NVHPC-CXX.cmake
new file mode 100644
index 0000000000..57380eb4e1
--- /dev/null
+++ b/Modules/Platform/Linux-NVHPC-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/Linux-NVHPC)
+__linux_compiler_nvhpc(CXX)
diff --git a/Modules/Platform/Linux-NVHPC-Fortran.cmake b/Modules/Platform/Linux-NVHPC-Fortran.cmake
new file mode 100644
index 0000000000..c68430c246
--- /dev/null
+++ b/Modules/Platform/Linux-NVHPC-Fortran.cmake
@@ -0,0 +1,2 @@
+include(Platform/Linux-NVHPC)
+__linux_compiler_nvhpc(Fortran)
diff --git a/Modules/Platform/Linux-NVHPC.cmake b/Modules/Platform/Linux-NVHPC.cmake
new file mode 100644
index 0000000000..aad17f1e9f
--- /dev/null
+++ b/Modules/Platform/Linux-NVHPC.cmake
@@ -0,0 +1,15 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# This module is shared by multiple languages; use include blocker.
+if(__LINUX_COMPILER_NVIDIA)
+ return()
+endif()
+set(__LINUX_COMPILER_NVIDIA 1)
+
+include(Platform/Linux-PGI)
+
+macro(__linux_compiler_nvhpc lang)
+ __linux_compiler_pgi(${lang})
+endmacro()