Skip to content

Commit 11482d7

Browse files
committed
compiler: Add LocalObject._mem_shared
1 parent 2b1cbed commit 11482d7

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,10 +176,10 @@ 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

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

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

196197
def _hashable_content(self):
197198
return (super()._hashable_content() +
198199
self.cargs +
199-
(self.initvalue, self.liveness, self.is_global))
200+
(self.initvalue, self.liveness, self.scope))
200201

201202
@property
202-
def is_global(self):
203-
return self._is_global
203+
def scope(self):
204+
return self._scope
204205

205206
@property
206207
def free_symbols(self):
@@ -236,6 +237,10 @@ def _C_free(self):
236237
"""
237238
return None
238239

240+
@property
241+
def _mem_shared(self):
242+
return self._scope == 'shared'
243+
239244
@property
240245
def _mem_global(self):
241-
return self._is_global
246+
return self._scope == 'global'

tests/test_iet.py

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

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

363363
# A LocalObject using both a template and a modifier
364364
class SpecialObject(LocalObject):

0 commit comments

Comments
 (0)