magma: old to new test API (#45140)
* magma: old to new test API * magma: simplify stand-alone test method/part docstrings/purposes --------- Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
This commit is contained in:
parent
dd53eeb322
commit
4606c8ed68
@ -84,7 +84,7 @@ class Magma(CMakePackage, CudaPackage, ROCmPackage):
|
|||||||
|
|
||||||
# Many cuda_arch values are not yet recognized by MAGMA's CMakeLists.txt
|
# Many cuda_arch values are not yet recognized by MAGMA's CMakeLists.txt
|
||||||
for target in [10, 11, 12, 13, 21, 32, 52, 53, 61, 62, 72, 86]:
|
for target in [10, 11, 12, 13, 21, 32, 52, 53, 61, 62, 72, 86]:
|
||||||
conflicts("cuda_arch={}".format(target))
|
conflicts(f"cuda_arch={target}")
|
||||||
|
|
||||||
# Some cuda_arch values had support added recently
|
# Some cuda_arch values had support added recently
|
||||||
conflicts("cuda_arch=37", when="@:2.5", msg="magma: cuda_arch=37 needs a version > 2.5")
|
conflicts("cuda_arch=37", when="@:2.5", msg="magma: cuda_arch=37 needs a version > 2.5")
|
||||||
@ -117,14 +117,14 @@ def generate_gpu_config(self):
|
|||||||
gpu_target = ""
|
gpu_target = ""
|
||||||
if "+cuda" in spec:
|
if "+cuda" in spec:
|
||||||
cuda_archs = spec.variants["cuda_arch"].value
|
cuda_archs = spec.variants["cuda_arch"].value
|
||||||
gpu_target = " ".join("sm_{0}".format(i) for i in cuda_archs)
|
gpu_target = " ".join(f"sm_{i}" for i in cuda_archs)
|
||||||
else:
|
else:
|
||||||
gpu_target = spec.variants["amdgpu_target"].value
|
gpu_target = spec.variants["amdgpu_target"].value
|
||||||
|
|
||||||
with open("make.inc", "w") as inc:
|
with open("make.inc", "w") as inc:
|
||||||
inc.write("FORT = true\n")
|
inc.write("FORT = true\n")
|
||||||
inc.write("GPU_TARGET = {0}\n".format(gpu_target))
|
inc.write(f"GPU_TARGET = {gpu_target}\n")
|
||||||
inc.write("BACKEND = {0}\n".format(backend))
|
inc.write(f"BACKEND = {backend}\n")
|
||||||
|
|
||||||
make("generate")
|
make("generate")
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ def cmake_args(self):
|
|||||||
if "+cuda" in spec:
|
if "+cuda" in spec:
|
||||||
cuda_arch = spec.variants["cuda_arch"].value
|
cuda_arch = spec.variants["cuda_arch"].value
|
||||||
sep = "" if "@:2.2.0" in spec else "_"
|
sep = "" if "@:2.2.0" in spec else "_"
|
||||||
capabilities = " ".join("sm{0}{1}".format(sep, i) for i in cuda_arch)
|
capabilities = " ".join(f"sm{sep}{i}" for i in cuda_arch)
|
||||||
options.append(define("GPU_TARGET", capabilities))
|
options.append(define("GPU_TARGET", capabilities))
|
||||||
archs = ";".join("%s" % i for i in cuda_arch)
|
archs = ";".join("%s" % i for i in cuda_arch)
|
||||||
options.append(define("CMAKE_CUDA_ARCHITECTURES", archs))
|
options.append(define("CMAKE_CUDA_ARCHITECTURES", archs))
|
||||||
@ -191,21 +191,40 @@ def post_install(self):
|
|||||||
def cache_test_sources(self):
|
def cache_test_sources(self):
|
||||||
"""Copy the example source files after the package is installed to an
|
"""Copy the example source files after the package is installed to an
|
||||||
install test subdirectory for use during `spack test run`."""
|
install test subdirectory for use during `spack test run`."""
|
||||||
self.cache_extra_test_sources([self.test_src_dir])
|
cache_extra_test_sources(self, [self.test_src_dir])
|
||||||
|
|
||||||
def test(self):
|
def test_c(self):
|
||||||
|
"""Run C examples"""
|
||||||
test_dir = join_path(self.test_suite.current_test_cache_dir, self.test_src_dir)
|
test_dir = join_path(self.test_suite.current_test_cache_dir, self.test_src_dir)
|
||||||
with working_dir(test_dir, create=False):
|
with working_dir(test_dir):
|
||||||
pkg_config_path = "{0}/lib/pkgconfig".format(self.prefix)
|
pkg_config_path = self.prefix.lib.pkgconfig
|
||||||
with spack.util.environment.set_env(PKG_CONFIG_PATH=pkg_config_path):
|
with spack.util.environment.set_env(PKG_CONFIG_PATH=pkg_config_path):
|
||||||
|
|
||||||
make("c")
|
make("c")
|
||||||
self.run_test("./example_sparse", purpose="MAGMA smoke test - sparse solver")
|
tests = [
|
||||||
self.run_test(
|
("example_sparse", "sparse solver"),
|
||||||
"./example_sparse_operator", purpose="MAGMA smoke test - sparse operator"
|
("example_sparse_operator", "sparse operator"),
|
||||||
)
|
("example_v1", "legacy v1 interface"),
|
||||||
self.run_test("./example_v1", purpose="MAGMA smoke test - legacy v1 interface")
|
("example_v2", "v2 interface"),
|
||||||
self.run_test("./example_v2", purpose="MAGMA smoke test - v2 interface")
|
]
|
||||||
if "+fortran" in self.spec:
|
|
||||||
make("fortran")
|
for test, desc in tests:
|
||||||
self.run_test("./example_f", purpose="MAGMA smoke test - Fortran interface")
|
with test_part(self, f"test_c_{test}", purpose=f"Run {desc} example"):
|
||||||
|
exe = which(test)
|
||||||
|
exe()
|
||||||
|
|
||||||
|
make("clean")
|
||||||
|
|
||||||
|
def test_fortran(self):
|
||||||
|
"""Run Fortran example"""
|
||||||
|
if "+fortran" not in self.spec:
|
||||||
|
raise SkipTest("Package must be installed with +fortran")
|
||||||
|
|
||||||
|
test_dir = join_path(self.test_suite.current_test_cache_dir, self.test_src_dir)
|
||||||
|
with working_dir(test_dir):
|
||||||
|
pkg_config_path = self.prefix.lib.pkgconfig
|
||||||
|
with spack.util.environment.set_env(PKG_CONFIG_PATH=pkg_config_path):
|
||||||
|
make("fortran")
|
||||||
|
example_f = which("example_f")
|
||||||
|
example_f()
|
||||||
make("clean")
|
make("clean")
|
||||||
|
Loading…
Reference in New Issue
Block a user