summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFrank Willmore <frankwillmore@gmail.com>2020-10-29 16:52:54 -0500
committerGitHub <noreply@github.com>2020-10-29 16:52:54 -0500
commitc954d50998f6a223027d864c5e4f161e5b2e27f1 (patch)
tree8484e35164bda11cb41afa63833a72c992d49b1e /lib
parent52959528a2cb7e7e9b213efd1243a078502ac708 (diff)
downloadspack-c954d50998f6a223027d864c5e4f161e5b2e27f1.tar.gz
spack-c954d50998f6a223027d864c5e4f161e5b2e27f1.tar.bz2
spack-c954d50998f6a223027d864c5e4f161e5b2e27f1.tar.xz
spack-c954d50998f6a223027d864c5e4f161e5b2e27f1.zip
Oneapi add compiler (#19330)
* enable flatcc to be built with gcc/9.X.X * add static option for building libyogrt * cleanup * Initial working version * rework new oneapi wrappers * tested and removed my initials from source * cleanup * Update __init__.py * remove whitespace * working now with mods for testing, detection. Detection for oneapi is working, but entry needs to be modified to add link path for libimf.so. Cleared cruft for old Intel versions * fixed some formatting * cleanup * flake8 cleanup * flake8 * fixed syntax of compiler version detection tests * fixed syntax of compiler version detection tests modified: detection.py * fix typo * fixes for compilers tests * remove erroneous tests for outdated -std= flags, remove ifx version check (output won't parse) Co-authored-by: Frank Willmore <willmore@anl.gov>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/spack/env/cc6
l---------lib/spack/env/oneapi/icpx1
l---------lib/spack/env/oneapi/icx1
l---------lib/spack/env/oneapi/ifx1
-rw-r--r--lib/spack/spack/compilers/oneapi.py105
-rw-r--r--lib/spack/spack/test/compilers/basics.py19
-rw-r--r--lib/spack/spack/test/compilers/detection.py34
7 files changed, 164 insertions, 3 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index e826cabca4..f23b22775b 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|nvc|xlc|xlc_r|fcc)
+ cc|c89|c99|gcc|clang|armclang|icc|icx|pgcc|nvc|xlc|xlc_r|fcc)
command="$SPACK_CC"
language="C"
comp="CC"
lang_flags=C
;;
- c++|CC|g++|clang++|armclang++|icpc|pgc++|nvc++|xlc++|xlc++_r|FCC)
+ c++|CC|g++|clang++|armclang++|icpc|icpx|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|nvfortran|xlf90|xlf90_r|nagfor|frt)
+ ftn|f90|fc|f95|gfortran|flang|armflang|ifort|ifx|pgfortran|nvfortran|xlf90|xlf90_r|nagfor|frt)
command="$SPACK_FC"
language="Fortran 90"
comp="FC"
diff --git a/lib/spack/env/oneapi/icpx b/lib/spack/env/oneapi/icpx
new file mode 120000
index 0000000000..82c2b8e90a
--- /dev/null
+++ b/lib/spack/env/oneapi/icpx
@@ -0,0 +1 @@
+../cc \ No newline at end of file
diff --git a/lib/spack/env/oneapi/icx b/lib/spack/env/oneapi/icx
new file mode 120000
index 0000000000..82c2b8e90a
--- /dev/null
+++ b/lib/spack/env/oneapi/icx
@@ -0,0 +1 @@
+../cc \ No newline at end of file
diff --git a/lib/spack/env/oneapi/ifx b/lib/spack/env/oneapi/ifx
new file mode 120000
index 0000000000..82c2b8e90a
--- /dev/null
+++ b/lib/spack/env/oneapi/ifx
@@ -0,0 +1 @@
+../cc \ No newline at end of file
diff --git a/lib/spack/spack/compilers/oneapi.py b/lib/spack/spack/compilers/oneapi.py
new file mode 100644
index 0000000000..bd511a4988
--- /dev/null
+++ b/lib/spack/spack/compilers/oneapi.py
@@ -0,0 +1,105 @@
+# 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 Oneapi(Compiler):
+ # Subclasses use possible names of C compiler
+ cc_names = ['icx']
+
+ # Subclasses use possible names of C++ compiler
+ cxx_names = ['icpx']
+
+ # Subclasses use possible names of Fortran 77 compiler
+ f77_names = ['ifx']
+
+ # Subclasses use possible names of Fortran 90 compiler
+ fc_names = ['ifx']
+
+ # Named wrapper links within build_env_path
+ link_paths = {'cc': 'oneapi/icx',
+ 'cxx': 'oneapi/icpx',
+ 'f77': 'oneapi/ifx',
+ 'fc': 'oneapi/ifx'}
+
+ PrgEnv = 'PrgEnv-oneapi'
+ PrgEnv_compiler = 'oneapi'
+
+ version_argument = '--version'
+ version_regex = r'\((?:IFORT|ICC)\)|DPC\+\+ [^ ]+ [^ ]+ [^ ]+ \(([^ ]+)\)'
+
+ @property
+ def verbose_flag(self):
+ return "-v"
+
+ required_libs = ['libirc', 'libifcore', 'libifcoremt', 'libirng']
+
+ @property
+ def debug_flags(self):
+ return ['-debug', '-g', '-g0', '-g1', '-g2', '-g3']
+
+ @property
+ def opt_flags(self):
+ return ['-O', '-O0', '-O1', '-O2', '-O3', '-Ofast', '-Os']
+
+ @property
+ def openmp_flag(self):
+ return "-qopenmp"
+ # There may be some additional options here for offload, e.g. :
+ # -fopenmp-simd Emit OpenMP code only for SIMD-based constructs.
+ # -fopenmp-targets=<value>
+ # -fopenmp-version=<value>
+ # -fopenmp Parse OpenMP pragmas and generate parallel code.
+ # -qno-openmp Disable OpenMP support
+ # -qopenmp-link=<value> Choose whether to link with the static or
+ # dynamic OpenMP libraries. Default is dynamic.
+ # -qopenmp-simd Emit OpenMP code only for SIMD-based constructs.
+ # -qopenmp-stubs enables the user to compile OpenMP programs in
+ # sequential mode. The OpenMP directives are
+ # ignored and a stub OpenMP library is linked.
+ # -qopenmp-threadprivate=<value>
+ # -qopenmp Parse OpenMP pragmas and generate parallel code.
+ # -static-openmp Use the static host OpenMP runtime while
+ # linking.
+ # -Xopenmp-target=<triple> <arg>
+ # -Xopenmp-target <arg> Pass <arg> to the target offloading toolchain.
+ # Source: icx --help output
+
+ @property
+ def cxx11_flag(self):
+ return "-std=c++11"
+
+ @property
+ def cxx14_flag(self):
+ return "-std=c++14"
+
+ @property
+ def c99_flag(self):
+ return "-std=c99"
+
+ @property
+ def c11_flag(self):
+ return "-std=c1x"
+
+ @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 stdcxx_libs(self):
+ return ('-cxxlib', )
diff --git a/lib/spack/spack/test/compilers/basics.py b/lib/spack/spack/test/compilers/basics.py
index 22099bdb63..78d8484b3b 100644
--- a/lib/spack/spack/test/compilers/basics.py
+++ b/lib/spack/spack/test/compilers/basics.py
@@ -540,6 +540,25 @@ def test_intel_flags():
'intel@1.0')
+def test_oneapi_flags():
+ supported_flag_test("openmp_flag", "-qopenmp", "oneapi@2020.8.0.0827")
+ supported_flag_test("cxx11_flag", "-std=c++11", "oneapi@2020.8.0.0827")
+ supported_flag_test("cxx14_flag", "-std=c++14", "oneapi@2020.8.0.0827")
+ supported_flag_test("c99_flag", "-std=c99", "oneapi@2020.8.0.0827")
+ supported_flag_test("c11_flag", "-std=c1x", "oneapi@2020.8.0.0827")
+ supported_flag_test("cc_pic_flag", "-fPIC", "oneapi@2020.8.0.0827")
+ supported_flag_test("cxx_pic_flag", "-fPIC", "oneapi@2020.8.0.0827")
+ supported_flag_test("f77_pic_flag", "-fPIC", "oneapi@2020.8.0.0827")
+ supported_flag_test("fc_pic_flag", "-fPIC", "oneapi@2020.8.0.0827")
+ supported_flag_test("stdcxx_libs", ("-cxxlib",), "oneapi@2020.8.0.0827")
+ supported_flag_test("debug_flags",
+ ['-debug', '-g', '-g0', '-g1', '-g2', '-g3'],
+ 'oneapi@2020.8.0.0827')
+ supported_flag_test("opt_flags",
+ ['-O', '-O0', '-O1', '-O2', '-O3', '-Ofast', '-Os'],
+ 'oneapi@2020.8.0.0827')
+
+
def test_nag_flags():
supported_flag_test("openmp_flag", "-openmp", "nag@1.0")
supported_flag_test("cxx11_flag", "-std=c++11", "nag@1.0")
diff --git a/lib/spack/spack/test/compilers/detection.py b/lib/spack/spack/test/compilers/detection.py
index cf2f7a057a..a74c4c201a 100644
--- a/lib/spack/spack/test/compilers/detection.py
+++ b/lib/spack/spack/test/compilers/detection.py
@@ -14,6 +14,7 @@ import spack.compilers.clang
import spack.compilers.fj
import spack.compilers.gcc
import spack.compilers.intel
+import spack.compilers.oneapi
import spack.compilers.nag
import spack.compilers.nvhpc
import spack.compilers.pgi
@@ -151,6 +152,37 @@ def test_intel_version_detection(version_str, expected_version):
@pytest.mark.parametrize('version_str,expected_version', [
+ ( # ICX
+ 'Intel(R) oneAPI DPC++ Compiler Pro 2021.1 (2020.8.0.0827)\n'
+ 'Target: x86_64-unknown-linux-gnu\n'
+ 'Thread model: posix\n'
+ 'InstalledDir: /soft/restricted/CNDA/sdk/\n'
+ '2020.9.15.1/oneapi/compiler/2021.1-beta09/linux/bin',
+ '2020.8.0.0827'
+ ),
+ ( # ICPX
+ 'Intel(R) oneAPI DPC++ Compiler Pro 2021.1 (2020.8.0.0827)\n'
+ 'Target: x86_64-unknown-linux-gnu\n'
+ 'Thread model: posix\n'
+ 'InstalledDir: /soft/restricted/CNDA/sdk/\n'
+ '2020.9.15.1/oneapi/compiler/2021.1-beta09/linux/bin',
+ '2020.8.0.0827'
+ )
+ # Detection will fail for ifx because it can't parse it from this.
+ # ( # IFX
+ # 'ifx (IFORT) 2021.1 Beta 20200827\n'
+ # 'Copyright (C) 1985-2020 Intel Corporation. All rights reserved.',
+ # '2020.8.0.0827'
+ # )
+])
+def test_oneapi_version_detection(version_str, expected_version):
+ version = spack.compilers.oneapi.Oneapi.extract_version_from_output(
+ version_str
+ )
+ assert version == expected_version
+
+
+@pytest.mark.parametrize('version_str,expected_version', [
('NAG Fortran Compiler Release 6.0(Hibiya) Build 1037\n'
'Product NPL6A60NA for x86-64 Linux\n', '6.0')
])
@@ -260,6 +292,8 @@ def test_xl_version_detection(version_str, expected_version):
('pgi', '19.1a'),
('intel', '9.0.0'),
('intel', '0.0.0-foobar')
+ # ('oneapi', '2021.1'),
+ # ('oneapi', '2021.1-foobar')
])
def test_cray_frontend_compiler_detection(
compiler, version, tmpdir, monkeypatch, working_env