From d2372f8eee43115d3d4f18e8468d33ba6bf88e1b Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 13 Dec 2024 16:09:17 -0700 Subject: [PATCH] Add libcxi and its dependencies (#47705) --- .../packages/cassini-headers/package.py | 24 ++++++ .../builtin/packages/cxi-driver/package.py | 22 ++++++ .../repos/builtin/packages/libcxi/package.py | 74 +++++++++++++++++++ .../builtin/packages/libfabric/package.py | 16 ++-- 4 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 var/spack/repos/builtin/packages/cassini-headers/package.py create mode 100644 var/spack/repos/builtin/packages/cxi-driver/package.py create mode 100644 var/spack/repos/builtin/packages/libcxi/package.py diff --git a/var/spack/repos/builtin/packages/cassini-headers/package.py b/var/spack/repos/builtin/packages/cassini-headers/package.py new file mode 100644 index 00000000000..c6cb72ae817 --- /dev/null +++ b/var/spack/repos/builtin/packages/cassini-headers/package.py @@ -0,0 +1,24 @@ +# Copyright 2013-2024 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.package import * + + +class CassiniHeaders(Package): + """This package provides hardware definitions and C headers for use by the + Linux driver and by user-space applications for the Cassini/Slingshot + +high-speed network interconnect made by HPE (formerly Cray)""" + + homepage = "https://github.com/HewlettPackard/shs-cassini-headers" + git = "https://github.com/HewlettPackard/shs-cassini-headers.git" + + license("GPL-2.0-only or BSD-2-Clause") + + version("main", branch="main") + + def install(self, spec, prefix): + with working_dir(self.stage.source_path): + copy_tree("include", prefix.include) + copy_tree("share", prefix.share) diff --git a/var/spack/repos/builtin/packages/cxi-driver/package.py b/var/spack/repos/builtin/packages/cxi-driver/package.py new file mode 100644 index 00000000000..d8f554a1e53 --- /dev/null +++ b/var/spack/repos/builtin/packages/cxi-driver/package.py @@ -0,0 +1,22 @@ +# Copyright 2013-2024 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.package import * + + +class CxiDriver(Package): + """This are the Linux driver headers for the Cray/HPE Cassini 1 and 2 + high-speed network interconnect (aka. Slingshot), and its Ethernet driver.""" + + homepage = "https://github.com/HewlettPackard/shs-cxi-driver" + git = "https://github.com/HewlettPackard/shs-cxi-driver.git" + + license("GPL-2.0") + + version("main", branch="main") + + def install(self, spec, prefix): + with working_dir(self.stage.source_path): + copy_tree("include", prefix.include) diff --git a/var/spack/repos/builtin/packages/libcxi/package.py b/var/spack/repos/builtin/packages/libcxi/package.py new file mode 100644 index 00000000000..10b7553e094 --- /dev/null +++ b/var/spack/repos/builtin/packages/libcxi/package.py @@ -0,0 +1,74 @@ +# Copyright 2013-2024 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.package import * + + +class Libcxi(AutotoolsPackage): + """The CXI library provides interfaces which interact directly with CXI + drivers.""" + + homepage = "https://github.com/HewlettPackard/shs-libcxi" + git = "https://github.com/HewlettPackard/shs-libcxi.git" + + license("LGPL-2.1-or-later or BSD-3-Clause") + + # no releases, tags: see https://github.com/HewlettPackard/shs-libcxi/issues/2 + version("main", branch="main") + + variant("level_zero", default=False, description="Enable level zero support") + variant("cuda", default=False, description="Build with CUDA support") + variant("rocm", default=False, description="Build with ROCm support") + + depends_on("c", type="build") + + depends_on("cassini-headers") + depends_on("cxi-driver") + + depends_on("libconfig@1.5:") + depends_on("libuv@1.18:") + # configure fails with newer libfuse + # see https://github.com/HewlettPackard/shs-libcxi/issues/3 + depends_on("libfuse@2.9.7:2") + depends_on("libyaml@0.1.7:") + depends_on("libnl@3:") + depends_on("numactl@2:") + depends_on("lm-sensors") + + depends_on("oneapi-level-zero", when="+level_zero") + depends_on("cuda", when="+cuda") + depends_on("hip", when="+rocm") + + # required due to https://github.com/HewlettPackard/shs-libcxi/issues/4 + def patch(self): + filter_file( + r"/usr/share/cassini-headers/csr_defs.json", + f"{self.spec['cassini-headers'].prefix}/share/cassini-headers/csr_defs.json", + "utils/cxi_dump_csrs.py", + string=True, + ) + + @when("@main") + def autoreconf(self, spec, prefix): + sh = which("sh") + sh("autogen.sh") + + def setup_build_environment(self, env): + env.append_flags("CFLAGS", f"-I{self.spec['cassini-headers'].prefix.include}") + + def configure_args(self): + args = [ + f"--with-udevrulesdir={self.prefix}/lib/udev/rules.d", + f"--with-systemdsystemunitdir={self.prefix}/lib/systemd/system", + ] + + if self.spec.satisfies("+level_zero"): + args.append(f"--with-ze={self.spec['oneapi-level-zero'].prefix}") + if self.spec.satisfies("+cuda"): + args.append(f"--with-cuda={self.spec['cuda'].prefix}") + if self.spec.satisfies("+rocm"): + args.append(f"--with-rocm={self.spec['hip'].prefix}") + + return args diff --git a/var/spack/repos/builtin/packages/libfabric/package.py b/var/spack/repos/builtin/packages/libfabric/package.py index eef6a4d54f9..6312566beff 100644 --- a/var/spack/repos/builtin/packages/libfabric/package.py +++ b/var/spack/repos/builtin/packages/libfabric/package.py @@ -6,7 +6,6 @@ import os import re -import spack.platforms.cray from spack.package import * @@ -69,7 +68,7 @@ class Libfabric(AutotoolsPackage, CudaPackage): depends_on("c", type="build") # generated fabrics = ( - conditional("cxi", when=spack.platforms.cray.slingshot_network()), + "cxi", "efa", "gni", "mlx", @@ -90,9 +89,6 @@ class Libfabric(AutotoolsPackage, CudaPackage): "xpmem", ) - # CXI is a closed source package and only exists when an external. - conflicts("fabrics=cxi") - variant( "fabrics", default="sockets,tcp,udp", @@ -132,11 +128,14 @@ class Libfabric(AutotoolsPackage, CudaPackage): depends_on("numactl", when="fabrics=opx") depends_on("liburing@2.1:", when="+uring") depends_on("oneapi-level-zero", when="+level_zero") + depends_on("libcxi", when="fabrics=cxi") depends_on("m4", when="@main", type="build") depends_on("autoconf", when="@main", type="build") depends_on("automake", when="@main", type="build") depends_on("libtool", when="@main", type="build") + depends_on("json-c", when="fabrics=cxi") + depends_on("curl", when="fabrics=cxi") conflicts("@1.9.0", when="platform=darwin", msg="This distribution is missing critical files") conflicts("fabrics=opx", when="@:1.14.99") @@ -209,6 +208,13 @@ def configure_args(self): else: args.append(f"--disable-{fabric}") + if self.spec.satisfies("fabrics=cxi"): + args.append(f"--with-json-c={self.spec['json-c'].prefix}") + args.append(f"--with-curl={self.spec['curl'].prefix}") + args.append(f"--with-cassini-headers={self.spec['cassini-headers'].prefix.include}") + args.append(f"--with-cxi-uapi-headers={self.spec['cxi-driver'].prefix.include}") + args.append(f"--enable-cxi={self.spec['libcxi'].prefix}") + return args def installcheck(self):