Skip to content

Commit cabc8bf

Browse files
committed
WIP WIP (now reusing the alloc function)
1 parent 4003653 commit cabc8bf

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

devito/passes/iet/definitions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
SizeOf, VOID, pow_to_mul, unevaluate)
2020
from devito.tools import as_mapper, as_list, as_tuple, filter_sorted, flatten
2121
from devito.types import (Array, ComponentAccess, CustomDimension, DeviceMap,
22-
DeviceRM, Eq, Symbol)
22+
DeviceRM, Eq, Symbol, size_t)
2323

2424
__all__ = ['DataManager', 'DeviceAwareDataManager', 'Storage']
2525

@@ -168,7 +168,8 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
168168
"""
169169
decl = Definition(obj)
170170

171-
# Symbols/pointers
171+
arity_param = Symbol(name='arity', dtype=size_t)
172+
arity_arg = SizeOf(obj.indexed._C_typedata)
172173
ffp0 = FieldFromPointer(obj._C_field_data, obj._C_symbol)
173174
ffp1 = FieldFromPointer(obj._C_field_shape, obj._C_symbol)
174175
ffp2 = FieldFromPointer(obj._C_field_size, obj._C_symbol)
@@ -189,7 +190,7 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
189190
init = [*[DummyExpr(IndexedPointer(ffp1, i), s)
190191
for i, s in enumerate(obj.c0.symbolic_shape)],
191192
DummyExpr(ffp2, obj.size),
192-
DummyExpr(ffp3, ffp2*SizeOf(obj.indexed._C_typedata))]
193+
DummyExpr(ffp3, ffp2*arity_param)]
193194

194195
# Allocate the underlying host data
195196
memptr = VOID(Byref(ffp0), '**')
@@ -210,7 +211,9 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
210211
name = self.sregistry.make_name(prefix='alloc')
211212
body = (decl, alloc0, alloc1, *init, alloc2, *as_tuple(alloc_dmap), ret)
212213
efunc0 = make_callable(name, body, retval=obj)
213-
alloc = Call(name, efunc0.parameters, retobj=obj)
214+
args = list(efunc0.parameters)
215+
args[args.index(arity_param)] = arity_arg
216+
alloc = Call(name, args, retobj=obj)
214217

215218
# Same story for the frees
216219
name = self.sregistry.make_name(prefix='free')

devito/types/misc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
__all__ = ['Timer', 'Pointer', 'VolatileInt', 'FIndexed', 'Wildcard', 'Fence',
1616
'Global', 'Hyperplane', 'Indirection', 'Temp', 'TempArray', 'Jump',
17-
'nop', 'WeakFence', 'CriticalRegion', 'Auto', 'AutoRef', 'auto']
17+
'nop', 'WeakFence', 'CriticalRegion', 'Auto', 'AutoRef', 'auto',
18+
'size_t']
1819

1920

2021
class Timer(CompositeObject):
@@ -344,7 +345,9 @@ def closing(self):
344345
"""
345346

346347

347-
# *** CXX support types
348+
# *** C/CXX support types
349+
350+
size_t = CustomDtype('size_t')
348351

349352
# NOTE: In C++, `auto` is a type specifier more than a type itself, but
350353
# it's a distinction we can afford to ignore, at least for now

0 commit comments

Comments
 (0)