summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/mpich/package.py
diff options
context:
space:
mode:
Diffstat (limited to 'var/spack/repos/builtin/packages/mpich/package.py')
-rw-r--r--var/spack/repos/builtin/packages/mpich/package.py62
1 files changed, 41 insertions, 21 deletions
diff --git a/var/spack/repos/builtin/packages/mpich/package.py b/var/spack/repos/builtin/packages/mpich/package.py
index 581f4d0d31..e07b7c4759 100644
--- a/var/spack/repos/builtin/packages/mpich/package.py
+++ b/var/spack/repos/builtin/packages/mpich/package.py
@@ -600,27 +600,47 @@ with '-Wl,-commons,use_dylibs' and without
install test subdirectory for use during `spack test run`."""
self.cache_extra_test_sources(["examples", join_path("test", "mpi")])
- def run_mpich_test(self, example_dir, exe):
- """Run stand alone tests"""
-
- test_dir = join_path(self.test_suite.current_test_cache_dir, example_dir)
- exe_source = join_path(test_dir, "{0}.c".format(exe))
-
- if not os.path.isfile(exe_source):
- print("Skipping {0} test".format(exe))
- return
+ def mpi_launcher(self):
+ """Determine the appropriate launcher."""
+ commands = [
+ join_path(self.spec.prefix.bin, "mpirun"),
+ join_path(self.spec.prefix.bin, "mpiexec"),
+ ]
+ if "+slurm" in self.spec:
+ commands.insert(0, join_path(self.spec["slurm"].prefix.bin))
+ return which(*commands)
+
+ def run_mpich_test(self, subdir, exe, num_procs=1):
+ """Compile and run the test program."""
+ path = self.test_suite.current_test_cache_dir.join(subdir)
+ with working_dir(path):
+ src = f"{exe}.c"
+ if not os.path.isfile(src):
+ raise SkipTest(f"{src} is missing")
+
+ mpicc = which(os.environ["MPICC"])
+ mpicc("-Wall", "-g", "-o", exe, src)
+ if num_procs > 1:
+ launcher = self.mpi_launcher()
+ if launcher is not None:
+ launcher("-n", str(num_procs), exe)
+ return
+
+ test_exe = which(exe)
+ test_exe()
+
+ def test_cpi(self):
+ """build and run cpi"""
+ self.run_mpich_test("examples", "cpi")
- self.run_test(
- self.prefix.bin.mpicc,
- options=[exe_source, "-Wall", "-g", "-o", exe],
- purpose="test: generate {0} file".format(exe),
- work_dir=test_dir,
- )
+ def test_finalized(self):
+ """build and run finalized"""
+ self.run_mpich_test(join_path("test", "mpi", "init"), "finalized")
- self.run_test(exe, purpose="test: run {0} example".format(exe), work_dir=test_dir)
+ def test_manyrma(self):
+ """build and run manyrma"""
+ self.run_mpich_test(join_path("test", "mpi", "perf"), "manyrma", 2)
- def test(self):
- self.run_mpich_test(join_path("test", "mpi", "init"), "finalized")
- self.run_mpich_test(join_path("test", "mpi", "basic"), "sendrecv")
- self.run_mpich_test(join_path("test", "mpi", "perf"), "manyrma")
- self.run_mpich_test("examples", "cpi")
+ def test_sendrecv(self):
+ """build and run sendrecv"""
+ self.run_mpich_test(join_path("test", "mpi", "basic"), "sendrecv", 2)