Skip to content

Commit 4003653

Browse files
committed
WIP WIP WIP
1 parent a48c553 commit 4003653

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

devito/passes/iet/definitions.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
169169
decl = Definition(obj)
170170

171171
# Symbols/pointers
172-
size = Symbol(name='size', dtype=np.uint64, is_const=True)
173172
ffp0 = FieldFromPointer(obj._C_field_data, obj._C_symbol)
174173
ffp1 = FieldFromPointer(obj._C_field_shape, obj._C_symbol)
175174
ffp2 = FieldFromPointer(obj._C_field_size, obj._C_symbol)
@@ -188,10 +187,9 @@ def _alloc_mapped_array_on_high_bw_mem(self, site, obj, storage, *args):
188187

189188
# Initialize the Array struct
190189
init = [*[DummyExpr(IndexedPointer(ffp1, i), s)
191-
for i, s in enumerate(obj.symbolic_shape)],
192-
DummyExpr(size, obj.size, init=True),
193-
DummyExpr(ffp2, size),
194-
DummyExpr(ffp3, size*SizeOf(obj.indexed._C_typedata))]
190+
for i, s in enumerate(obj.c0.symbolic_shape)],
191+
DummyExpr(ffp2, obj.size),
192+
DummyExpr(ffp3, ffp2*SizeOf(obj.indexed._C_typedata))]
195193

196194
# Allocate the underlying host data
197195
memptr = VOID(Byref(ffp0), '**')

devito/types/array.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import numpy as np
55
from sympy import Expr, cacheit
66

7+
from devito.data import FULL
78
from devito.tools import (Pickable, as_tuple, c_restrict_void_p,
89
dtype_to_ctype, dtypes_vector_mapper, is_integer)
910
from devito.types.basic import AbstractFunction, LocalType
@@ -60,6 +61,13 @@ def shape_allocated(self):
6061
def is_const(self):
6162
return self._is_const
6263

64+
@property
65+
def c0(self):
66+
# ArrayBasic can be used as a base class for tensorial objects (that is,
67+
# arrays whose components are AbstractFunctions). This property enables
68+
# treating the two cases uniformly in some lowering passes
69+
return self
70+
6371

6472
class Array(ArrayBasic):
6573

@@ -425,7 +433,6 @@ def __halo_setup__(self, components=(), **kwargs):
425433

426434
@property
427435
def c0(self):
428-
# Shortcut for self.components[0]
429436
return self.components[0]
430437

431438
# Class attributes overrides
@@ -464,18 +471,26 @@ def ncomp(self):
464471
def initvalue(self):
465472
return None
466473

467-
# Overrides defaulting to self.c0's behaviour
468-
474+
# Defaulting to self.c0's behaviour
469475
for i in ('_mem_internal_eager', '_mem_internal_lazy', '_mem_local',
470476
'_mem_mapped', '_mem_host', '_mem_stack', '_mem_constant',
471477
'_mem_shared', '_mem_shared_remote', '__padding_dtype__',
472478
'_size_domain', '_size_halo', '_size_owned', '_size_padding',
473-
'_size_nopad', '_size_nodomain', '_offset_domain',
474-
'_offset_halo', '_offset_owned', '_dist_dimensions',
475-
'_C_get_field', 'grid', 'symbolic_shape',
479+
'_size_nopad', '_size_nodomain', '_offset_domain', '_offset_halo',
480+
'_offset_owned', '_dist_dimensions', '_C_get_field', 'grid',
476481
*AbstractFunction.__properties__):
477482
locals()[i] = property(lambda self, v=i: getattr(self.c0, v))
478483

484+
# Other overrides
485+
486+
@cached_property
487+
def symbolic_shape(self):
488+
from devito.symbolics import FieldFromPointer, IndexedPointer # noqa
489+
ffp = FieldFromPointer(self._C_field_shape, self._C_symbol)
490+
ret = [s if is_integer(s) else IndexedPointer(ffp, i)
491+
for i, s in enumerate(self.shape)]
492+
return tuple(ret)
493+
479494
@property
480495
def _mem_heap(self):
481496
return not any([self._mem_stack, self._mem_shared, self._mem_shared_remote])

0 commit comments

Comments
 (0)