From d93c0744916a6dfd44f6672be0eb4cb562a8f8d0 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 3 Aug 2022 11:54:09 -0400 Subject: AMReX: SYCL support (#31233) Add SYCL support, check CUDA-HIP-SYCL mutually exclusive. Require AMReX ver 21.06+ for SYCL. Co-authored-by: etpalmer63 --- var/spack/repos/builtin/packages/amrex/package.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'var/spack/repos/builtin/packages/amrex/package.py') diff --git a/var/spack/repos/builtin/packages/amrex/package.py b/var/spack/repos/builtin/packages/amrex/package.py index 2ad5307cf9..4167d11e53 100644 --- a/var/spack/repos/builtin/packages/amrex/package.py +++ b/var/spack/repos/builtin/packages/amrex/package.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import os + from spack.package import * @@ -83,6 +85,7 @@ class Amrex(CMakePackage, CudaPackage, ROCmPackage): variant("petsc", default=False, description="Enable PETSc interfaces") variant("sundials", default=False, description="Enable SUNDIALS interfaces") variant("pic", default=False, description="Enable PIC") + variant("sycl", default=False, description="Enable SYCL backend") # Build dependencies depends_on("mpi", when="+mpi") @@ -125,6 +128,8 @@ class Amrex(CMakePackage, CudaPackage, ROCmPackage): depends_on("hypre@2.19.0:", type="link", when="@21.03: ~cuda +hypre") depends_on("hypre@2.20.0:", type="link", when="@21.03: +cuda +hypre") depends_on("petsc", type="link", when="+petsc") + depends_on("cmake@3.22:", type="build", when="+sycl") + depends_on("intel-oneapi-mkl", type=("build", "link"), when="+sycl") # these versions of gcc have lambda function issues # see https://github.com/spack/spack/issues/22310 @@ -184,7 +189,14 @@ class Amrex(CMakePackage, CudaPackage, ROCmPackage): when="+rocm", msg="AMReX does not support rocm-4.2 due to a compiler bug", ) + # GPU vendor support is mutually exclusive conflicts("+cuda", when="+rocm", msg="CUDA and HIP support are exclusive") + conflicts("+cuda", when="+sycl", msg="CUDA and SYCL support are exclusive") + conflicts("+rocm", when="+sycl", msg="HIP and SYCL support are exclusive") + + conflicts( + "+sycl", when="@:21.05", msg="For SYCL support, AMReX version 21.06 and newer suggested." + ) def url_for_version(self, version): if version >= Version("20.05"): @@ -244,6 +256,16 @@ class Amrex(CMakePackage, CudaPackage, ROCmPackage): targets = self.spec.variants["amdgpu_target"].value args.append("-DAMReX_AMD_ARCH=" + ";".join(str(x) for x in targets)) + if "+sycl" in self.spec: + args.append("-DAMReX_GPU_BACKEND=SYCL") + # SYCL GPU backend only supported with Intel's oneAPI or DPC++ compilers + sycl_compatible_compilers = ["dpcpp", "icpx"] + if not (os.path.basename(self.compiler.cxx) in sycl_compatible_compilers): + raise InstallError( + "AMReX's SYCL GPU Backend requires DPC++ (dpcpp)" + + " or the oneAPI CXX (icpx) compiler." + ) + return args # -- cgit v1.2.3-60-g2f50