Browse Source

Merge topic 'nvhpc-compiler'

4de28ba4e6 Tests: Update tests for NVHPC compiler
90502d76b7 FindOpenMP: Add support for NVHPC compiler
76dee5831b FindOpenACC: Add support for NVHPC compiler
ff7bab83c2 GenerateExportHeader: Add support for NVHPC compiler
83ea49818f NVHPC: Add support for NVIDIA HPC SDK compilers based on PGI

Acked-by: Kitware Robot <[email protected]>
Merge-request: !5475
Brad King 5 years ago
parent
commit
b369aee24d

+ 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)
   IAR = IAR Systems (iar.com)
   Intel = Intel Compiler (intel.com)
   Intel = Intel Compiler (intel.com)
   MSVC = Microsoft Visual Studio (microsoft.com)
   MSVC = Microsoft Visual Studio (microsoft.com)
+  NVHPC = NVIDIA HPC SDK Compiler (nvidia.com)
   NVIDIA = NVIDIA CUDA Compiler (nvidia.com)
   NVIDIA = NVIDIA CUDA Compiler (nvidia.com)
   OpenWatcom = Open Watcom (openwatcom.org)
   OpenWatcom = Open Watcom (openwatcom.org)
   PGI = The Portland Group (pgroup.com)
   PGI = The Portland Group (pgroup.com)

+ 1 - 0
Modules/CMakeCompilerIdDetection.cmake

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

+ 17 - 0
Modules/CMakeFortranCompilerId.F.in

@@ -82,6 +82,23 @@
 #  define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
 #  define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
 #  define COMPILER_VERSION_PATCH DEC(__IBMC__    % 10)
 #  define COMPILER_VERSION_PATCH DEC(__IBMC__    % 10)
 # endif
 # 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)
 #elif defined(__PGI)
         PRINT *, 'INFO:compiler[PGI]'
         PRINT *, 'INFO:compiler[PGI]'
 # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
 # 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()

+ 4 - 1
Modules/FindOpenACC.cmake

@@ -12,7 +12,7 @@ Detect OpenACC support by the compiler.
 This module can be used to detect OpenACC support in a compiler.
 This module can be used to detect OpenACC support in a compiler.
 If the compiler supports OpenACC, the flags required to compile with
 If the compiler supports OpenACC, the flags required to compile with
 OpenACC support are returned in variables for the different languages.
 OpenACC support are returned in variables for the different languages.
-Currently, only PGI, GNU and Cray compilers are supported.
+Currently, only NVHPC, PGI, GNU and Cray compilers are supported.
 
 
 Imported Targets
 Imported Targets
 ^^^^^^^^^^^^^^^^
 ^^^^^^^^^^^^^^^^
@@ -139,6 +139,7 @@ endfunction()
 
 
 
 
 function(_OPENACC_GET_FLAGS_CANDIDATE LANG FLAG_VAR)
 function(_OPENACC_GET_FLAGS_CANDIDATE LANG FLAG_VAR)
+  set(ACC_FLAG_NVHPC "-acc")
   set(ACC_FLAG_PGI "-acc")
   set(ACC_FLAG_PGI "-acc")
   set(ACC_FLAG_GNU "-fopenacc")
   set(ACC_FLAG_GNU "-fopenacc")
   set(ACC_FLAG_Cray "-h acc")
   set(ACC_FLAG_Cray "-h acc")
@@ -155,6 +156,7 @@ endfunction()
 
 
 function(_OPENACC_GET_ACCEL_TARGET_FLAG LANG TARGET FLAG_VAR)
 function(_OPENACC_GET_ACCEL_TARGET_FLAG LANG TARGET FLAG_VAR)
   # Find target accelerator flags.
   # Find target accelerator flags.
+  set(ACC_TARGET_FLAG_NVHPC "-ta")
   set(ACC_TARGET_FLAG_PGI "-ta")
   set(ACC_TARGET_FLAG_PGI "-ta")
   if(DEFINED ACC_TARGET_FLAG_${CMAKE_${LANG}_COMPILER_ID})
   if(DEFINED ACC_TARGET_FLAG_${CMAKE_${LANG}_COMPILER_ID})
     set("${FLAG_VAR}" "${ACC_TARGET_FLAG_${CMAKE_${LANG}_COMPILER_ID}}=${TARGET}" PARENT_SCOPE)
     set("${FLAG_VAR}" "${ACC_TARGET_FLAG_${CMAKE_${LANG}_COMPILER_ID}}=${TARGET}" PARENT_SCOPE)
@@ -164,6 +166,7 @@ endfunction()
 
 
 function(_OPENACC_GET_VERBOSE_FLAG LANG FLAG_VAR)
 function(_OPENACC_GET_VERBOSE_FLAG LANG FLAG_VAR)
   # Find compiler's verbose flag for OpenACC.
   # Find compiler's verbose flag for OpenACC.
+  set(ACC_VERBOSE_FLAG_NVHPC "-Minfo=accel")
   set(ACC_VERBOSE_FLAG_PGI "-Minfo=accel")
   set(ACC_VERBOSE_FLAG_PGI "-Minfo=accel")
   if(DEFINED ACC_VERBOSE_FLAG_${CMAKE_${LANG}_COMPILER_ID})
   if(DEFINED ACC_VERBOSE_FLAG_${CMAKE_${LANG}_COMPILER_ID})
     set("${FLAG_VAR}" "${ACC_VERBOSE_FLAG_${CMAKE_${LANG}_COMPILER_ID}}" PARENT_SCOPE)
     set("${FLAG_VAR}" "${ACC_VERBOSE_FLAG_${CMAKE_${LANG}_COMPILER_ID}}" PARENT_SCOPE)

+ 1 - 0
Modules/FindOpenMP.cmake

@@ -117,6 +117,7 @@ function(_OPENMP_FLAG_CANDIDATES LANG)
     set(OMP_FLAG_PathScale "-openmp")
     set(OMP_FLAG_PathScale "-openmp")
     set(OMP_FLAG_NAG "-openmp")
     set(OMP_FLAG_NAG "-openmp")
     set(OMP_FLAG_Absoft "-openmp")
     set(OMP_FLAG_Absoft "-openmp")
+    set(OMP_FLAG_NVHPC "-mp")
     set(OMP_FLAG_PGI "-mp")
     set(OMP_FLAG_PGI "-mp")
     set(OMP_FLAG_Flang "-fopenmp")
     set(OMP_FLAG_Flang "-fopenmp")
     set(OMP_FLAG_SunPro "-xopenmp")
     set(OMP_FLAG_SunPro "-xopenmp")

+ 2 - 2
Modules/GenerateExportHeader.cmake

@@ -232,7 +232,7 @@ macro(_test_compiler_hidden_visibility)
       AND NOT WIN32
       AND NOT WIN32
       AND NOT CYGWIN
       AND NOT CYGWIN
       AND NOT CMAKE_CXX_COMPILER_ID MATCHES XL
       AND NOT CMAKE_CXX_COMPILER_ID MATCHES XL
-      AND NOT CMAKE_CXX_COMPILER_ID MATCHES PGI
+      AND NOT CMAKE_CXX_COMPILER_ID MATCHES "^(PGI|NVHPC)$"
       AND NOT CMAKE_CXX_COMPILER_ID MATCHES Watcom)
       AND NOT CMAKE_CXX_COMPILER_ID MATCHES Watcom)
     if (CMAKE_CXX_COMPILER_LOADED)
     if (CMAKE_CXX_COMPILER_LOADED)
       check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY)
       check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY)
@@ -254,7 +254,7 @@ macro(_test_compiler_has_deprecated)
       OR CMAKE_CXX_COMPILER_ID MATCHES Embarcadero
       OR CMAKE_CXX_COMPILER_ID MATCHES Embarcadero
       OR CMAKE_CXX_COMPILER_ID MATCHES HP
       OR CMAKE_CXX_COMPILER_ID MATCHES HP
       OR GCC_TOO_OLD
       OR GCC_TOO_OLD
-      OR CMAKE_CXX_COMPILER_ID MATCHES PGI
+      OR CMAKE_CXX_COMPILER_ID MATCHES "^(PGI|NVHPC)$"
       OR CMAKE_CXX_COMPILER_ID MATCHES Watcom)
       OR CMAKE_CXX_COMPILER_ID MATCHES Watcom)
     set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL
     set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL
       "Compiler support for a deprecated attribute")
       "Compiler support for a deprecated attribute")

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

+ 2 - 2
Tests/CompileFeatures/CMakeLists.txt

@@ -15,7 +15,7 @@ macro(run_test feature lang)
   endif()
   endif()
 endmacro()
 endmacro()
 
 
-if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
+if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang)$")
   get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES)
   get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES)
   list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]")
   list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]")
   foreach(feature ${c_features})
   foreach(feature ${c_features})
@@ -23,7 +23,7 @@ if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
   endforeach()
   endforeach()
 endif()
 endif()
 
 
-if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
+if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang)$")
   get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
   get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
   list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]")
   list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]")
   foreach(feature ${cxx_features})
   foreach(feature ${cxx_features})

+ 1 - 1
Tests/FortranOnly/CMakeLists.txt

@@ -146,7 +146,7 @@ set_property(SOURCE no_preprocess_source_lower.f PROPERTY Fortran_PREPROCESS OFF
 # Test that we can explicitly not preprocess a target or source.
 # Test that we can explicitly not preprocess a target or source.
 # This will not work on certain compilers due to either missing a
 # This will not work on certain compilers due to either missing a
 # "don't preprocess" flag, or due to choice of file extension.
 # "don't preprocess" flag, or due to choice of file extension.
-if(test_pp_flags AND NOT CMAKE_Fortran_COMPILER_ID MATCHES "(Flang|NAG|PGI|SunPro|XL)")
+if(test_pp_flags AND NOT CMAKE_Fortran_COMPILER_ID MATCHES "(Flang|NAG|PGI|NVHPC|SunPro|XL)")
   add_library(no_preprocess_target STATIC no_preprocess_target_upper.F)
   add_library(no_preprocess_target STATIC no_preprocess_target_upper.F)
   target_compile_options(no_preprocess_target PRIVATE -DINTEGER=nonsense)
   target_compile_options(no_preprocess_target PRIVATE -DINTEGER=nonsense)
   add_library(no_preprocess_source STATIC no_preprocess_source_upper.F)
   add_library(no_preprocess_source STATIC no_preprocess_source_upper.F)

+ 2 - 2
Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt

@@ -52,7 +52,7 @@ endmacro()
 # detailed features tables, not just meta-features
 # detailed features tables, not just meta-features
 
 
 if (CMAKE_C_COMPILE_FEATURES)
 if (CMAKE_C_COMPILE_FEATURES)
-  if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
+  if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang)$")
     set(C_expected_features ${CMAKE_C_COMPILE_FEATURES})
     set(C_expected_features ${CMAKE_C_COMPILE_FEATURES})
     list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]")
     list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]")
   endif()
   endif()
@@ -95,7 +95,7 @@ if (C_expected_features)
 endif()
 endif()
 
 
 if (CMAKE_CXX_COMPILE_FEATURES)
 if (CMAKE_CXX_COMPILE_FEATURES)
-  if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
+  if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang)$")
     set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES})
     set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES})
     list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]")
     list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]")
   endif()
   endif()

+ 1 - 1
Tests/RunCMake/CMakeLists.txt

@@ -268,7 +268,7 @@ add_RunCMake_test(Graphviz)
 add_RunCMake_test(TargetPropertyGeneratorExpressions)
 add_RunCMake_test(TargetPropertyGeneratorExpressions)
 add_RunCMake_test(Languages)
 add_RunCMake_test(Languages)
 add_RunCMake_test(LinkStatic)
 add_RunCMake_test(LinkStatic)
-if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
+if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang)$")
   add_RunCMake_test(MetaCompileFeatures)
   add_RunCMake_test(MetaCompileFeatures)
 endif()
 endif()
 if(MSVC)
 if(MSVC)

+ 2 - 2
Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake

@@ -1,7 +1,7 @@
 set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
 set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
 
 
-# PGI compiler doesn't add build id to binaries by default
-if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI")
+# Some compilers do not add build id to binaries by default.
+if(CMAKE_CXX_COMPILER_ID MATCHES "^(PGI|NVHPC)$")
   string(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,--build-id")
   string(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,--build-id")
   string(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id")
   string(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id")
 endif()
 endif()