Skip to content

Commit

Permalink
Merge pull request #2220 from devitocodes/ci-fix
Browse files Browse the repository at this point in the history
compiler: Fix reduction over sparse only
  • Loading branch information
mloubout authored Sep 29, 2023
2 parents 7887f86 + ce14590 commit 0f0ae38
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest-core-mpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
os: ubuntu-latest
- name: icx
arch: icx
os: ["self-hosted", "docker"]
os: ubuntu-latest

steps:
- name: Checkout devito
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/pytest-core-nompi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:

- name: pytest-docker-py39-icx-omp
python-version: '3.9'
os: ["self-hosted", "docker"]
os: ubuntu-latest
arch: "icx"
language: "openmp"
sympy: "1.12"
Expand Down Expand Up @@ -160,6 +160,10 @@ jobs:
pip install -e .[tests]
pip install sympy==${{matrix.sympy}}
- name: Check configuration
run: |
${{ env.RUN_CMD }} python3 -c "from devito import configuration; print(''.join(['%s: %s \n' % (k, v) for (k, v) in configuration.items()]))"
- name: Test with pytest
run: |
${{ env.RUN_CMD }} ${{ matrix.arch }} --version
Expand Down
4 changes: 2 additions & 2 deletions devito/ir/clusters/visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ def __init__(self, func, mode='dense'):
self.func = func

if mode == 'dense':
self.cond = lambda c: c.is_dense
self.cond = lambda c: c.is_dense or not c.is_sparse
elif mode == 'sparse':
self.cond = lambda c: not c.is_dense
self.cond = lambda c: c.is_sparse
else:
self.cond = lambda c: True

Expand Down
2 changes: 1 addition & 1 deletion tests/test_buffering.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def test_over_injection():
rec.interpolate(expr=u.forward))

op0 = Operator(eqns, opt='noop')
op1 = Operator(eqns, opt='buffering')
op1 = Operator(eqns, opt=('buffering', {'par-collapse-work': 0}))

# Check generated code
assert len(retrieve_iteration_tree(op1)) == \
Expand Down
28 changes: 27 additions & 1 deletion tests/test_dle.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
retrieve_iteration_tree, Expression)
from devito.passes.iet.languages.openmp import Ompizer, OmpRegion
from devito.tools import as_tuple
from devito.types import Scalar
from devito.types import Scalar, Symbol


def get_blocksizes(op, opt, grid, blockshape, level=0):
Expand Down Expand Up @@ -789,6 +789,32 @@ def test_reduction_local(self):

assert n.data[0] == 11*11

def test_mapify_reduction_sparse(self):
grid = Grid((11, 11))
s = SparseTimeFunction(name="s", grid=grid, npoint=1, nt=11)
s.data.fill(1.)
r = Symbol(name="r", dtype=np.float32)
n0 = Function(name="n0", dimensions=(Dimension("noi"),), shape=(1,))

eqns = [Eq(r, 0), Inc(r, s*s), Eq(n0[0], r)]
op0 = Operator(eqns)
op1 = Operator(eqns, opt=('advanced', {'mapify-reduce': True}))

expr0 = FindNodes(Expression).visit(op0)
assert len(expr0) == 3
assert expr0[1].is_reduction

expr1 = FindNodes(Expression).visit(op1)
assert len(expr1) == 4
assert expr1[1].expr.lhs.indices == s.indices
assert expr1[2].expr.rhs.is_Indexed
assert expr1[2].is_reduction

op0()
assert n0.data[0] == 11
op1()
assert n0.data[0] == 11

def test_array_max_reduction(self):
"""
Test generation of OpenMP sum-reduction clauses involving Function's.
Expand Down

0 comments on commit 0f0ae38

Please sign in to comment.