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>
This commit is contained in:
parent
52959528a2
commit
c954d50998
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|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"
|
||||
|
1
lib/spack/env/oneapi/icpx
vendored
Symbolic link
1
lib/spack/env/oneapi/icpx
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../cc
|
1
lib/spack/env/oneapi/icx
vendored
Symbolic link
1
lib/spack/env/oneapi/icx
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../cc
|
1
lib/spack/env/oneapi/ifx
vendored
Symbolic link
1
lib/spack/env/oneapi/ifx
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../cc
|
105
lib/spack/spack/compilers/oneapi.py
Normal file
105
lib/spack/spack/compilers/oneapi.py
Normal file
@ -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', )
|
@ -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")
|
||||
|
@ -14,6 +14,7 @@
|
||||
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
|
||||
@ -150,6 +151,37 @@ def test_intel_version_detection(version_str, expected_version):
|
||||
assert version == 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
|
||||
|
Loading…
Reference in New Issue
Block a user