From 539544a037d66d9ae5f1a8301131a20be42fa556 Mon Sep 17 00:00:00 2001 From: mloubout Date: Fri, 11 Aug 2023 08:47:43 -0400 Subject: [PATCH] misc: fix openmp= deprecation --- tests/test_autotuner.py | 12 ++++++------ tests/test_builtins.py | 4 ++-- tests/test_dimension.py | 4 ++-- tests/test_dle.py | 2 +- tests/test_dse.py | 12 ++++++------ tests/test_operator.py | 12 ++++++------ tests/test_pickle.py | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/test_autotuner.py b/tests/test_autotuner.py index 57cc516812..90f5837e9f 100644 --- a/tests/test_autotuner.py +++ b/tests/test_autotuner.py @@ -53,7 +53,7 @@ def test_mode_runtime_forward(): g = Function(name='g', grid=grid) f = TimeFunction(name='f', grid=grid) - op = Operator(Eq(f.forward, f + g + 1.), openmp=False) + op = Operator(Eq(f.forward, f + g + 1.), opt=('advanced', {'openmp': False})) summary = op.apply(time=100, autotune=('basic', 'runtime')) # AT is expected to have attempted 6 block shapes @@ -72,7 +72,7 @@ def test_mode_runtime_backward(): g = Function(name='g', grid=grid) f = TimeFunction(name='f', grid=grid) - op = Operator(Eq(f.backward, f + g + 1.), openmp=False) + op = Operator(Eq(f.backward, f + g + 1.), opt=('advanced', {'openmp': False})) summary = op.apply(time=101, autotune=('basic', 'runtime')) # AT is expected to have attempted 6 block shapes @@ -91,7 +91,7 @@ def test_mode_destructive(): g = Function(name='g', grid=grid) f = TimeFunction(name='f', grid=grid, time_order=0) - op = Operator(Eq(f, f + g + 1.), openmp=False) + op = Operator(Eq(f, f + g + 1.), opt=('advanced', {'openmp': False})) op.apply(time=100, autotune=('basic', 'destructive')) # AT is expected to have executed 30 timesteps (6 block shapes, 5 timesteps each) @@ -104,7 +104,7 @@ def test_blocking_only(): grid = Grid(shape=(96, 96, 96)) f = TimeFunction(name='f', grid=grid) - op = Operator(Eq(f.forward, f.dx + 1.), openmp=False) + op = Operator(Eq(f.forward, f.dx + 1.), opt=('advanced', {'openmp': False})) op.apply(time=0, autotune=True) assert op._state['autotuning'][0]['runs'] == 6 @@ -117,7 +117,7 @@ def test_mixed_blocking_nthreads(): grid = Grid(shape=(96, 96, 96)) f = TimeFunction(name='f', grid=grid) - op = Operator(Eq(f.forward, f.dx + 1.), openmp=True) + op = Operator(Eq(f.forward, f.dx + 1.), opt=('advanced', {'openmp': True})) op.apply(time=100, autotune=True) assert op._state['autotuning'][0]['runs'] == 6 @@ -312,7 +312,7 @@ def test_nested_nthreads(): grid = Grid(shape=(96, 96, 96)) f = TimeFunction(name='f', grid=grid) - op = Operator(Eq(f.forward, f.dx + 1.), openmp=True) + op = Operator(Eq(f.forward, f.dx + 1.), opt=('advanced', {'openmp': True})) op.apply(time=10, autotune=True) assert op._state['autotuning'][0]['runs'] == 6 diff --git a/tests/test_builtins.py b/tests/test_builtins.py index 0c70d63e86..17b08213e8 100644 --- a/tests/test_builtins.py +++ b/tests/test_builtins.py @@ -340,8 +340,8 @@ def test_serial_vs_parallel(self): f = TimeFunction(name='f', grid=grid) f.data[:] = np.arange(10000).reshape((100, 100)) - assert np.isclose(norm(f), - switchconfig(openmp=True)(norm)(f), + assert np.isclose(switchconfig(language='C')(norm)(f), + switchconfig(language='openmp')(norm)(f), rtol=1e-5) def test_inner_sparse(self): diff --git a/tests/test_dimension.py b/tests/test_dimension.py index 408dd3ffb5..7bf28faa35 100644 --- a/tests/test_dimension.py +++ b/tests/test_dimension.py @@ -657,7 +657,7 @@ def test_arrays_defined_over_subdims(self): f = Function(name='f', grid=grid) a = Array(name='a', dimensions=(xi,), dtype=grid.dtype) op = Operator([Eq(a[xi], 1), Eq(f, f + a[xi + 1], subdomain=grid.interior)], - openmp=False) + opt=('advanced', {'openmp': False})) assert len(op.parameters) == 6 # neither `x_size` nor `xi_size` are expected here assert not any(i.name in ('x_size', 'xi_size') for i in op.parameters) @@ -1625,7 +1625,7 @@ def test_array_shared_w_topofuse(self): Eq(a1, 1), Eq(a1, 2, implicit_dims=(cd0,))] - op = Operator(eqns, openmp=True) + op = Operator(eqns, opt=('advanced', {'openmp': True})) assert_structure(op, ['i,x,y', 'i', 'i,x,y', 'i,x,y'], 'i,x,y,x,y,x,y') diff --git a/tests/test_dle.py b/tests/test_dle.py index 9292b52664..cbe19aee7e 100644 --- a/tests/test_dle.py +++ b/tests/test_dle.py @@ -531,7 +531,7 @@ def test_nthreads_generation(self): eq = Eq(f.forward, f + 1) - op0 = Operator(eq, openmp=True) + op0 = Operator(eq, opt=('advanced', {'openmp': True})) # `nthreads` must appear among the Operator parameters assert op0.nthreads in op0.parameters diff --git a/tests/test_dse.py b/tests/test_dse.py index b1ed9394ec..b346e00092 100644 --- a/tests/test_dse.py +++ b/tests/test_dse.py @@ -1123,7 +1123,7 @@ def test_nested_invariant_v5(self): expr = 1./(5.*dt*sqrt(a)*b/hx + 2.*dt**2*b**2*a/hx**2 + 3.) eq = Eq(e.forward, 2.*expr*sqrt(a) + 3.*expr + e*sqrt(a)).subs({x: xright}) - op = Operator(eq, openmp=False) + op = Operator(eq, opt=('advanced', {'openmp': False})) # Check generated code arrays = [i for i in FindSymbols().visit(op) if i.is_Array] @@ -1777,7 +1777,7 @@ def g1_tilde(field, phi): eqn = Eq(p0.forward, update_p) - op = Operator(eqn, subs=grid.spacing_map, openmp=True) + op = Operator(eqn, subs=grid.spacing_map, opt=('advanced', {'openmp': True})) # Check code generation bns, pbs = assert_blocking(op, {'x0_blk0'}) @@ -1823,7 +1823,7 @@ def g3_tilde(field, phi): eqn = Eq(p0.forward, update_p) - op = Operator(eqn, subs=grid.spacing_map, openmp=True) + op = Operator(eqn, subs=grid.spacing_map, opt=('advanced', {'openmp': True})) # Check code generation assert op._profiler._sections['section1'].sops == exp_ops @@ -1867,7 +1867,7 @@ def g2_tilde(field, phi, theta): eqn = Eq(p0.forward, update_p) - op = Operator(eqn, subs=grid.spacing_map, openmp=True) + op = Operator(eqn, subs=grid.spacing_map, opt=('advanced', {'openmp': True})) # Check code generation assert op._profiler._sections['section1'].sops == exp_ops @@ -1934,7 +1934,7 @@ def g3_tilde(field, phi, theta): eqns = [Eq(p0.forward, update_p), Eq(m0.forward, update_m)] - op = Operator(eqns, subs=grid.spacing_map, openmp=True) + op = Operator(eqns, subs=grid.spacing_map, opt=('advanced', {'openmp': True})) # Check code generation assert op._profiler._sections['section1'].sops == exp_ops @@ -2842,7 +2842,7 @@ def test_opcounts(self, space_order, expected): eqns = [Eq(u.forward, (2*u - u.backward) + s**2/m * (e * H2u + H1v)), Eq(v.forward, (2*v - v.backward) + s**2/m * (d * H2v + H1v))] - op = Operator(eqns, openmp=True) + op = Operator(eqns, opt=('advanced', {'openmp': True})) # Check code generation _, pbs = assert_blocking(op, {'x0_blk0'}) diff --git a/tests/test_operator.py b/tests/test_operator.py index cc8574fc8e..5cdc546d51 100644 --- a/tests/test_operator.py +++ b/tests/test_operator.py @@ -142,7 +142,7 @@ def test_parameters(self): a_dense = Function(name='a_dense', grid=grid) const = Constant(name='constant') eqn = Eq(a_dense, a_dense + 2.*const) - op = Operator(eqn, openmp=False) + op = Operator(eqn, opt=('advanced', {'openmp': False})) assert len(op.parameters) == 5 assert op.parameters[0].name == 'a_dense' assert op.parameters[0].is_AbstractFunction @@ -738,7 +738,7 @@ def test_default_functions(self): grid = Grid(shape=(5, 6, 7)) f = TimeFunction(name='f', grid=grid) g = Function(name='g', grid=grid) - op = Operator(Eq(f.forward, g + f), openmp=False) + op = Operator(Eq(f.forward, g + f), opt=('advanced', {'openmp': False})) expected = { 'x_m': 0, 'x_M': 4, @@ -1875,7 +1875,7 @@ def test_barrier_halts_topofuse(self): # No surprises here -- the third equation gets swapped with the second # one so as to be fused with the first equation - op0 = Operator(eqns0, openmp=True) + op0 = Operator(eqns0, opt=('advanced', {'openmp': True})) assert_structure(op0, ['t,x,y,z', 't', 't,z'], 't,x,y,z,z') class DummyBarrier(sympy.Function, Barrier): @@ -1884,14 +1884,14 @@ class DummyBarrier(sympy.Function, Barrier): eqns1 = list(eqns0) eqns1[1] = Eq(Symbol('dummy'), DummyBarrier(time)) - op1 = Operator(eqns1, openmp=True) + op1 = Operator(eqns1, opt=('advanced', {'openmp': True})) assert_structure(op1, ['t,x,y,z', 't', 't,x,y,z'], 't,x,y,z,x,y,z') # Again, but now a swap is performed *before* the barrier so it's legal eqns2 = list(eqns0) eqns2.append(eqns1[1]) - op2 = Operator(eqns2, openmp=True) + op2 = Operator(eqns2, opt=('advanced', {'openmp': True})) assert_structure(op2, ['t,x,y,z', 't', 't,z'], 't,x,y,z,z') def test_array_shared_w_topofuse(self): @@ -1913,7 +1913,7 @@ def test_array_shared_w_topofuse(self): # For thread-shared Arrays, WAR dependencies shouldn't prevent topo-fusion # opportunities, since they're not really WAR's as classic Lamport # theory would tag - op = Operator(eqns, openmp=True) + op = Operator(eqns, opt=('advanced', {'openmp': True})) assert_structure(op, ['x,y', 'i,x,y'], 'x,y,i,x,y') def test_topofuse_w_numeric_dim(self): diff --git a/tests/test_pickle.py b/tests/test_pickle.py index 9eead76564..27e9f80c7a 100644 --- a/tests/test_pickle.py +++ b/tests/test_pickle.py @@ -598,7 +598,7 @@ def test_mpi_objects(self, pickle): def test_threadid(self, pickle): grid = Grid(shape=(4, 4, 4)) f = TimeFunction(name='f', grid=grid) - op = Operator(Eq(f.forward, f + 1.), openmp=True) + op = Operator(Eq(f.forward, f + 1.), opt=('advanced', {'openmp': True})) tid = ThreadID(op.nthreads)