From 2c20fa9c8fc239c0657b7b02bd52a76b8980540d Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Fri, 7 Jun 2024 10:32:45 +0000 Subject: [PATCH 1/3] arch: Implement Device.numa_domains --- devito/arch/archinfo.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/devito/arch/archinfo.py b/devito/arch/archinfo.py index ce17ecfc13..db1b329ed3 100644 --- a/devito/arch/archinfo.py +++ b/devito/arch/archinfo.py @@ -804,9 +804,13 @@ def _mro(cls): def march(self): return None - @property + @cached_property def numa_domains(self): - raise NotImplementedError + info = get_gpu_info() + try: + return info['ncards'] + except KeyError: + return None @cached_property def memtotal(self): From 50e71f3934ccf6b89c04a22ae311deff0fdfb184 Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Fri, 7 Jun 2024 10:32:58 +0000 Subject: [PATCH 2/3] tests: Prove that cloudpickle can handle dynamic classes --- tests/test_pickle.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_pickle.py b/tests/test_pickle.py index 68d593e058..9b7a639a32 100644 --- a/tests/test_pickle.py +++ b/tests/test_pickle.py @@ -476,6 +476,29 @@ def test_receiver(self, pickle): assert np.all(new_rec.coordinates.data == [[0.], [1.], [2.]]) +class TestAdvanced: + + def test_foreign(self): + MySparseFunction = type('MySparseFunction', (SparseFunction,), {'attr': 42}) + + grid = Grid(shape=(3,)) + + msf = MySparseFunction(name='msf', grid=grid, npoint=3, space_order=2, + coordinates=[(0.,), (1.,), (2.,)]) + + # Plain `pickle` doesn't support pickling of dynamic classes + with pytest.raises(Exception): + pickle0.dumps(msf) + + # But `cloudpickle` does + pkl_msf = pickle1.dumps(msf) + new_msf = pickle1.loads(pkl_msf) + + assert new_msf.attr == 42 + assert new_msf.name == 'msf' + assert new_msf.npoint == 3 + + @pytest.mark.parametrize('pickle', [pickle0, pickle1]) class TestOperator: From 9c40360dd5864c9f5ced24836057abc421d40f69 Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Fri, 7 Jun 2024 11:00:30 +0000 Subject: [PATCH 3/3] tests: Tweak decoupler marker to run under mpirun --- conftest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conftest.py b/conftest.py index 81d143eb7a..f14d595f78 100644 --- a/conftest.py +++ b/conftest.py @@ -174,8 +174,7 @@ def parallel(item, m): testname = get_testname(item) # Only spew tracebacks on rank 0. # Run xfailing tests to ensure that errors are reported to calling process - args = ["-n", "1", pyversion, "-m", "pytest", "--no-summary", "-s", - "--runxfail", "-qq", testname] + args = ["-n", "1", pyversion, "-m", "pytest", "-s", "--runxfail", "-qq", testname] if nprocs > 1: args.extend([":", "-n", "%d" % (nprocs - 1), pyversion, "-m", "pytest", "-s", "--runxfail", "--tb=no", "-qq", "--no-summary", testname]) @@ -203,7 +202,8 @@ def decoupler(item, m): testname = get_testname(item) pyversion = sys.executable - call = [pyversion, "-m", "pytest", "--no-summary", "-s", "--runxfail", testname] + args = ["-n", "1", pyversion, "-m", "pytest", "-s", "--runxfail", testname] + call = [mpi_exec] + args return set_run_reset(env_vars, call)