summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorScott McMillan <scott.andrew.mcmillan@gmail.com>2020-10-16 16:04:27 -0500
committerGitHub <noreply@github.com>2020-10-16 14:04:27 -0700
commita612be1c9883d6f2f41e227ca947ef9af9308cb2 (patch)
treebcae796bf4dd5e4014e916e902d7136f8660a834 /lib
parent78f349c635e477bb846b24e55912b0df80070f6c (diff)
downloadspack-a612be1c9883d6f2f41e227ca947ef9af9308cb2.tar.gz
spack-a612be1c9883d6f2f41e227ca947ef9af9308cb2.tar.bz2
spack-a612be1c9883d6f2f41e227ca947ef9af9308cb2.tar.xz
spack-a612be1c9883d6f2f41e227ca947ef9af9308cb2.zip
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>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/spack/env/cc6
l---------lib/spack/env/nvhpc/nvc1
l---------lib/spack/env/nvhpc/nvc++1
l---------lib/spack/env/nvhpc/nvfortran1
-rw-r--r--lib/spack/spack/compilers/nvhpc.py90
-rw-r--r--lib/spack/spack/test/compilers/basics.py17
-rw-r--r--lib/spack/spack/test/compilers/detection.py55
7 files changed, 168 insertions, 3 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index b5913c5f10..6de7df3576 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -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"
diff --git a/lib/spack/env/nvhpc/nvc b/lib/spack/env/nvhpc/nvc
new file mode 120000
index 0000000000..82c2b8e90a
--- /dev/null
+++ b/lib/spack/env/nvhpc/nvc
@@ -0,0 +1 @@
+../cc \ No newline at end of file
diff --git a/lib/spack/env/nvhpc/nvc++ b/lib/spack/env/nvhpc/nvc++
new file mode 120000
index 0000000000..82c2b8e90a
--- /dev/null
+++ b/lib/spack/env/nvhpc/nvc++
@@ -0,0 +1 @@
+../cc \ No newline at end of file
diff --git a/lib/spack/env/nvhpc/nvfortran b/lib/spack/env/nvhpc/nvfortran
new file mode 120000
index 0000000000..82c2b8e90a
--- /dev/null
+++ b/lib/spack/env/nvhpc/nvfortran
@@ -0,0 +1 @@
+../cc \ No newline at end of file
diff --git a/lib/spack/spack/compilers/nvhpc.py b/lib/spack/spack/compilers/nvhpc.py
new file mode 100644
index 0000000000..c102320132
--- /dev/null
+++ b/lib/spack/spack/compilers/nvhpc.py
@@ -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']
diff --git a/lib/spack/spack/test/compilers/basics.py b/lib/spack/spack/test/compilers/basics.py
index 762a2e67aa..9af416dd7b 100644
--- a/lib/spack/spack/test/compilers/basics.py
+++ b/lib/spack/spack/test/compilers/basics.py
@@ -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")
diff --git a/lib/spack/spack/test/compilers/detection.py b/lib/spack/spack/test/compilers/detection.py
index 634189d02a..4cb80090b5 100644
--- a/lib/spack/spack/test/compilers/detection.py
+++ b/lib/spack/spack/test/compilers/detection.py
@@ -15,6 +15,7 @@ import spack.compilers.fj
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
@@ -158,6 +159,60 @@ def test_nag_version_detection(version_str, 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'
'The Portland Group - PGI Compilers and Tools\n'