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 <kwrobot@kitware.com>
Merge-request: !5475
This commit is contained in:
Brad King
2021-01-28 14:03:01 +00:00
committed by Kitware Robot
21 changed files with 92 additions and 11 deletions

View File

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

View File

@@ -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)

View File

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

View File

@@ -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__)

View File

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

View File

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

View File

@@ -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")

View File

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

View File

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

View File

@@ -12,7 +12,7 @@ Detect OpenACC support by the compiler.
This module can be used to detect OpenACC support in a compiler.
If the compiler supports OpenACC, the flags required to compile with
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
^^^^^^^^^^^^^^^^
@@ -139,6 +139,7 @@ endfunction()
function(_OPENACC_GET_FLAGS_CANDIDATE LANG FLAG_VAR)
set(ACC_FLAG_NVHPC "-acc")
set(ACC_FLAG_PGI "-acc")
set(ACC_FLAG_GNU "-fopenacc")
set(ACC_FLAG_Cray "-h acc")
@@ -155,6 +156,7 @@ endfunction()
function(_OPENACC_GET_ACCEL_TARGET_FLAG LANG TARGET FLAG_VAR)
# Find target accelerator flags.
set(ACC_TARGET_FLAG_NVHPC "-ta")
set(ACC_TARGET_FLAG_PGI "-ta")
if(DEFINED ACC_TARGET_FLAG_${CMAKE_${LANG}_COMPILER_ID})
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)
# Find compiler's verbose flag for OpenACC.
set(ACC_VERBOSE_FLAG_NVHPC "-Minfo=accel")
set(ACC_VERBOSE_FLAG_PGI "-Minfo=accel")
if(DEFINED ACC_VERBOSE_FLAG_${CMAKE_${LANG}_COMPILER_ID})
set("${FLAG_VAR}" "${ACC_VERBOSE_FLAG_${CMAKE_${LANG}_COMPILER_ID}}" PARENT_SCOPE)

View File

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

View File

@@ -232,7 +232,7 @@ macro(_test_compiler_hidden_visibility)
AND NOT WIN32
AND NOT CYGWIN
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)
if (CMAKE_CXX_COMPILER_LOADED)
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 HP
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)
set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL
"Compiler support for a deprecated attribute")

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,7 +15,7 @@ macro(run_test feature lang)
endif()
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)
list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]")
foreach(feature ${c_features})
@@ -23,7 +23,7 @@ if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
endforeach()
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)
list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]")
foreach(feature ${cxx_features})

View File

@@ -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.
# This will not work on certain compilers due to either missing a
# "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)
target_compile_options(no_preprocess_target PRIVATE -DINTEGER=nonsense)
add_library(no_preprocess_source STATIC no_preprocess_source_upper.F)

View File

@@ -52,7 +52,7 @@ endmacro()
# detailed features tables, not just meta-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})
list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]")
endif()
@@ -95,7 +95,7 @@ if (C_expected_features)
endif()
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})
list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]")
endif()

View File

@@ -268,7 +268,7 @@ add_RunCMake_test(Graphviz)
add_RunCMake_test(TargetPropertyGeneratorExpressions)
add_RunCMake_test(Languages)
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)
endif()
if(MSVC)

View File

@@ -1,7 +1,7 @@
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_SHARED_LINKER_FLAGS "-Wl,--build-id")
endif()