tests/petsc: convert to new stand-alone test process (#38652)
This commit is contained in:
parent
131acbdacc
commit
4286c7398b
1 changed files with 78 additions and 45 deletions
|
@ -625,24 +625,36 @@ def headers(self):
|
||||||
def setup_build_tests(self):
|
def setup_build_tests(self):
|
||||||
"""Copy the build test files after the package is installed to an
|
"""Copy the build test 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`."""
|
||||||
if self.spec.satisfies("@3.13:"):
|
if not self.spec.satisfies("@3.13:"):
|
||||||
self.cache_extra_test_sources("src/ksp/ksp/tutorials")
|
tty.warn("Stand-alone tests only available for v3.13:")
|
||||||
self.cache_extra_test_sources("src/snes/tutorials")
|
return
|
||||||
|
|
||||||
def test(self):
|
self.cache_extra_test_sources(
|
||||||
# solve Poisson equation in 2D to make sure nothing is broken:
|
[join_path("src", "ksp", "ksp", "tutorials"), join_path("src", "snes", "tutorials")]
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_runner(self):
|
||||||
|
"""Set key environment variables and return runner and options."""
|
||||||
spec = self.spec
|
spec = self.spec
|
||||||
env["PETSC_DIR"] = self.prefix
|
env["PETSC_DIR"] = self.prefix
|
||||||
env["PETSC_ARCH"] = ""
|
env["PETSC_ARCH"] = ""
|
||||||
if "+mpi" in spec:
|
if "+mpi" in spec:
|
||||||
runexe = Executable(join_path(spec["mpi"].prefix.bin, "mpiexec")).command
|
runexe = which(spec["mpi"].prefix.bin.mpiexec)
|
||||||
runopt = ["-n", "4"]
|
runopt = ["-n", "4"]
|
||||||
else:
|
else:
|
||||||
runexe = Executable(join_path(self.prefix, "lib/petsc/bin/petsc-mpiexec.uni")).command
|
runexe = which(join_path(self.prefix.lib.petsc.bin, "petsc-mpiexec.uni"))
|
||||||
runopt = ["-n", "1"]
|
runopt = ["-n", "1"]
|
||||||
w_dir = join_path(self.install_test_root, "src/ksp/ksp/tutorials")
|
return runexe, runopt
|
||||||
|
|
||||||
|
def test_ex50(self):
|
||||||
|
"""build and run ex50 to solve Poisson equation in 2D"""
|
||||||
|
# solve Poisson equation in 2D to make sure nothing is broken:
|
||||||
|
make = which("make")
|
||||||
|
runexe, runopts = self.get_runner()
|
||||||
|
|
||||||
|
w_dir = self.test_suite.current_test_cache_dir.src.ksp.ksp.tutorials
|
||||||
with working_dir(w_dir):
|
with working_dir(w_dir):
|
||||||
testexe = ["ex50", "-da_grid_x", "4", "-da_grid_y", "4"]
|
baseopts = ["ex50", "-da_grid_x", "4", "-da_grid_y", "4"]
|
||||||
testdict = {
|
testdict = {
|
||||||
None: [],
|
None: [],
|
||||||
"+superlu-dist": ["-pc_type", "lu", "-pc_factor_mat_solver_type", "superlu_dist"],
|
"+superlu-dist": ["-pc_type", "lu", "-pc_factor_mat_solver_type", "superlu_dist"],
|
||||||
|
@ -651,40 +663,61 @@ def test(self):
|
||||||
"+mkl-pardiso": ["-pc_type", "lu", "-pc_factor_mat_solver_type", "mkl_pardiso"],
|
"+mkl-pardiso": ["-pc_type", "lu", "-pc_factor_mat_solver_type", "mkl_pardiso"],
|
||||||
}
|
}
|
||||||
make("ex50", parallel=False)
|
make("ex50", parallel=False)
|
||||||
for feature, featureopt in testdict.items():
|
for feature, featureopts in testdict.items():
|
||||||
if not feature or feature in spec:
|
if not feature or feature in self.spec:
|
||||||
self.run_test(runexe, runopt + testexe + featureopt)
|
name = f"_{feature[1:]}" if feature else ""
|
||||||
if "+cuda" in spec:
|
options = runopts + baseopts + featureopts
|
||||||
make("ex7", parallel=False)
|
with test_part(self, f"test_ex50{name}", purpose=f"run {options}"):
|
||||||
testexe = [
|
runexe(*options)
|
||||||
"ex7",
|
|
||||||
"-mat_type",
|
def test_ex7(self):
|
||||||
"aijcusparse",
|
"""build and run ex7"""
|
||||||
"-sub_pc_factor_mat_solver_type",
|
if "+cuda" not in self.spec:
|
||||||
"cusparse",
|
raise SkipTest("Package must be built with +cuda")
|
||||||
"-sub_ksp_type",
|
|
||||||
"preonly",
|
make = which("make")
|
||||||
"-sub_pc_type",
|
runexe, runopts = self.get_runner()
|
||||||
"ilu",
|
|
||||||
"-use_gpu_aware_mpi",
|
w_dir = self.test_suite.current_test_cache_dir.src.ksp.ksp.tutorials
|
||||||
"0",
|
|
||||||
]
|
|
||||||
self.run_test(runexe, runopt + testexe)
|
|
||||||
make("clean", parallel=False)
|
|
||||||
w_dir = join_path(self.install_test_root, "src/snes/tutorials")
|
|
||||||
with working_dir(w_dir):
|
with working_dir(w_dir):
|
||||||
if "+kokkos" in spec:
|
make("ex7", parallel=False)
|
||||||
make("ex3k", parallel=False)
|
exeopts = [
|
||||||
testexe = [
|
"ex7",
|
||||||
"ex3k",
|
"-mat_type",
|
||||||
"-view_initial",
|
"aijcusparse",
|
||||||
"-dm_vec_type",
|
"-sub_pc_factor_mat_solver_type",
|
||||||
"kokkos",
|
"cusparse",
|
||||||
"-dm_mat_type",
|
"-sub_ksp_type",
|
||||||
"aijkokkos",
|
"preonly",
|
||||||
"-use_gpu_aware_mpi",
|
"-sub_pc_type",
|
||||||
"0",
|
"ilu",
|
||||||
"-snes_monitor",
|
"-use_gpu_aware_mpi",
|
||||||
]
|
"0",
|
||||||
self.run_test(runexe, runopt + testexe)
|
]
|
||||||
make("clean", parallel=False)
|
options = runopts + exeopts
|
||||||
|
runexe(*options)
|
||||||
|
|
||||||
|
def test_ex3k(self):
|
||||||
|
"""build and run ex3k"""
|
||||||
|
if "+kokkos" not in self.spec:
|
||||||
|
raise SkipTest("Package must be built with +kokkos")
|
||||||
|
|
||||||
|
make = which("make")
|
||||||
|
runexe, runopts = self.get_runner()
|
||||||
|
|
||||||
|
w_dir = self.test_suite.current_test_cache_dir.src.snes.tutorials
|
||||||
|
with working_dir(w_dir):
|
||||||
|
make("ex3k", parallel=False)
|
||||||
|
exeopts = [
|
||||||
|
"ex3k",
|
||||||
|
"-view_initial",
|
||||||
|
"-dm_vec_type",
|
||||||
|
"kokkos",
|
||||||
|
"-dm_mat_type",
|
||||||
|
"aijkokkos",
|
||||||
|
"-use_gpu_aware_mpi",
|
||||||
|
"0",
|
||||||
|
"-snes_monitor",
|
||||||
|
]
|
||||||
|
options = runopts + exeopts
|
||||||
|
runexe(*options)
|
||||||
|
|
Loading…
Reference in a new issue