Skip to content

Commit

Permalink
Merge pull request #2186 from devitocodes/deprec-fix
Browse files Browse the repository at this point in the history
misc: fix openmp= deprecation
  • Loading branch information
FabioLuporini authored Aug 23, 2023
2 parents c8e5415 + 539544a commit 67e5779
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
12 changes: 6 additions & 6 deletions tests/test_autotuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion tests/test_dle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/test_dse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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'})
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'})
Expand Down
12 changes: 6 additions & 6 deletions tests/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 67e5779

Please sign in to comment.