New compiler: nvhpc (NVIDIA HPC SDK) (#19294)
* Add nvhpc compiler definition: "spack compiler add" will now look for instances of the NVIDIA HPC SDK compiler executables (nvc, nvc++, nvfortran) in supplied paths * Add the nvhpc package which installs the nvhpc compiler * Add testing for nvhpc detection and C++-standard/pic flags Co-authored-by: Scott McMillan <smcmillan@nvidia.com>
This commit is contained in:
6
lib/spack/env/cc
vendored
6
lib/spack/env/cc
vendored
@@ -107,19 +107,19 @@ case "$command" in
|
||||
cpp)
|
||||
mode=cpp
|
||||
;;
|
||||
cc|c89|c99|gcc|clang|armclang|icc|pgcc|xlc|xlc_r|fcc)
|
||||
cc|c89|c99|gcc|clang|armclang|icc|pgcc|nvc|xlc|xlc_r|fcc)
|
||||
command="$SPACK_CC"
|
||||
language="C"
|
||||
comp="CC"
|
||||
lang_flags=C
|
||||
;;
|
||||
c++|CC|g++|clang++|armclang++|icpc|pgc++|xlc++|xlc++_r|FCC)
|
||||
c++|CC|g++|clang++|armclang++|icpc|pgc++|nvc++|xlc++|xlc++_r|FCC)
|
||||
command="$SPACK_CXX"
|
||||
language="C++"
|
||||
comp="CXX"
|
||||
lang_flags=CXX
|
||||
;;
|
||||
ftn|f90|fc|f95|gfortran|flang|armflang|ifort|pgfortran|xlf90|xlf90_r|nagfor|frt)
|
||||
ftn|f90|fc|f95|gfortran|flang|armflang|ifort|pgfortran|nvfortran|xlf90|xlf90_r|nagfor|frt)
|
||||
command="$SPACK_FC"
|
||||
language="Fortran 90"
|
||||
comp="FC"
|
||||
|
1
lib/spack/env/nvhpc/nvc
vendored
Symbolic link
1
lib/spack/env/nvhpc/nvc
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../cc
|
1
lib/spack/env/nvhpc/nvc++
vendored
Symbolic link
1
lib/spack/env/nvhpc/nvc++
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../cc
|
1
lib/spack/env/nvhpc/nvfortran
vendored
Symbolic link
1
lib/spack/env/nvhpc/nvfortran
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../cc
|
90
lib/spack/spack/compilers/nvhpc.py
Normal file
90
lib/spack/spack/compilers/nvhpc.py
Normal file
@@ -0,0 +1,90 @@
|
||||
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
|
||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
from spack.compiler import Compiler
|
||||
|
||||
|
||||
class Nvhpc(Compiler):
|
||||
# Subclasses use possible names of C compiler
|
||||
cc_names = ['nvc']
|
||||
|
||||
# Subclasses use possible names of C++ compiler
|
||||
cxx_names = ['nvc++']
|
||||
|
||||
# Subclasses use possible names of Fortran 77 compiler
|
||||
f77_names = ['nvfortran']
|
||||
|
||||
# Subclasses use possible names of Fortran 90 compiler
|
||||
fc_names = ['nvfortran']
|
||||
|
||||
# Named wrapper links within build_env_path
|
||||
link_paths = {'cc': 'nvhpc/nvc',
|
||||
'cxx': 'nvhpc/nvc++',
|
||||
'f77': 'nvhpc/nvfortran',
|
||||
'fc': 'nvhpc/nvfortran'}
|
||||
|
||||
PrgEnv = 'PrgEnv-nvhpc'
|
||||
PrgEnv_compiler = 'nvhpc'
|
||||
|
||||
version_argument = '--version'
|
||||
version_regex = r'nv[^ ]* (?:[^ ]+ Dev-r)?([0-9.]+)(?:-[0-9]+)?'
|
||||
|
||||
@property
|
||||
def verbose_flag(self):
|
||||
return "-v"
|
||||
|
||||
@property
|
||||
def debug_flags(self):
|
||||
return ['-g', '-gopt']
|
||||
|
||||
@property
|
||||
def opt_flags(self):
|
||||
return ['-O', '-O0', '-O1', '-O2', '-O3', '-O4']
|
||||
|
||||
@property
|
||||
def openmp_flag(self):
|
||||
return "-mp"
|
||||
|
||||
@property
|
||||
def cc_pic_flag(self):
|
||||
return "-fpic"
|
||||
|
||||
@property
|
||||
def cxx_pic_flag(self):
|
||||
return "-fpic"
|
||||
|
||||
@property
|
||||
def f77_pic_flag(self):
|
||||
return "-fpic"
|
||||
|
||||
@property
|
||||
def fc_pic_flag(self):
|
||||
return "-fpic"
|
||||
|
||||
@property
|
||||
def c99_flag(self):
|
||||
return '-c99'
|
||||
|
||||
@property
|
||||
def c11_flag(self):
|
||||
return '-c11'
|
||||
|
||||
@property
|
||||
def cxx11_flag(self):
|
||||
return '--c++11'
|
||||
|
||||
@property
|
||||
def cxx14_flag(self):
|
||||
return '--c++14'
|
||||
|
||||
@property
|
||||
def cxx17_flag(self):
|
||||
return '--c++17'
|
||||
|
||||
@property
|
||||
def stdcxx_libs(self):
|
||||
return ('-c++libs', )
|
||||
|
||||
required_libs = ['libnvc', 'libnvf']
|
@@ -533,6 +533,23 @@ def test_nag_flags():
|
||||
'nag@1.0')
|
||||
|
||||
|
||||
def test_nvhpc_flags():
|
||||
supported_flag_test("openmp_flag", "-mp", "nvhpc@20.9")
|
||||
supported_flag_test("cxx11_flag", "--c++11", "nvhpc@20.9")
|
||||
supported_flag_test("cxx14_flag", "--c++14", "nvhpc@20.9")
|
||||
supported_flag_test("cxx17_flag", "--c++17", "nvhpc@20.9")
|
||||
supported_flag_test("c99_flag", "-c99", "nvhpc@20.9")
|
||||
supported_flag_test("c11_flag", "-c11", "nvhpc@20.9")
|
||||
supported_flag_test("cc_pic_flag", "-fpic", "nvhpc@20.9")
|
||||
supported_flag_test("cxx_pic_flag", "-fpic", "nvhpc@20.9")
|
||||
supported_flag_test("f77_pic_flag", "-fpic", "nvhpc@20.9")
|
||||
supported_flag_test("fc_pic_flag", "-fpic", "nvhpc@20.9")
|
||||
supported_flag_test("debug_flags", ['-g', '-gopt'], 'nvhpc@20.9')
|
||||
supported_flag_test("opt_flags", ['-O', '-O0', '-O1', '-O2', '-O3', '-O4'],
|
||||
'nvhpc@20.9')
|
||||
supported_flag_test("stdcxx_libs", ('-c++libs',), 'nvhpc@20.9')
|
||||
|
||||
|
||||
def test_pgi_flags():
|
||||
supported_flag_test("openmp_flag", "-mp", "pgi@1.0")
|
||||
supported_flag_test("cxx11_flag", "-std=c++11", "pgi@1.0")
|
||||
|
@@ -15,6 +15,7 @@
|
||||
import spack.compilers.gcc
|
||||
import spack.compilers.intel
|
||||
import spack.compilers.nag
|
||||
import spack.compilers.nvhpc
|
||||
import spack.compilers.pgi
|
||||
import spack.compilers.xl
|
||||
import spack.compilers.xl_r
|
||||
@@ -157,6 +158,60 @@ def test_nag_version_detection(version_str, expected_version):
|
||||
assert version == expected_version
|
||||
|
||||
|
||||
@pytest.mark.parametrize('version_str,expected_version', [
|
||||
# C compiler on x86-64
|
||||
('nvc 20.9-0 LLVM 64-bit target on x86-64 Linux -tp haswell\n'
|
||||
'NVIDIA Compilers and Tools\n'
|
||||
'Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.',
|
||||
'20.9'),
|
||||
# C++ compiler on x86-64
|
||||
('nvc++ 20.9-0 LLVM 64-bit target on x86-64 Linux -tp haswell\n'
|
||||
'NVIDIA Compilers and Tools\n'
|
||||
'Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.',
|
||||
'20.9'),
|
||||
# Fortran compiler on x86-64
|
||||
('nvfortran 20.9-0 LLVM 64-bit target on x86-64 Linux -tp haswell\n'
|
||||
'NVIDIA Compilers and Tools\n'
|
||||
'Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.',
|
||||
'20.9'),
|
||||
# C compiler on Power
|
||||
('nvc 20.9-0 linuxpower target on Linuxpower\n'
|
||||
'NVIDIA Compilers and Tools\n'
|
||||
'Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.',
|
||||
'20.9'),
|
||||
# C++ compiler on Power
|
||||
('nvc++ 20.9-0 linuxpower target on Linuxpower\n'
|
||||
'NVIDIA Compilers and Tools\n'
|
||||
'Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.',
|
||||
'20.9'),
|
||||
# Fortran compiler on Power
|
||||
('nvfortran 20.9-0 linuxpower target on Linuxpower\n'
|
||||
'NVIDIA Compilers and Tools\n'
|
||||
'Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.',
|
||||
'20.9'),
|
||||
# C compiler on Arm
|
||||
('nvc 20.9-0 linuxarm64 target on aarch64 Linux\n'
|
||||
'NVIDIA Compilers and Tools\n'
|
||||
'Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.',
|
||||
'20.9'),
|
||||
# C++ compiler on Arm
|
||||
('nvc++ 20.9-0 linuxarm64 target on aarch64 Linux\n'
|
||||
'NVIDIA Compilers and Tools\n'
|
||||
'Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.',
|
||||
'20.9'),
|
||||
# Fortran compiler on Arm
|
||||
('nvfortran 20.9-0 linuxarm64 target on aarch64 Linux\n'
|
||||
'NVIDIA Compilers and Tools\n'
|
||||
'Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.',
|
||||
'20.9')
|
||||
])
|
||||
def test_nvhpc_version_detection(version_str, expected_version):
|
||||
version = spack.compilers.nvhpc.Nvhpc.extract_version_from_output(
|
||||
version_str
|
||||
)
|
||||
assert version == expected_version
|
||||
|
||||
|
||||
@pytest.mark.parametrize('version_str,expected_version', [
|
||||
# Output on x86-64
|
||||
('pgcc 15.10-0 64-bit target on x86-64 Linux -tp sandybridge\n'
|
||||
|
Reference in New Issue
Block a user