diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 8bc9c34f30..b4eb3d55a1 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -51,11 +51,6 @@ jobs: - name: Tests in examples run: | py.test --cov --cov-config=.coveragerc --cov-report=xml examples/ - py.test --cov --cov-config=.coveragerc --cov-report=xml examples/seismic/acoustic/acoustic_example.py - py.test --cov --cov-config=.coveragerc --cov-report=xml examples/seismic/viscoacoustic/viscoacoustic_example.py - py.test --cov --cov-config=.coveragerc --cov-report=xml examples/seismic/tti/tti_example.py - py.test --cov --cov-config=.coveragerc --cov-report=xml examples/seismic/elastic/elastic_example.py - py.test --cov --cov-config=.coveragerc --cov-report=xml examples/seismic/viscoelastic/viscoelastic_example.py - name: Seismic acoustic examples run: | diff --git a/devito/passes/iet/mpi.py b/devito/passes/iet/mpi.py index de87bb13a8..00d96213aa 100644 --- a/devito/passes/iet/mpi.py +++ b/devito/passes/iet/mpi.py @@ -45,15 +45,6 @@ def _drop_halospots(iet): if f in hs.fmapper and all(i.is_reduction for i in v): mapper[hs].add(f) - # If a HaloSpot is outside any iteration it is not needed - for iters, halo_spots in MapNodes(Iteration, HaloSpot, 'groupby').visit(iet).items(): - if iters: - continue - for hs in halo_spots: - for f, v in hs.fmapper.items(): - if v.loc_indices: - mapper[hs].add(f) - # Transform the IET introducing the "reduced" HaloSpots subs = {hs: hs._rebuild(halo_scheme=hs.halo_scheme.drop(mapper[hs])) for hs in FindNodes(HaloSpot).visit(iet)} diff --git a/devito/passes/iet/parpragma.py b/devito/passes/iet/parpragma.py index 1d1ca334d2..44ee6afd6c 100644 --- a/devito/passes/iet/parpragma.py +++ b/devito/passes/iet/parpragma.py @@ -295,6 +295,8 @@ def _select_candidates(self, candidates): except TypeError: pass + # At least one inner loop (nested) or + # we do not collapse most inner loop if it is an atomic reduction if not i.is_ParallelAtomic or nested: collapsable.append(i) diff --git a/devito/symbolics/inspection.py b/devito/symbolics/inspection.py index 06ad8ed373..94279db4ab 100644 --- a/devito/symbolics/inspection.py +++ b/devito/symbolics/inspection.py @@ -267,8 +267,8 @@ def has_integer_args(*args): def sympy_dtype(expr, default): """ - Try to infer the data type of the expression - returns the default if non is found + Infer the dtype of the expression + or default if could not be determined. """ # Symbol/... without argument, check its dtype if len(expr.args) == 0: diff --git a/devito/types/basic.py b/devito/types/basic.py index b4620ca093..55fe1d07a1 100644 --- a/devito/types/basic.py +++ b/devito/types/basic.py @@ -830,7 +830,7 @@ def __new__(cls, *args, **kwargs): # Go straight through Basic, thus bypassing caching and machinery # in sympy.Application/Function that isn't really necessary # AbstractFunctions are unique by construction! - newobj = sympy.Basic.__new__(cls, *indices) + newobj = sympy.Basic.__new__(cls, *sympy.sympify(indices)) # Initialization. The following attributes must be available # when executing __init_finalize__ diff --git a/devito/types/dimension.py b/devito/types/dimension.py index ca30e2217e..76d9d9e60a 100644 --- a/devito/types/dimension.py +++ b/devito/types/dimension.py @@ -187,7 +187,7 @@ def indirect(self): @property def index(self): - return self if self.indirect is True else getattr(self, 'parent', self) + return self @property def is_const(self): @@ -477,6 +477,10 @@ def __init_finalize__(self, name, parent): def parent(self): return self._parent + @property + def index(self): + return self if self.indirect else self.parent + @property def root(self): return self._parent.root @@ -1228,6 +1232,10 @@ def is_Derived(self): def parent(self): return self._parent + @property + def index(self): + return self.parent or self + @property def root(self): if self.is_Derived: diff --git a/devito/types/sparse.py b/devito/types/sparse.py index ba9631e677..0ac006c26b 100644 --- a/devito/types/sparse.py +++ b/devito/types/sparse.py @@ -112,7 +112,7 @@ def __subfunc_setup__(self, key, suffix, dtype=None): # Fallback to default behaviour dtype = dtype or self.dtype else: - if not isinstance(key, np.ndarray): + if key is not None: key = np.array(key) if (shape != key.shape[:2] and key.shape != (shape[1],)) and \ @@ -197,6 +197,16 @@ def _dist_datamap(self): def npoint(self): return self.shape[self._sparse_position] + @property + def npoint_global(self): + """ + Global `npoint`s. This only differs from `self.npoint` in an MPI context. + Issues + ------ + * https://github.com/devitocodes/devito/issues/1498 + """ + return self._npoint + @property def space_order(self): """The space order.""" @@ -1656,9 +1666,9 @@ def __indices_setup__(cls, *args, **kwargs): """ Return the default Dimension indices for a given data shape. """ - Dimensions = kwargs.get('dimensions') - if Dimensions is None: - Dimensions = (kwargs['grid'].time_dim, Dimension( + dimensions = kwargs.get('dimensions') + if dimensions is None: + dimensions = (kwargs['grid'].time_dim, Dimension( name='p_%s' % kwargs["name"])) if args: diff --git a/tests/test_caching.py b/tests/test_caching.py index 978a09e896..a11c6319a3 100644 --- a/tests/test_caching.py +++ b/tests/test_caching.py @@ -638,10 +638,9 @@ def test_sparse_function(self, operate_on_empty_cache): i = u.inject(expr=u, field=u) - # created: rxu, rxy (radius dimensions) and spacings and conditionals - # conditional sparse dim + # created: rux, ruy (radius dimensions) and spacings # posx, posy, px, py, u_coords (as indexified), - ncreated = 2+2+1+2+2+2+1 + ncreated = 2+1+2+2+2+1 # Note that injection is now lazy so no new symbols should be created assert len(_SymbolCache) == cur_cache_size i.evaluate @@ -661,7 +660,7 @@ def test_sparse_function(self, operate_on_empty_cache): # in the first clear_cache they were still referenced by their "parent" objects # (e.g., ru* by ConditionalDimensions, through `condition`) - assert len(_SymbolCache) == init_cache_size + 10 + assert len(_SymbolCache) == init_cache_size + 8 clear_cache() # Now we should be back to the original state except for # pos* that belong to the abstract class diff --git a/tests/test_gpu_openacc.py b/tests/test_gpu_openacc.py index 9c4a0e885e..823d11854d 100644 --- a/tests/test_gpu_openacc.py +++ b/tests/test_gpu_openacc.py @@ -132,9 +132,9 @@ def test_multiple_tile_sizes(self, par_tile): trees = retrieve_iteration_tree(op) assert len(trees) == 4 - assert trees[1][1].pragmas[0].value ==\ + assert trees[0][1].pragmas[0].value ==\ 'acc parallel loop tile(32,4,4) present(u)' - assert trees[2][1].pragmas[0].value ==\ + assert trees[1][1].pragmas[0].value ==\ 'acc parallel loop tile(8,8) present(u)' def test_multi_tile_blocking_structure(self):