Skip to content

Commit 4a903d3

Browse files
committed
compiler: Add LocalObject._mem_shared
1 parent 67a2179 commit 4a903d3

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

devito/types/object.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,27 +176,28 @@ class LocalObject(AbstractObject, LocalType):
176176
"""
177177

178178
__rargs__ = ('name',)
179-
__rkwargs__ = ('cargs', 'initvalue', 'liveness', 'is_global')
179+
__rkwargs__ = ('cargs', 'initvalue', 'liveness', 'scope')
180180

181181
def __init__(self, name, cargs=None, initvalue=None, liveness='lazy',
182-
is_global=False, **kwargs):
182+
scope='stack', **kwargs):
183183
self.name = name
184184
self.cargs = as_tuple(cargs)
185185
self.initvalue = initvalue or self.default_initvalue
186186

187187
assert liveness in ['eager', 'lazy']
188188
self._liveness = liveness
189189

190-
self._is_global = is_global
190+
assert scope in ['stack', 'shared', 'global']
191+
self._scope = scope
191192

192193
def _hashable_content(self):
193194
return (super()._hashable_content() +
194195
self.cargs +
195-
(self.initvalue, self.liveness, self.is_global))
196+
(self.initvalue, self.liveness, self.scope))
196197

197198
@property
198-
def is_global(self):
199-
return self._is_global
199+
def scope(self):
200+
return self._scope
200201

201202
@property
202203
def free_symbols(self):
@@ -232,6 +233,10 @@ def _C_free(self):
232233
"""
233234
return None
234235

236+
@property
237+
def _mem_shared(self):
238+
return self._scope == 'shared'
239+
235240
@property
236241
def _mem_global(self):
237-
return self._is_global
242+
return self._scope == 'global'

tests/test_iet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ class MyObject(LocalObject):
354354
lo0 = MyObject('obj0')
355355

356356
# Globally-scoped objects must not be declared in the function body
357-
lo1 = MyObject('obj1', is_global=True)
357+
lo1 = MyObject('obj1', scope='global')
358358

359359
# A LocalObject using both a template and a modifier
360360
class SpecialObject(LocalObject):

0 commit comments

Comments
 (0)