tests/heffte/tasmanian: convert to new stand-alone test process (#35750)

This commit is contained in:
Tamara Dahlgren 2023-06-26 06:10:55 -07:00 committed by GitHub
parent 134dceb055
commit 8528106484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 119 deletions

View File

@ -3,10 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from llnl.util import tty
from spack.package import *
@ -130,68 +126,38 @@ def cmake_args(self):
return args
def cmake_bin(self, set_path=True):
"""(Hack) Set/get cmake dependency path. Sync with Tasmanian."""
filepath = join_path(self.install_test_root, "cmake_bin_path.txt")
if set_path:
with open(filepath, "w") as out_file:
cmake_bin = join_path(self.spec["cmake"].prefix.bin, "cmake")
out_file.write("{0}\n".format(cmake_bin))
elif os.path.isfile(filepath):
with open(filepath, "r") as in_file:
return in_file.read().strip()
@run_after("install")
def setup_smoke_test(self):
install_tree(
self.prefix.share.heffte.testing, join_path(self.install_test_root, "testing")
)
self.cmake_bin(set_path=True)
def test(self):
cmake_bin = self.cmake_bin(set_path=False)
if not cmake_bin:
tty.msg("Skipping heffte test: cmake_bin_path.txt not found")
return
def test_make_test(self):
"""build and run make(test)"""
# using the tests copied from <prefix>/share/heffte/testing
cmake_dir = self.test_suite.current_test_cache_dir.testing
options = [cmake_dir]
if "+rocm" in self.spec:
options.append(
"-Dhip_DIR=" + join_path(self.spec["hip"].prefix, "lib", "cmake", "hip")
)
options.append(
options.extend(
[
f"-Dhip_DIR={self.spec['hip'].prefix.lib.cmake.hip}",
"-DAMDDeviceLibs_DIR="
+ join_path(self.spec["llvm-amdgpu"].prefix, "lib", "cmake", "AMDDeviceLibs")
)
options.append(
"-Damd_comgr_DIR="
+ join_path(self.spec["comgr"].prefix, "lib", "cmake", "amd_comgr")
)
options.append(
+ f"{self.spec['llvm-amdgpu'].prefix.lib.cmake.AMDDeviceLibs}",
f"-Damd_comgr_DIR={self.spec['comgr'].prefix.lib.cmake.amd_comgr}",
"-Dhsa-runtime64_DIR="
+ join_path(self.spec["hsa-rocr-dev"].prefix, "lib", "cmake", "hsa-runtime64")
)
options.append(
"-DHSA_HEADER=" + join_path(self.spec["hsa-rocr-dev"].prefix, "include")
)
options.append(
"-Drocfft_DIR=" + join_path(self.spec["rocfft"].prefix, "lib", "cmake", "rocfft")
+ f"{self.spec['hsa-rocr-dev'].prefix.lib.cmake.hsa-runtime64}",
"-DHSA_HEADER={self.spec['hsa-rocr-dev'].prefix.include}",
"-Drocfft_DIR={self.spec['rocfft'].prefix.lib.cmake.rocfft}",
]
)
# Provide the path to the MPI dependency so that the test can find an MPI launcher
options.append("-DMPI_HOME=" + self.spec["mpi"].prefix)
# Provide the root directory of the MPI installation.
options.append(f"-DMPI_HOME={self.spec['mpi'].prefix}")
if not self.run_test(cmake_bin, options=options, purpose="Generate the Makefile"):
tty.msg("Skipping heffte test: failed to generate Makefile")
return
cmake = which(self.spec["cmake"].prefix.bin.cmake)
cmake(*options)
if not self.run_test("make", purpose="Build test software"):
tty.msg("Skipping heffte test: failed to build test")
return
if not self.run_test("make", options=["test"], purpose="Run test"):
tty.msg("Failed heffte test: failed to run test")
make = which("make")
make()
make("test")

View File

@ -3,10 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
from llnl.util import tty
from spack.package import *
@ -22,6 +18,8 @@ class Tasmanian(CMakePackage, CudaPackage, ROCmPackage):
tags = ["e4s"]
maintainers("mkstoyanov")
test_requires_compiler = True
version("develop", branch="master")
version("7.9", sha256="decba62e6bbccf1bc26c6e773a8d4fd51d7f3e3e534ddd386ec41300694ce5cc")
@ -175,85 +173,39 @@ def cmake_args(self):
return args
# TODO: Replace this method and its 'get' use for cmake path with
# join_path(self.spec['cmake'].prefix.bin, 'cmake') once stand-alone
# tests can access build dependencies through self.spec['cmake'].
def cmake_bin(self, set=True):
"""(Hack) Set/get cmake dependency path."""
filepath = join_path(self.install_test_root, "cmake_bin_path.txt")
if set:
with open(filepath, "w") as out_file:
cmake_bin = join_path(self.spec["cmake"].prefix.bin, "cmake")
out_file.write("{0}\n".format(cmake_bin))
elif os.path.isfile(filepath):
with open(filepath, "r") as in_file:
return in_file.read().strip()
@run_after("install")
def setup_smoke_test(self):
if not self.spec["cmake"].satisfies("@3.10:"):
tty.msg("Error tasmanian test: CMake 3.10 or higher is required")
return
install_tree(
self.prefix.share.Tasmanian.testing, join_path(self.install_test_root, "testing")
)
self.cmake_bin(set=True)
def test(self):
cmake_bin = self.cmake_bin(set=False)
if not cmake_bin:
tty.msg("Skipping tasmanian test: cmake_bin_path.txt not found")
return
def test_make_test(self):
"""build and run make(test)"""
# using the tests copied from <prefix>/share/Tasmanian/testing
cmake_dir = self.test_suite.current_test_cache_dir.testing
options = [cmake_dir]
if "+rocm" in self.spec:
options.append(
"-DAMDDeviceLibs_DIR="
+ join_path(self.spec["llvm-amdgpu"].prefix, "lib", "cmake", "AMDDeviceLibs")
f"-DAMDDeviceLibs_DIR={self.spec['llvm-amdgpu'].prefix.lib.cmake.AMDDeviceLibs}"
)
options.append(f"-Damd_comgr_DIR={self.spec['comgr'].prefix.lib.cmake.amd_comgr}")
options.append(
"-Damd_comgr_DIR="
+ join_path(self.spec["comgr"].prefix, "lib", "cmake", "amd_comgr")
)
options.append(
"-Dhsa-runtime64_DIR="
+ join_path(self.spec["hsa-rocr-dev"].prefix, "lib", "cmake", "hsa-runtime64")
)
options.append(
"-DHSA_HEADER=" + join_path(self.spec["hsa-rocr-dev"].prefix, "include")
)
options.append(
"-DCMAKE_INCLUDE_PATH="
+ join_path(self.spec["hsa-rocr-dev"].prefix, "include", "hsa")
)
options.append(
"-Drocblas_DIR="
+ join_path(self.spec["rocblas"].prefix, "lib", "cmake", "rocblas")
)
options.append(
"-Drocsparse_DIR="
+ join_path(self.spec["rocsparse"].prefix, "lib", "cmake", "rocsparse")
)
options.append(
"-Drocsolver_DIR="
+ join_path(self.spec["rocsolver"].prefix, "lib", "cmake", "rocsolver")
f"-Dhsa-runtime64_DIR={self.spec['hsa-rocr-dev'].prefix.lib.cmake.hsa-runtime64}"
)
options.append(f"-DHSA_HEADER={self.spec['hsa-rocr-dev'].prefix.include}")
options.append(f"-DCMAKE_INCLUDE_PATH={self.spec['hsa-rocr-dev'].prefix.include.hsa}")
options.append(f"-Drocblas_DIR={self.spec['rocblas'].prefix.lib.cmake.rocblas}")
options.append(f"-Drocsparse_DIR={self.spec['rocsparse'].prefix.lib.cmake.rocsparse}")
options.append(f"-Drocsolver_DIR={self.spec['rocsolver'].prefix.lib.cmake.rocsolver}")
if "+mpi" in self.spec:
options.append("-DMPI_HOME=" + self.spec["mpi"].prefix)
if not self.run_test(cmake_bin, options=options, purpose="Generate the Makefile"):
tty.msg("Skipping tasmanian test: failed to generate Makefile")
return
cmake = which(self.spec["cmake"].prefix.bin.cmake)
cmake(*options)
if not self.run_test("make", purpose="Build test software"):
tty.msg("Skipping tasmanian test: failed to build test")
return
make = which("make")
make()
if not self.run_test("make", options=["test"], purpose="Run test"):
tty.msg("Failed tasmanian test: failed to run test")
make("test")