Skip to content

Commit

Permalink
dsl: Purge UniqueDimension
Browse files Browse the repository at this point in the history
  • Loading branch information
EdCaunt committed Sep 12, 2024
1 parent e1a3e43 commit 635e3f6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 41 deletions.
2 changes: 1 addition & 1 deletion devito/ir/equations/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions devito/types/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

"""
Expand Down
11 changes: 5 additions & 6 deletions devito/types/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down Expand Up @@ -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),
Expand Down
18 changes: 0 additions & 18 deletions tests/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 635e3f6

Please sign in to comment.