Skip to content

Commit

Permalink
tests: Factorize test_incr_perfect_outer
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioLuporini committed Oct 10, 2023
1 parent d628f54 commit 2b09a82
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 48 deletions.
30 changes: 27 additions & 3 deletions tests/test_gpu_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from conftest import assert_structure
from devito import (Constant, Eq, Inc, Grid, Function, ConditionalDimension,
MatrixSparseTimeFunction, SparseTimeFunction, SubDimension,
SubDomain, SubDomainSet, TimeFunction, Operator, configuration,
switchconfig)
Dimension, MatrixSparseTimeFunction, SparseTimeFunction,
SubDimension, SubDomain, SubDomainSet, TimeFunction,
Operator, configuration, switchconfig)
from devito.arch import get_gpu_info
from devito.exceptions import InvalidArgument
from devito.ir import (Conditional, Expression, Section, FindNodes, FindSymbols,
Expand Down Expand Up @@ -110,6 +110,30 @@ def test_fission(self):
assert np.all(usave.data[5:] == expected[5:])
assert np.all(vsave.data[:5] == expected[:5])

def test_incr_perfect_outer(self):
grid = Grid((5, 5))
d = Dimension(name="d")

u = Function(name="u", dimensions=(*grid.dimensions, d),
grid=grid, shape=(*grid.shape, 5), )
v = Function(name="v", dimensions=(*grid.dimensions, d),
grid=grid, shape=(*grid.shape, 5))
w = Function(name="w", grid=grid)

u.data.fill(1)
v.data.fill(2)

summation = Inc(w, u*v)

op = Operator([summation])

assert 'reduction' not in str(op)
assert 'collapse(2)' in str(op)
assert 'parallel' in str(op)

op()
assert np.all(w.data == 10)


class Bundle(SubDomain):
"""
Expand Down
24 changes: 1 addition & 23 deletions tests/test_gpu_openacc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np

from devito import (Grid, Function, TimeFunction, SparseTimeFunction, Eq, Operator,
norm, solve, Dimension, Inc)
norm, solve)
from conftest import skipif, assert_blocking, opts_device_tiling
from devito.data import LEFT
from devito.exceptions import InvalidOperator
Expand Down Expand Up @@ -168,28 +168,6 @@ def test_multi_tile_blocking_structure(self):
assert len(iters) == len(v)
assert all(i.step == j for i, j in zip(iters, v))

def test_incr_perfect_outer(self):
grid = Grid((5, 5))
d = Dimension(name="d")
u = Function(name="u", dimensions=(*grid.dimensions, d),
grid=grid, shape=(*grid.shape, 5), )
v = Function(name="v", dimensions=(*grid.dimensions, d),
grid=grid, shape=(*grid.shape, 5))
u.data.fill(1)
v.data.fill(2)

w = Function(name="w", grid=grid)

summation = Inc(w, u*v)

op0 = Operator([summation])
assert 'reduction' not in str(op0)
assert 'collapse(2)' in str(op0)
assert 'acc parallel loop' in str(op0)

op0()
assert np.all(w.data == 10)


class TestOperator(object):

Expand Down
22 changes: 0 additions & 22 deletions tests/test_gpu_openmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,28 +268,6 @@ def test_timeparallel_reduction(self):
('omp target teams distribute parallel for collapse(3)'
' reduction(+:f[0])')

def test_incr_perfect_outer(self):
grid = Grid((5, 5))
d = Dimension(name="d")
u = Function(name="u", dimensions=(*grid.dimensions, d),
grid=grid, shape=(*grid.shape, 5), )
v = Function(name="v", dimensions=(*grid.dimensions, d),
grid=grid, shape=(*grid.shape, 5))
u.data.fill(1)
v.data.fill(2)

w = Function(name="w", grid=grid)

summation = Inc(w, u*v)

op0 = Operator([summation])
assert 'reduction' not in str(op0)
assert 'collapse(2)' in str(op0)
assert 'omp target teams distribute parallel' in str(op0)

op0()
assert np.all(w.data == 10)


class TestOperator(object):

Expand Down

0 comments on commit 2b09a82

Please sign in to comment.