eztrace: multiple build systems (#44855)

This commit is contained in:
Harmen Stoppels 2024-06-26 06:12:02 +02:00 committed by GitHub
parent 4d604c8c9f
commit e6a8eba72d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,17 +3,17 @@
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.build_systems import autotools, cmake
from spack.package import * from spack.package import *
class Eztrace(Package): class Eztrace(CMakePackage, AutotoolsPackage, CudaPackage):
"""EZTrace is a tool to automatically generate execution traces """EZTrace is a tool to automatically generate execution traces of HPC applications."""
of HPC applications."""
homepage = "https://gitlab.com/eztrace" homepage = "https://gitlab.com/eztrace"
maintainers("trahay")
git = "https://gitlab.com/eztrace/eztrace.git" git = "https://gitlab.com/eztrace/eztrace.git"
maintainers("trahay")
license("CECILL-B") license("CECILL-B")
version("master", branch="master") version("master", branch="master")
@ -22,80 +22,46 @@ class Eztrace(Package):
version("1.1-13", sha256="6144d04fb62b3ccad41af0268cd921161f168d0cca3f6c210c448bb0b07be7e0") version("1.1-13", sha256="6144d04fb62b3ccad41af0268cd921161f168d0cca3f6c210c448bb0b07be7e0")
version("1.1-10", sha256="63d1af2db38b04efa817614574f381e7536e12db06a2c75375d1795adda3d1d8") version("1.1-10", sha256="63d1af2db38b04efa817614574f381e7536e12db06a2c75375d1795adda3d1d8")
# dependencies for eztrace 1.x and 2.x variant("starpu", default=False, description="Enable StarPU support", when="@2.1:")
variant("netcdf", default=False, description="Enable NetCDF support", when="@2.1:")
variant("pnetcdf", default=False, description="Enable PNetCDF support", when="@2.1:")
build_system(
conditional("cmake", when="@2:"), conditional("autotools", when="@:1"), default="cmake"
)
depends_on("mpi") depends_on("mpi")
depends_on("opari2") depends_on("opari2")
depends_on("binutils") depends_on("binutils")
depends_on("otf2", when="@2:")
with when("build_system=autotools"):
depends_on("autoconf", type="build")
depends_on("automake", type="build")
depends_on("libtool", type="build")
with when("build_system=cmake"):
depends_on("cmake@3.1:", type="build")
depends_on("starpu", when="+starpu")
depends_on("cuda", when="+cuda")
depends_on("netcdf-c", when="+netcdf")
depends_on("parallel-netcdf", when="+pnetcdf")
patch(
"https://gitlab.com/eztrace/eztrace/-/commit/3aafa74b12bc2c7e0687f2dbcfc35a699487eb10.diff",
sha256="45321b0fd15db84840280c34a91ab877d0ceec6eb825f699f08a7bd135be3d79",
when="@:1",
)
# eztrace 1.x dependencies
depends_on("autoconf@2.71", type="build", when="@:1")
depends_on("automake", type="build", when="@:1")
depends_on("libtool", type="build", when="@:1")
# Does not work on Darwin due to MAP_POPULATE # Does not work on Darwin due to MAP_POPULATE
conflicts("platform=darwin", when="@:1") conflicts("platform=darwin", when="@:1")
# eztrace 2.x dependencies # CUDA support from 2.1
depends_on("cmake@3.1:", type="build", when="@2.0:") conflicts("+cuda", when="@:2.0")
depends_on("otf2", when="@2.0:")
variant("starpu", default=False, description="Enable StarPU support", when="@2.1:")
depends_on("starpu", when="@2.1:+starpu")
variant("cuda", default=False, description="Enable CUDA support", when="@2.1:")
depends_on("cuda", when="@2.1:+cuda")
variant("netcdf", default=False, description="Enable NetCDF support", when="@2.1:")
depends_on("netcdf-c", when="@2.1:+netcdf")
variant("pnetcdf", default=False, description="Enable PNetCDF support", when="@2.1:")
depends_on("parallel-netcdf", when="@2.1:+pnetcdf")
def url_for_version(self, version): def url_for_version(self, version):
url = "https://gitlab.com/eztrace/eztrace/-/archive/{0}/eztrace-{1}.tar.gz" return f"https://gitlab.com/eztrace/eztrace/-/archive/{version}/eztrace-{version}.tar.gz"
return url.format(version, version)
@when("@2.0:")
def install(self, spec, prefix):
# Since eztrace 2.0, the build system uses CMake
spec = self.spec
args = [
"-DCMAKE_INSTALL_PREFIX=$prefix",
"-DEZTRACE_ENABLE_MEMORY=ON",
"-DEZTRACE_ENABLE_MPI=ON",
"-DEZTRACE_ENABLE_OPENMP=ON",
"-DEZTRACE_ENABLE_POSIXIO=ON",
"-DEZTRACE_ENABLE_PTHREAD=ON",
"-DOTF2_INCLUDE_PATH=%s" % spec["otf2"].prefix.include,
"-DOTF2_LIBRARY_PATH=%s" % spec["otf2"].libs,
]
if spec.satisfies("@2.1:"):
if spec.satisfies("%llvm-openmp-ompt"):
args.extend(["-DEZTRACE_ENABLE_OMPT=ON"])
if "+starpu" in spec:
args.extend(["-DEZTRACE_ENABLE_STARPU=ON"])
if "+cuda" in spec:
args.extend(["-DEZTRACE_ENABLE_CUDA=ON"])
if "+netcdf" in spec:
args.extend(["-DEZTRACE_ENABLE_NETCDF=ON"])
if "+pnetcdf" in spec:
args.extend(["-DEZTRACE_ENABLE_PNETCDF=ON"])
args.extend(std_cmake_args)
with working_dir("spack-build", create=True):
cmake("..", *args)
make()
make("install")
# Until eztrace 2.0, the build system uses autoconf
@when("@:1")
def install(self, spec, prefix):
if self.spec.satisfies("%fj"):
env.set("LDFLAGS", "--linkfortran")
self.patch()
which("bash")("bootstrap")
configure("--prefix=" + prefix, "--with-mpi={0}".format(self.spec["mpi"].prefix))
self.fix_libtool()
make()
make("install")
@when("@:1") @when("@:1")
def patch(self): def patch(self):
@ -106,9 +72,40 @@ def patch(self):
string=True, string=True,
) )
@when("@:1")
def fix_libtool(self): class CMakeBuilder(cmake.CMakeBuilder):
if self.spec.satisfies("%fj"): def cmake_args(self):
libtools = ["extlib/gtg/libtool", "extlib/opari2/build-frontend/libtool"] spec = self.spec
for f in libtools: args = [
filter_file('wl=""', 'wl="-Wl,"', f, string=True) self.define("EZTRACE_ENABLE_MEMORY", True),
self.define("EZTRACE_ENABLE_MPI", True),
self.define("EZTRACE_ENABLE_OPENMP", True),
self.define("EZTRACE_ENABLE_POSIXIO", True),
self.define("EZTRACE_ENABLE_PTHREAD", True),
self.define("OTF2_INCLUDE_PATH", spec["otf2"].prefix.include),
self.define("OTF2_LIBRARY_PATH", spec["otf2"].libs),
]
if spec.satisfies("@2.1: %llvm-openmp-ompt"):
args.append(self.define("EZTRACE_ENABLE_OMPT", True))
if "+starpu" in spec:
args.append(self.define("EZTRACE_ENABLE_STARPU", True))
if "+cuda" in spec:
args.append(self.define("EZTRACE_ENABLE_CUDA", True))
if "+netcdf" in spec:
args.append(self.define("EZTRACE_ENABLE_NETCDF", True))
if "+pnetcdf" in spec:
args.append(self.define("EZTRACE_ENABLE_PNETCDF", True))
return args
class AutotoolsBuilder(autotools.AutotoolsBuilder):
def setup_build_environment(self, env):
env.set("LDFLAGS", "--linkfortran")
def autoreconf(self, pkg, spec, prefix):
Executable("/bin/sh")("./bootstrap")
def configure_args(self):
return [f"--with-mpi={self.spec['mpi'].prefix}"]