Skip to content

Commit f6b6ddd

Browse files
committed
compiler: Add LocalObject._mem_shared
1 parent 29c09e5 commit f6b6ddd

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
@@ -177,10 +177,10 @@ class LocalObject(AbstractObject, LocalType):
177177
"""
178178

179179
__rargs__ = ('name',)
180-
__rkwargs__ = ('cargs', 'initvalue', 'liveness', 'is_global')
180+
__rkwargs__ = ('cargs', 'initvalue', 'liveness', 'scope')
181181

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

@@ -192,16 +192,17 @@ def __init__(self, name, cargs=None, initvalue=None, liveness='lazy',
192192
assert liveness in ['eager', 'lazy']
193193
self._liveness = liveness
194194

195-
self._is_global = is_global
195+
assert scope in ['stack', 'shared', 'global']
196+
self._scope = scope
196197

197198
def _hashable_content(self):
198199
return (super()._hashable_content() +
199200
self.cargs +
200-
(self.initvalue, self.liveness, self.is_global))
201+
(self.initvalue, self.liveness, self.scope))
201202

202203
@property
203-
def is_global(self):
204-
return self._is_global
204+
def scope(self):
205+
return self._scope
205206

206207
@property
207208
def free_symbols(self):
@@ -235,6 +236,10 @@ def _C_free(self):
235236
"""
236237
return None
237238

239+
@property
240+
def _mem_shared(self):
241+
return self._scope == 'shared'
242+
238243
@property
239244
def _mem_global(self):
240-
return self._is_global
245+
return self._scope == 'global'

tests/test_iet.py

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

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

365365
# A LocalObject using both a template and a modifier
366366
class SpecialObject(LocalObject):

0 commit comments

Comments
 (0)