diff options
author | AcriusWinter <152348900+AcriusWinter@users.noreply.github.com> | 2024-08-11 01:28:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-11 02:28:25 -0600 |
commit | 990e0dc52629d2c38b8b36317c51a4a7e9a4d845 (patch) | |
tree | fe9e97537d90c58d02787932b9b9d115d93f6271 | |
parent | f9d8b6b5aa59fc1e6895943227f809c99277b902 (diff) | |
download | spack-990e0dc52629d2c38b8b36317c51a4a7e9a4d845.tar.gz spack-990e0dc52629d2c38b8b36317c51a4a7e9a4d845.tar.bz2 spack-990e0dc52629d2c38b8b36317c51a4a7e9a4d845.tar.xz spack-990e0dc52629d2c38b8b36317c51a4a7e9a4d845.zip |
hypre: old to new test API (#45066)
* hypre: old to new test API
* hypre: restore test_parts; add Makefile cleanup
---------
Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov>
-rw-r--r-- | var/spack/repos/builtin/packages/hypre/package.py | 76 |
1 files changed, 35 insertions, 41 deletions
diff --git a/var/spack/repos/builtin/packages/hypre/package.py b/var/spack/repos/builtin/packages/hypre/package.py index 86ff57b274..9b908b4465 100644 --- a/var/spack/repos/builtin/packages/hypre/package.py +++ b/var/spack/repos/builtin/packages/hypre/package.py @@ -139,17 +139,11 @@ class Hypre(AutotoolsPackage, CudaPackage, ROCmPackage): gpu_pkgs = ["magma", "umpire"] for sm_ in CudaPackage.cuda_arch_values: for pkg in gpu_pkgs: - depends_on( - "{0}+cuda cuda_arch={1}".format(pkg, sm_), - when="+{0}+cuda cuda_arch={1}".format(pkg, sm_), - ) + depends_on(f"{pkg}+cuda cuda_arch={sm_}", when=f"+{pkg}+cuda cuda_arch={sm_}") for gfx in ROCmPackage.amdgpu_targets: for pkg in gpu_pkgs: - depends_on( - "{0}+rocm amdgpu_target={1}".format(pkg, gfx), - when="+{0}+rocm amdgpu_target={1}".format(pkg, gfx), - ) + depends_on(f"{pkg}+rocm amdgpu_target={gfx}", when=f"+{pkg}+rocm amdgpu_target={gfx}") # hypre@:2.28.0 uses deprecated cuSPARSE functions/types (e.g. csrsv2Info_t). depends_on("cuda@:11", when="@:2.28.0+cuda") @@ -193,11 +187,13 @@ class Hypre(AutotoolsPackage, CudaPackage, ROCmPackage): def url_for_version(self, version): if version >= Version("2.12.0"): - url = "https://github.com/hypre-space/hypre/archive/v{0}.tar.gz" + url = f"https://github.com/hypre-space/hypre/archive/v{version}.tar.gz" else: - url = "http://computing.llnl.gov/project/linear_solvers/download/hypre-{0}.tar.gz" + url = ( + f"http://computing.llnl.gov/project/linear_solvers/download/hypre-{version}.tar.gz" + ) - return url.format(version) + return url def configure_args(self): spec = self.spec @@ -220,8 +216,8 @@ class Hypre(AutotoolsPackage, CudaPackage, ROCmPackage): os.environ["F77"] = spec["mpi"].mpif77 os.environ["FC"] = spec["mpi"].mpifc configure_args.append("--with-MPI") - configure_args.append("--with-MPI-lib-dirs={0}".format(spec["mpi"].prefix.lib)) - configure_args.append("--with-MPI-include={0}".format(spec["mpi"].prefix.include)) + configure_args.append(f"--with-MPI-lib-dirs={spec['mpi'].prefix.lib}") + configure_args.append(f"--with-MPI-include={spec['mpi'].prefix.include}") else: configure_args.append("--without-MPI") @@ -278,11 +274,11 @@ class Hypre(AutotoolsPackage, CudaPackage, ROCmPackage): if cuda_arch_vals: cuda_arch_sorted = list(sorted(cuda_arch_vals, reverse=True)) cuda_arch = cuda_arch_sorted[0] - configure_args.append("--with-gpu-arch={0}".format(cuda_arch)) + configure_args.append(f"--with-gpu-arch={cuda_arch}") # New in 2.21.0: replaces --enable-cub if spec.satisfies("@2.21.0:"): configure_args.append("--enable-device-memory-pool") - configure_args.append("--with-cuda-home={0}".format(spec["cuda"].prefix)) + configure_args.append(f"--with-cuda-home={spec['cuda'].prefix}") else: configure_args.append("--enable-cub") if spec.satisfies("+cublas"): @@ -304,14 +300,14 @@ class Hypre(AutotoolsPackage, CudaPackage, ROCmPackage): "--with-hip", "--enable-rocrand", "--enable-rocsparse", - "--with-extra-CUFLAGS={0}".format(rocm_inc), + f"--with-extra-CUFLAGS={rocm_inc}", ] ) rocm_arch_vals = spec.variants["amdgpu_target"].value if rocm_arch_vals: rocm_arch_sorted = list(sorted(rocm_arch_vals, reverse=True)) rocm_arch = rocm_arch_sorted[0] - configure_args.append("--with-gpu-arch={0}".format(rocm_arch)) + configure_args.append(f"--with-gpu-arch={rocm_arch}") if spec.satisfies("+rocblas"): configure_args.append("--enable-rocblas") else: @@ -387,36 +383,34 @@ class Hypre(AutotoolsPackage, CudaPackage, ROCmPackage): def cache_test_sources(self): cache_extra_test_sources(self, self.extra_install_tests) + # Customize the makefile to use the installed package + makefile = join_path(install_test_root(self), self.extra_install_tests, "Makefile") + filter_file(r"^HYPRE_DIR\s* =.*", f"HYPRE_DIR = {self.prefix}", makefile) + filter_file(r"^CC\s*=.*", f"CC = {os.environ['CC']}", makefile) + filter_file(r"^F77\s*=.*", f"F77 = {os.environ['F77']}", makefile) + filter_file(r"^CXX\s*=.*", f"CXX = {os.environ['CXX']}", makefile) + @property def _cached_tests_work_dir(self): """The working directory for cached test sources.""" return join_path(self.test_suite.current_test_cache_dir, self.extra_install_tests) - def test(self): - """Perform smoke test on installed HYPRE package.""" + def test_bigint(self): + """build and run bigint tests""" if "+mpi" not in self.spec: - print("Skipping: HYPRE must be installed with +mpi to run tests") - return - - # Build copied and cached test examples - self.run_test( - "make", - ["HYPRE_DIR={0}".format(self.prefix), "bigint"], - purpose="test: building selected examples", - work_dir=self._cached_tests_work_dir, - ) - - # Run the examples built above - for exe in ["./ex5big", "./ex15big"]: - self.run_test( - exe, - [], - [], - installed=False, - purpose="test: ensuring {0} runs".format(exe), - skip_missing=True, - work_dir=self._cached_tests_work_dir, - ) + raise SkipTest("Package must be installed with +mpi") + + # build and run cached examples + with working_dir(self._cached_tests_work_dir): + make = which("make") + make("bigint") + + for name in ["ex5big", "ex15big"]: + with test_part(self, f"test_bigint_{name}", f"ensure {name} runs"): + exe = which(name) + if exe is None: + raise SkipTest(f"{name} does not exist in version {self.version}") + exe() @property def headers(self): |