From edb971a10e360b673e9fb9a4a7ef09e597b7df5a Mon Sep 17 00:00:00 2001 From: Peter Scheibel Date: Thu, 2 Dec 2021 15:49:20 -0800 Subject: [PATCH] Support packages which need to explicitly refer to dpcpp by name (#27168) * Hack to support packages which need to explicitly refer to dpcpp by name * cc script needs to know about dpcpp --- lib/spack/env/cc | 2 +- lib/spack/env/oneapi/dpcpp | 1 + lib/spack/spack/compilers/dpcpp.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 120000 lib/spack/env/oneapi/dpcpp create mode 100644 lib/spack/spack/compilers/dpcpp.py diff --git a/lib/spack/env/cc b/lib/spack/env/cc index c498db0583..59ff0001e1 100755 --- a/lib/spack/env/cc +++ b/lib/spack/env/cc @@ -248,7 +248,7 @@ case "$command" in lang_flags=C debug_flags="-g" ;; - c++|CC|g++|clang++|armclang++|icpc|icpx|pgc++|nvc++|xlc++|xlc++_r|FCC) + c++|CC|g++|clang++|armclang++|icpc|icpx|dpcpp|pgc++|nvc++|xlc++|xlc++_r|FCC) command="$SPACK_CXX" language="C++" comp="CXX" diff --git a/lib/spack/env/oneapi/dpcpp b/lib/spack/env/oneapi/dpcpp new file mode 120000 index 0000000000..82c2b8e90a --- /dev/null +++ b/lib/spack/env/oneapi/dpcpp @@ -0,0 +1 @@ +../cc \ No newline at end of file diff --git a/lib/spack/spack/compilers/dpcpp.py b/lib/spack/spack/compilers/dpcpp.py new file mode 100644 index 0000000000..664b1d86c5 --- /dev/null +++ b/lib/spack/spack/compilers/dpcpp.py @@ -0,0 +1,29 @@ +# Copyright 2013-2021 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) + +import spack.compilers.oneapi + + +class Dpcpp(spack.compilers.oneapi.Oneapi): + """This is the same as the oneAPI compiler but uses dpcpp instead of + icpx (for DPC++ source files). It explicitly refers to dpcpp, so that + CMake test files which check the compiler name (e.g. CMAKE_CXX_COMPILER) + detect it as dpcpp. + + Ideally we could switch out icpx for dpcpp where needed in the oneAPI + compiler definition, but two things are needed for that: (a) a way to + tell the compiler that it should be using dpcpp and (b) a way to + customize the link_paths + + See also: https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compiler-setup/using-the-command-line/invoking-the-compiler.html + """ + # Subclasses use possible names of C++ compiler + cxx_names = ['dpcpp'] + + # Named wrapper links within build_env_path + link_paths = {'cc': 'oneapi/icx', + 'cxx': 'oneapi/dpcpp', + 'f77': 'oneapi/ifx', + 'fc': 'oneapi/ifx'}