diff --git a/devito/ir/equations/algorithms.py b/devito/ir/equations/algorithms.py index cc72ccf6e5..818f307101 100644 --- a/devito/ir/equations/algorithms.py +++ b/devito/ir/equations/algorithms.py @@ -267,7 +267,7 @@ def _(d, mapper, rebuilt, sregistry): try: idim1 = rebuilt[idim0] except KeyError: - iname = sregistry.make_name(prefix=idim0.name) + iname = sregistry.make_name(prefix='n') rebuilt[idim0] = idim1 = idim0._rebuild(name=iname) kwargs['implicit_dimension'] = idim1 diff --git a/devito/types/dimension.py b/devito/types/dimension.py index 3123db8312..1ccb847da8 100644 --- a/devito/types/dimension.py +++ b/devito/types/dimension.py @@ -395,22 +395,6 @@ def __eq__(self, other): __hash__ = Symbol.__hash__ -class UniqueDimension(BasicDimension): - """ - Like BasicDimension, but with a tag for unique hashing. - """ - - __rargs__ = Dimension.__rargs__ + ('tag',) - - def __init_finalize__(self, name, tag, **kwargs): - super().__init_finalize__(name, **kwargs) - self._tag = tag - - @property - def tag(self): - return self._tag - - class DefaultDimension(Dimension, DataSymbol): """ diff --git a/devito/types/grid.py b/devito/types/grid.py index 9bbd4a642a..9daae18ea6 100644 --- a/devito/types/grid.py +++ b/devito/types/grid.py @@ -16,8 +16,7 @@ from devito.types.utils import DimensionTuple from devito.types.dimension import (Dimension, SpaceDimension, TimeDimension, Spacing, SteppingDimension, SubDimension, - MultiSubDimension, DefaultDimension, - UniqueDimension) + MultiSubDimension, DefaultDimension) __all__ = ['Grid', 'SubDomain', 'SubDomainSet'] @@ -738,10 +737,10 @@ def __subdomain_finalize__(self, grid, **kwargs): # Associate the `_local_bounds` to suitable symbolic objects that the # compiler can use to generate code - # Standard Dimensions hash the same, which means that they are all the same object - # if their names are the same. Hence tag them with the SubDomainSet location to - # make them unique. - i_dim = UniqueDimension('n', id(self)) + # Dimensions with identical names hash the same, hence tag them with the + # SubDomainSet ID to make them unique so they can be used to key a dictionary + # of replacements without risking overwriting. + i_dim = Dimension('n_%s' % str(id(self))) d_dim = DefaultDimension(name='d', default_value=2*grid.dim) sd_func = Function(name=self.name, grid=self._grid, shape=(self._n_domains, 2*grid.dim), diff --git a/tests/test_caching.py b/tests/test_caching.py index 02742a8728..8dca69fa60 100644 --- a/tests/test_caching.py +++ b/tests/test_caching.py @@ -12,7 +12,6 @@ from devito.types import (DeviceID, NThreadsBase, NPThreads, Object, LocalObject, Scalar, Symbol, ThreadID) from devito.types.basic import AbstractSymbol -from devito.types.dimension import UniqueDimension @pytest.fixture @@ -78,23 +77,6 @@ def test_dimension(self): assert hash(d3) != hash(d0) assert hash(d3) != hash(d1) - def test_unique_dimension(self): - """ - Test that UniqueDimensions have different hash values, so long as - their tags differ. - """ - d0 = UniqueDimension('d', 0) - d1 = UniqueDimension('d', 1) - assert hash(d0) != hash(d1) - - s = Scalar(name='s') - d2 = UniqueDimension('d', 0, spacing=s) - d3 = UniqueDimension('d', 1, spacing=s) - assert hash(d2) != hash(d3) - - d4 = UniqueDimension('d', 0) - assert hash(d0) == hash(d4) - def test_sub_dimension(self): """Test that different SubDimensions have different hash value.""" d0 = Dimension(name='d')