Skip to content

Commit 4d236f1

Browse files
committed
compiler: Add Basic._mem_shared_remote
1 parent 6b3c934 commit 4d236f1

2 files changed

Lines changed: 29 additions & 14 deletions

File tree

devito/types/array.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,16 @@ class Array(ArrayBasic):
9090
to 'local'. Used to override `_mem_local` and `_mem_mapped`.
9191
scope : str, optional
9292
The scope in the given memory space. Allowed values: 'heap', 'stack',
93-
'static', 'constant', 'shared'. 'static' refers to a static array in a
94-
C/C++ sense. 'constant' and 'shared' mean that the Array represents an
95-
object allocated in so called constant and shared memory, respectively,
96-
which are typical of device architectures. If 'shared' is specified but
97-
the underlying architecture doesn't have something akin to shared memory,
98-
the behaviour is unspecified. If 'constant' is specified but the underlying
99-
architecture doesn't have something akin to constant memory, the Array
100-
falls back to a global, const, static array in a C/C++ sense.
101-
Note that not all scopes make sense for a given space.
93+
'static', 'constant', 'shared', 'shared-remote'. 'static' refers to a
94+
static array in a C/C++ sense. 'constant' and 'shared' mean that the
95+
Array represents an object allocated in so called constant and shared
96+
memory, respectively, which are typical of device architectures. If
97+
'shared' is specified but the underlying architecture doesn't have
98+
something akin to shared memory, the behaviour is unspecified. If
99+
'constant' is specified but the underlying architecture doesn't have
100+
something akin to constant memory, the Array falls back to a global,
101+
const, static array in a C/C++ sense. Note that not all scopes make
102+
sense for a given space.
102103
grid : Grid, optional
103104
Only necessary for distributed-memory parallelism; a Grid contains
104105
information about the distributed Dimensions, hence it is necessary
@@ -131,7 +132,8 @@ def __init_finalize__(self, *args, **kwargs):
131132
super().__init_finalize__(*args, **kwargs)
132133

133134
self._scope = kwargs.get('scope', 'heap')
134-
assert self._scope in ['heap', 'stack', 'static', 'constant', 'shared']
135+
assert self._scope in ['heap', 'stack', 'static', 'constant', 'shared',
136+
'shared-remote']
135137

136138
self._initvalue = kwargs.get('initvalue')
137139
assert self._initvalue is None or self._scope != 'heap'
@@ -174,6 +176,10 @@ def _mem_heap(self):
174176
def _mem_shared(self):
175177
return self._scope == 'shared'
176178

179+
@property
180+
def _mem_shared_remote(self):
181+
return self._scope == 'shared-remote'
182+
177183
@property
178184
def _mem_constant(self):
179185
return self._scope == 'constant'
@@ -445,9 +451,10 @@ def initvalue(self):
445451

446452
for i in ('_mem_internal_eager', '_mem_internal_lazy', '_mem_local',
447453
'_mem_mapped', '_mem_host', '_mem_stack', '_mem_constant',
448-
'_mem_shared', '__padding_dtype__', '_size_domain', '_size_halo',
449-
'_size_owned', '_size_padding', '_size_nopad', '_size_nodomain',
450-
'_offset_domain', '_offset_halo', '_offset_owned', '_dist_dimensions',
454+
'_mem_shared', '_mem_shared_remote', '__padding_dtype__',
455+
'_size_domain', '_size_halo', '_size_owned', '_size_padding',
456+
'_size_nopad', '_size_nodomain', '_offset_domain',
457+
'_offset_halo', '_offset_owned', '_dist_dimensions',
451458
'_C_get_field', 'grid', 'symbolic_shape',
452459
*AbstractFunction.__properties__):
453460
locals()[i] = property(lambda self, v=i: getattr(self.c0, v))

devito/types/basic.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CodeSymbol:
4242
* "liveness": `_mem_external`, `_mem_internal_eager`, `_mem_internal_lazy`
4343
* "space": `_mem_local`, `_mem_mapped`, `_mem_host`
4444
* "scope": `_mem_stack`, `_mem_heap`, `_mem_global`, `_mem_shared`,
45-
`_mem_constant`
45+
`_mem_shared_remote`, `_mem_constant`
4646
4747
For example, an object that is `<_mem_internal_lazy, _mem_local, _mem_heap>`
4848
is allocated within the Operator entry point, on either the host or device
@@ -211,6 +211,14 @@ def _mem_shared(self):
211211
"""
212212
return False
213213

214+
@property
215+
def _mem_shared_remote(self):
216+
"""
217+
True if the associated data is allocated in so called remote shared
218+
memory, False otherwise.
219+
"""
220+
return False
221+
214222

215223
class Basic(CodeSymbol):
216224

0 commit comments

Comments
 (0)