1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Sun, 5 Jan 2020 18:53:47 +0100
Subject: Fix nprocs
Forwarded: not-needed
---
pysph/parallel/tests/test_parallel.py | 12 ++++++++----
pysph/parallel/tests/test_parallel_run.py | 7 +++++--
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/pysph/parallel/tests/test_parallel.py b/pysph/parallel/tests/test_parallel.py
index 8397f0a..9896f5d 100644
--- a/pysph/parallel/tests/test_parallel.py
+++ b/pysph/parallel/tests/test_parallel.py
@@ -10,6 +10,9 @@ from pysph.tools import run_parallel_script
path = run_parallel_script.get_directory(__file__)
+import os
+nprocs = int(os.environ.get('NPROCS', '1'))
+
class ParticleArrayTestCase(unittest.TestCase):
@classmethod
@@ -42,6 +45,7 @@ class ParticleArrayTestCase(unittest.TestCase):
)
+@unittest.skipIf(nprocs !=4, 'only works with 4 processes')
class ParticleArrayExchangeTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
@@ -69,7 +73,7 @@ class SummationDensityTestCase(unittest.TestCase):
@mark.parallel
def test_summation_density(self):
run_parallel_script.run(
- filename='summation_density.py', nprocs=4, path=path
+ filename='summation_density.py', nprocs=nprocs, path=path
)
@@ -88,14 +92,14 @@ class MPIReduceArrayTestCase(unittest.TestCase):
@mark.parallel
def test_mpi_reduce_array(self):
run_parallel_script.run(
- filename='reduce_array.py', nprocs=4, path=path
+ filename='reduce_array.py', nprocs=nprocs, path=path
)
@mark.parallel
def test_parallel_reduce(self):
args = ['--directory=%s' % self.root]
run_parallel_script.run(
- filename='simple_reduction.py', args=args, nprocs=4, path=path
+ filename='simple_reduction.py', args=args, nprocs=nprocs, path=path
)
@@ -108,7 +112,7 @@ class DumpLoadTestCase(unittest.TestCase):
@mark.parallel
def test_dump_and_load_work_in_parallel(self):
run_parallel_script.run(
- filename='check_dump_load.py', nprocs=4, path=path
+ filename='check_dump_load.py', nprocs=nprocs, path=path
)
diff --git a/pysph/parallel/tests/test_parallel_run.py b/pysph/parallel/tests/test_parallel_run.py
index a39bd58..efbb7e9 100644
--- a/pysph/parallel/tests/test_parallel_run.py
+++ b/pysph/parallel/tests/test_parallel_run.py
@@ -11,6 +11,9 @@ from pytest import mark, importorskip
from pysph.tools import run_parallel_script
from pysph.parallel.tests.example_test_case import ExampleTestCase, get_example_script
+import os
+nprocs = int(os.environ.get('NPROCS', '1'))
+
class ParallelTests(ExampleTestCase):
@@ -28,7 +31,7 @@ class ParallelTests(ExampleTestCase):
extra_parallel_kwargs = dict(ghost_layers=1, lb_freq=5)
self.run_example(
get_example_script('sphysics/dambreak_sphysics.py'),
- nprocs=4, atol=1e-12,
+ nprocs=nprocs, atol=1e-12,
serial_kwargs=serial_kwargs,
extra_parallel_kwargs=extra_parallel_kwargs
)
@@ -50,7 +53,7 @@ class ParallelTests(ExampleTestCase):
serial_kwargs = dict(max_steps=max_steps, pfreq=500, sort_gids=None)
extra_parallel_kwargs = dict(ghost_layers=2, lb_freq=5)
self.run_example(
- 'cavity.py', nprocs=4, atol=1e-14, serial_kwargs=serial_kwargs,
+ 'cavity.py', nprocs=nprocs, atol=1e-14, serial_kwargs=serial_kwargs,
extra_parallel_kwargs=extra_parallel_kwargs
)
|