Skip to content
Snippets Groups Projects
Commit 5854c2b6 authored by Marcel Koch's avatar Marcel Koch
Browse files

if temp array is managed, use correct declaration

parent e30edbc3
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ def _default_value(shape_impl, shape): ...@@ -42,6 +42,7 @@ def _default_value(shape_impl, shape):
def default_declaration(name, kernel, decl_info): def default_declaration(name, kernel, decl_info):
shape = kernel.temporary_variables[name].shape shape = kernel.temporary_variables[name].shape
shape_impl = kernel.temporary_variables[name].shape_impl shape_impl = kernel.temporary_variables[name].shape_impl
managed = kernel.temporary_variables[name].managed
# Determine the C++ type to use for this temporary. # Determine the C++ type to use for this temporary.
t = _temporary_type(shape_impl, shape) t = _temporary_type(shape_impl, shape)
...@@ -51,7 +52,13 @@ def default_declaration(name, kernel, decl_info): ...@@ -51,7 +52,13 @@ def default_declaration(name, kernel, decl_info):
v = _default_value(shape_impl[1:], shape[1:]) v = _default_value(shape_impl[1:], shape[1:])
if shape_impl[0] == 'arr': if shape_impl[0] == 'arr':
return '{} {}{};'.format(t, name, ''.join('[{}]'.format(s) for s in shape)) if managed:
size = 1
for s in shape:
size *= s
return '{} {}[{}];'.format(t, name, size)
else:
return '{} {}{};'.format(t, name, ''.join('[{}]'.format(s) for s in shape))
if shape_impl[0] == 'vec': if shape_impl[0] == 'vec':
return '{} {}({}, {});'.format(t, name, shape[0], v) return '{} {}({}, {});'.format(t, name, shape[0], v)
if shape_impl[0] == 'fv': if shape_impl[0] == 'fv':
...@@ -91,6 +98,10 @@ class DuneTemporaryVariable(TemporaryVariable): ...@@ -91,6 +98,10 @@ class DuneTemporaryVariable(TemporaryVariable):
self.custom_declaration = self.decl_method is not None self.custom_declaration = self.decl_method is not None
if self.managed and shape_impl is not None:
for impl in shape_impl:
assert impl == 'arr'
TemporaryVariable.__init__(self, name, TemporaryVariable.__init__(self, name,
managed=self.managed, managed=self.managed,
shape_impl=self.shape_impl, shape_impl=self.shape_impl,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment