Skip to content

Commit

Permalink
make level_zero variant consistent, add missing instances (spack#47985)
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie authored Dec 10, 2024
1 parent 466c3ab commit 30c0035
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ spack:
# - py-torch # error

# GPU
- aml +ze
- aml +level_zero
- amrex +sycl
- arborx +sycl ^kokkos +sycl +openmp cxxstd=17 +examples
- cabana +sycl ^kokkos +sycl +openmp cxxstd=17 +examples
Expand Down
24 changes: 16 additions & 8 deletions var/spack/repos/builtin/packages/aml/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ class Aml(AutotoolsPackage):
#############################

variant("opencl", default=False, description="Support for memory operations on top of OpenCL.")
variant("ze", default=False, description="Support for memory operations on top of Level Zero.")
variant(
"level_zero",
default=False,
description="Support for memory operations on top of Level Zero.",
)
variant("hip", default=False, description="Support for memory operations on top of HIP.")
variant("cuda", default=False, description="Support for memory operations on top of CUDA.")
variant("hwloc", default=True, description="Enable feature related to topology management")
Expand All @@ -70,7 +74,7 @@ class Aml(AutotoolsPackage):
# - hip dependency. We use the environment variable HIP_PATH in the configure.
depends_on("hip", when="+hip")
# - level_zero loader is the dependency for the oneAPI variant
depends_on("oneapi-level-zero", when="+ze")
depends_on("oneapi-level-zero", when="+level_zero")
# - hwloc >= 2.1 becomes a dependency when +hwloc variant is used.
depends_on("hwloc@2.1:", when="+hwloc")
# - ocl-icd >= 2.1 becomes a dependency when +opencl variant is used.
Expand All @@ -94,15 +98,19 @@ class Aml(AutotoolsPackage):

# This is the function to overload to pass all hwloc flag.
def configure_args(self):
config_args = []
for b in ["opencl", "hwloc", "ze", "hip", "cuda"]:
config_args.extend(self.with_or_without(b))
config_args = [
*self.with_or_without("opencl"),
*self.with_or_without("hwloc"),
*self.with_or_without("hip"),
*self.with_or_without("cuda"),
*self.with_or_without("ze", variant="level_zero"),
]
if self.spec.satisfies("%oneapi"):
config_args += ["--with-openmp-flags=-fiopenmp -fopenmp-targets=spir64"]
config_args.append("--with-openmp-flags=-fiopenmp -fopenmp-targets=spir64")
if self.spec.variants["hip-platform"].value == "amd":
config_args += ["--with-hip-platform=amd"]
config_args.append("--with-hip-platform=amd")
if self.spec.variants["hip-platform"].value == "nvidia":
config_args += ["--with-hip-platform=nvidia"]
config_args.append("--with-hip-platform=nvidia")
return config_args

# Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class DoubleBatchedFftLibrary(CMakePackage):

variant("shared", default=True, description="Shared library")
variant("sycl", default=True, description="Build bbfft-sycl")
variant("level-zero", default=True, when="~sycl", description="Build bbfft-level-zero")
variant("level_zero", default=True, when="~sycl", description="Build bbfft-level-zero")
variant("opencl", default=True, when="~sycl", description="Build bbfft-opencl")

depends_on("cmake@3.23.0:", type="build")
depends_on("oneapi-level-zero", when="+sycl")
depends_on("oneapi-level-zero", when="+level-zero")
depends_on("oneapi-level-zero", when="+level_zero")
depends_on("opencl", when="+opencl")

patch("0001-Add-CPATH-and-LIBRARY_PATHs-to-OpenCL-search-paths.patch", when="@:0.3.6")
Expand All @@ -50,7 +50,7 @@ def cmake_args(self):
return [
self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
self.define_from_variant("BUILD_SYCL", "sycl"),
self.define_from_variant("BUILD_LEVEL_ZERO", "level-zero"),
self.define_from_variant("BUILD_LEVEL_ZERO", "level_zero"),
self.define_from_variant("BUILD_OPENCL", "opencl"),
self.define("BUILD_BENCHMARK", False),
self.define("BUILD_EXAMPLE", False),
Expand Down
34 changes: 16 additions & 18 deletions var/spack/repos/builtin/packages/geopm-service/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GeopmService(AutotoolsPackage):
)
variant("gnu-ld", default=False, description="Assume C compiler uses gnu-ld")

variant("levelzero", default=False, description="Enables the use of oneAPI Level Zero loader")
variant("level_zero", default=False, description="Enables the use of oneAPI Level Zero loader")
variant("nvml", default=False, description="Enable NVML support")

variant(
Expand All @@ -51,7 +51,7 @@ class GeopmService(AutotoolsPackage):
when="@develop",
)

conflicts("+nvml", when="+levelzero", msg="LevelZero and NVML support are mutually exclusive")
conflicts("+nvml", when="+level_zero", msg="LevelZero and NVML support are mutually exclusive")

conflicts("%gcc@:7.2", msg="Requires C++17 support")
conflicts("%clang@:4", msg="Requires C++17 support")
Expand Down Expand Up @@ -100,7 +100,7 @@ class GeopmService(AutotoolsPackage):
depends_on("systemd", when="+systemd")
depends_on("libcap", when="+libcap")
depends_on("liburing", when="+liburing")
depends_on("oneapi-level-zero", when="+levelzero")
depends_on("oneapi-level-zero", when="+level_zero")
depends_on("cuda", when="+nvml")

extends("python")
Expand Down Expand Up @@ -129,19 +129,19 @@ def autoreconf(self, spec, prefix):
def configure_args(self):
args = [
"--with-bash-completion-dir="
+ join_path(self.spec.prefix, "share", "bash-completion", "completions")
+ join_path(self.spec.prefix, "share", "bash-completion", "completions"),
*self.enable_or_disable("debug"),
*self.enable_or_disable("docs"),
*self.enable_or_disable("systemd"),
*self.enable_or_disable("liburing"),
*self.with_or_without("liburing", activation_value="prefix"),
*self.enable_or_disable("libcap"),
*self.with_or_without("gnu-ld"),
*self.enable_or_disable("levelzero", variant="level_zero"),
*self.enable_or_disable("nvml"),
*self.enable_or_disable("rawmsr"),
]

args += self.enable_or_disable("debug")
args += self.enable_or_disable("docs")
args += self.enable_or_disable("systemd")
args += self.enable_or_disable("liburing")
args += self.with_or_without("liburing", activation_value="prefix")
args += self.enable_or_disable("libcap")
args += self.with_or_without("gnu-ld")

args += self.enable_or_disable("levelzero")
args += self.enable_or_disable("nvml")
if self.spec.satisfies("+nvml"):
args += [
"--with-nvml="
Expand All @@ -150,10 +150,8 @@ def configure_args(self):
)
]

args += self.enable_or_disable("rawmsr")
with when("@develop"):
if self.spec.target.family != "x86_64":
args += ["--disable-cpuid"]
if self.spec.satisfies("@develop") and self.spec.target.family != "x86_64":
args.append("--disable-cpuid")
return args

def setup_run_environment(self, env):
Expand Down
44 changes: 19 additions & 25 deletions var/spack/repos/builtin/packages/hwloc/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ class Hwloc(AutotoolsPackage, CudaPackage, ROCmPackage):
)
variant("opencl", default=False, description="Support an OpenCL library at run time")
variant("rocm", default=False, description="Support ROCm devices")
variant(
"oneapi-level-zero", default=False, description="Support Intel OneAPI Level Zero devices"
)
variant("level_zero", default=False, description="Support Intel OneAPI Level Zero devices")

depends_on("c", type="build")
depends_on("cxx", type="build")
Expand Down Expand Up @@ -139,10 +137,10 @@ class Hwloc(AutotoolsPackage, CudaPackage, ROCmPackage):
# variant of llvm-amdgpu depends on hwloc.
depends_on("llvm-amdgpu", when="+opencl")

with when("+oneapi-level-zero"):
with when("+level_zero"):
depends_on("oneapi-level-zero")
# LevelZero support isn't available until hwloc version 2.5.0
conflicts("@:2.4.99", msg="hwloc supports Intel OneAPI Level Zero only since 2.5.0")
conflicts("@:2.4", msg="hwloc supports Intel OneAPI Level Zero only since 2.5.0")

@classmethod
def determine_version(cls, exe):
Expand All @@ -160,7 +158,18 @@ def libs(self):
return LibraryList(libs)

def configure_args(self):
args = []
args = [
*self.enable_or_disable("netloc"),
*self.enable_or_disable("cairo"),
*self.enable_or_disable("nvml"),
*self.enable_or_disable("gl"),
*self.enable_or_disable("cuda"),
*self.enable_or_disable("libxml2"),
*self.enable_or_disable("libudev"),
*self.enable_or_disable("pci"),
*self.enable_or_disable("libs"),
*self.enable_or_disable("levelzero", variant="level_zero"),
]

# If OpenCL is not enabled, disable it since hwloc might
# pick up an OpenCL library at build time that is then
Expand All @@ -179,26 +188,11 @@ def configure_args(self):
args.append("--disable-rsmi")

if self.spec.satisfies("+rocm"):
args.append("--with-rocm={0}".format(self.spec["hip"].prefix))
args.append("--with-rocm-version={0}".format(self.spec["hip"].version))

args.extend(self.enable_or_disable("netloc"))
args.extend(self.enable_or_disable("cairo"))
args.extend(self.enable_or_disable("nvml"))
args.extend(self.enable_or_disable("gl"))
args.extend(self.enable_or_disable("cuda"))
args.extend(self.enable_or_disable("libxml2"))
args.extend(self.enable_or_disable("libudev"))
args.extend(self.enable_or_disable("pci"))
args.extend(self.enable_or_disable("libs"))
args.append(f'--with-rocm={self.spec["hip"].prefix}')
args.append(f'--with-rocm-version={self.spec["hip"].version}')

if self.spec.satisfies("+cuda"):
args.append("--with-cuda={0}".format(self.spec["cuda"].prefix))
args.append("--with-cuda-version={0}".format(self.spec["cuda"].version))

if self.spec.satisfies("+oneapi-level-zero"):
args.append("--enable-levelzero")
else:
args.append("--disable-levelzero")
args.append(f'--with-cuda={self.spec["cuda"].prefix}')
args.append(f'--with-cuda-version={self.spec["cuda"].version}')

return args
31 changes: 12 additions & 19 deletions var/spack/repos/builtin/packages/libfabric/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ class Libfabric(AutotoolsPackage, CudaPackage):
# device file can only be opened once per process, however, and thus it
# frequently conflicts with MPI.
variant("kdreg", default=False, description="Enable kdreg on supported Cray platforms")

variant("debug", default=False, description="Enable debugging")

variant("uring", default=False, when="@1.17.0:", description="Enable uring support")
variant("level_zero", default=False, description="Enable Level Zero support")

# For version 1.9.0:
# headers: fix forward-declaration of enum fi_collective_op with C++
Expand All @@ -132,6 +131,7 @@ class Libfabric(AutotoolsPackage, CudaPackage):
depends_on("uuid", when="fabrics=opx")
depends_on("numactl", when="fabrics=opx")
depends_on("liburing@2.1:", when="+uring")
depends_on("oneapi-level-zero", when="+level_zero")

depends_on("m4", when="@main", type="build")
depends_on("autoconf", when="@main", type="build")
Expand Down Expand Up @@ -195,26 +195,19 @@ def autoreconf(self, spec, prefix):
bash("./autogen.sh")

def configure_args(self):
args = []

args.extend(self.enable_or_disable("debug"))

if self.spec.satisfies("+kdreg"):
args.append("--with-kdreg=yes")
else:
args.append("--with-kdreg=no")

if self.spec.satisfies("+uring"):
args.append("--with-uring=yes")
args = [
*self.enable_or_disable("debug"),
*self.with_or_without("kdreg"),
*self.with_or_without("uring"),
*self.with_or_without("cuda", activation_value="prefix"),
*self.with_or_without("ze", variant="level_zero"),
]

for fabric in [f if isinstance(f, str) else f[0].value for f in self.fabrics]:
if "fabrics=" + fabric in self.spec:
args.append("--enable-{0}=yes".format(fabric))
if f"fabrics={fabric}" in self.spec:
args.append(f"--enable-{fabric}")
else:
args.append("--enable-{0}=no".format(fabric))

if self.spec.satisfies("+cuda"):
args.append(f"--with-cuda={self.spec['cuda'].prefix}")
args.append(f"--disable-{fabric}")

return args

Expand Down
11 changes: 8 additions & 3 deletions var/spack/repos/builtin/packages/libquo/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class Libquo(AutotoolsPackage):
version("1.3", sha256="61b0beff15eae4be94b5d3cbcbf7bf757659604465709ed01827cbba45efcf90")
version("1.2.9", sha256="0a64bea8f52f9eecd89e4ab82fde1c5bd271f3866c612da0ce7f38049409429b")

depends_on("c", type="build") # generated
depends_on("fortran", type="build") # generated
depends_on("c", type="build")
depends_on("fortran", type="build")

depends_on("mpi")

Expand All @@ -43,4 +43,9 @@ def autoreconf(self, spec, prefix):
bash("./autogen")

def configure_args(self):
return [f"CC={self.spec['mpi'].mpicc}", f"FC={self.spec['mpi'].mpifc}"]
return [
f"CC={self.spec['mpi'].mpicc}",
f"FC={self.spec['mpi'].mpifc}",
# hwloc is vendored
"--disable-levelzero",
]
28 changes: 18 additions & 10 deletions var/spack/repos/builtin/packages/mpich/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ class Mpich(AutotoolsPackage, CudaPackage, ROCmPackage):
version("3.1", sha256="fcf96dbddb504a64d33833dc455be3dda1e71c7b3df411dfcf9df066d7c32c39")
version("3.0.4", sha256="cf638c85660300af48b6f776e5ecd35b5378d5905ec5d34c3da7a27da0acf0b3")

depends_on("c", type="build") # generated
depends_on("cxx", type="build") # generated
depends_on("fortran", type="build", when="+fortran")

variant("hwloc", default=True, description="Use external hwloc package")
variant("hydra", default=True, description="Build the hydra process manager")
variant("romio", default=True, description="Enable ROMIO MPI I/O implementation")
Expand Down Expand Up @@ -134,21 +130,27 @@ class Mpich(AutotoolsPackage, CudaPackage, ROCmPackage):
depends_on("yaksa+cuda", when="+cuda")
depends_on("yaksa+rocm", when="+rocm")

conflicts("datatype-engine=yaksa", when="device=ch3")
conflicts("datatype-engine=yaksa", when="device=ch3:sock")
conflicts("datatype-engine=dataloop", when="+cuda")
conflicts("datatype-engine=dataloop", when="+rocm")

variant(
"hcoll",
default=False,
description="Enable support for Mellanox HCOLL accelerated "
"collective operations library",
when="@3.3: device=ch4 netmod=ucx",
)
depends_on("hcoll", when="+hcoll")

variant("xpmem", default=False, when="@3.4:", description="Enable XPMEM support")
variant("level_zero", default=False, description="Enable level zero support")

conflicts("datatype-engine=yaksa", when="device=ch3")
conflicts("datatype-engine=yaksa", when="device=ch3:sock")
conflicts("datatype-engine=dataloop", when="+cuda")
conflicts("datatype-engine=dataloop", when="+rocm")

depends_on("c", type="build")
depends_on("cxx", type="build")
depends_on("fortran", type="build", when="+fortran")

depends_on("hcoll", when="+hcoll")
depends_on("xpmem", when="+xpmem")

# Todo: cuda can be a conditional variant, but it does not seem to work when
Expand Down Expand Up @@ -303,6 +305,7 @@ class Mpich(AutotoolsPackage, CudaPackage, ROCmPackage):
depends_on("python@3.0:", when="@develop", type="build")

depends_on("cray-pmi", when="pmi=cray")
depends_on("oneapi-level-zero", when="+level_zero")

conflicts("device=ch4", when="@:3.2")
conflicts("netmod=ofi", when="@:3.1.4")
Expand Down Expand Up @@ -523,8 +526,13 @@ def configure_args(self):
"--{0}-ibverbs".format("with" if "+verbs" in spec else "without"),
"--enable-wrapper-rpath={0}".format("no" if "~wrapperrpath" in spec else "yes"),
"--with-yaksa={0}".format(spec["yaksa"].prefix if "^yaksa" in spec else "embedded"),
*self.with_or_without("ze", variant="level_zero"),
]

# https://github.com/pmodels/mpich/commit/bbfc4cab6ade0b75ef3803a83af1cad4a262a564
if self.spec.satisfies("@:4.2 ~hwloc"):
config_args += self.enable_or_disable("levelzero", variant="level_zero")

# see https://github.com/pmodels/mpich/issues/5530
if spec.platform == "darwin":
config_args.append("--enable-two-level-namespace")
Expand Down
Loading

0 comments on commit 30c0035

Please sign in to comment.