diff --git a/devito/passes/iet/parpragma.py b/devito/passes/iet/parpragma.py index 5d75e002db3..a4513ef31fd 100644 --- a/devito/passes/iet/parpragma.py +++ b/devito/passes/iet/parpragma.py @@ -324,7 +324,7 @@ def _make_reductions(self, partree): # The opposite corner case (most outer loop atomic) # should be detected before this pass nc = len(partree.collapsed) - if all(i.is_ParallelNoAtomic for i in partree.collapsed[:nc-1]): + if nc > 1 and all(i.is_ParallelNoAtomic for i in partree.collapsed[:nc-1]): mapper = {partree.root: partree.root._rebuild(ncollapsed=nc-1)} return Transformer(mapper).visit(partree) diff --git a/tests/test_adjoint.py b/tests/test_adjoint.py index 473e484c0ed..759b86a3aee 100644 --- a/tests/test_adjoint.py +++ b/tests/test_adjoint.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from devito import Operator, norm, Function, Grid, SparseFunction +from devito import Operator, norm, Function, Grid, SparseFunction, inner from devito.logger import info from examples.seismic import demo_model, Receiver from examples.seismic.acoustic import acoustic_setup @@ -114,7 +114,7 @@ def test_adjoint_F(self, mkey, shape, kernel, space_order, time_order, setup_fun solver.adjoint(rec=rec, srca=srca) # Adjoint test: Verify matches closely - term1 = np.dot(srca.data.reshape(-1), solver.geometry.src.data) + term1 = inner(srca, solver.geometry.src) term2 = norm(rec) ** 2 info(': %f, : %f, difference: %4.4e, ratio: %f' % (term1, term2, (term1 - term2)/term1, term1 / term2)) @@ -231,6 +231,6 @@ def test_adjoint_inject_interpolate(self, shape, coords, npoints=19): # y => p # x => c # P^T y => a - term1 = np.dot(p2.data.reshape(-1), p.data.reshape(-1)) - term2 = np.dot(c.data.reshape(-1), a.data.reshape(-1)) + term1 = inner(p2, p) + term2 = inner(c, a) assert np.isclose((term1-term2) / term1, 0., atol=1.e-6) diff --git a/tests/test_dle.py b/tests/test_dle.py index ecd5644e412..e7935dd45dc 100644 --- a/tests/test_dle.py +++ b/tests/test_dle.py @@ -888,9 +888,8 @@ def test_incr_perfect_outer(self): summation = Inc(w, u*v) - op0 = Operator([summation]) + op0 = Operator([summation], opt=('advanced', {'openmp': True})) assert 'reduction' not in str(op0) - assert 'collapse(2)' in str(op0) assert 'omp for' in str(op0) op0()