Browse Source

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
Tin Huynh 5 years ago
parent
commit
83ea49818f

+ 4 - 0
Help/release/dev/nvhpc-compiler.rst

@@ -0,0 +1,4 @@
+nvhpc-compiler
+--------------
+
+* The NVIDIA HPC SDK compilers are now supported with compiler id ``NVHPC``.

+ 1 - 0
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)

+ 1 - 0
Modules/CMakeCompilerIdDetection.cmake

@@ -61,6 +61,7 @@ function(compiler_id_detection outvar lang)
       XLClang
       XL
       VisualAge
+      NVHPC
       PGI
       Cray
       TI

+ 17 - 0
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__)

+ 3 - 0
Modules/Compiler/NVHPC-C.cmake

@@ -0,0 +1,3 @@
+include(Compiler/PGI-C)
+include(Compiler/NVHPC)
+__compiler_nvhpc(C)

+ 3 - 0
Modules/Compiler/NVHPC-CXX.cmake

@@ -0,0 +1,3 @@
+include(Compiler/PGI-CXX)
+include(Compiler/NVHPC)
+__compiler_nvhpc(CXX)

+ 9 - 0
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")

+ 3 - 0
Modules/Compiler/NVHPC-Fortran.cmake

@@ -0,0 +1,3 @@
+include(Compiler/PGI-Fortran)
+include(Compiler/NVHPC)
+__compiler_nvhpc(Fortran)

+ 15 - 0
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()

+ 2 - 0
Modules/Platform/Linux-NVHPC-C.cmake

@@ -0,0 +1,2 @@
+include(Platform/Linux-NVHPC)
+__linux_compiler_nvhpc(C)

+ 2 - 0
Modules/Platform/Linux-NVHPC-CXX.cmake

@@ -0,0 +1,2 @@
+include(Platform/Linux-NVHPC)
+__linux_compiler_nvhpc(CXX)

+ 2 - 0
Modules/Platform/Linux-NVHPC-Fortran.cmake

@@ -0,0 +1,2 @@
+include(Platform/Linux-NVHPC)
+__linux_compiler_nvhpc(Fortran)

+ 15 - 0
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()