Skip to content

Kernel expects wrong shape of array

The issue can be reproduced with the following code:

from pystencils.session import *

domain_size = (132, 128)

dh = ps.create_data_handling(domain_size, periodicity=(True, True), default_target='cpu')

src = dh.add_array("src", values_per_cell=1, dtype=np.float64, ghost_layers=1, alignment=True)
dh.fill(src.name, 1.0, ghost_layers=True)

dst = dh.add_array("dst", values_per_cell=1, dtype=np.float64, ghost_layers=1, alignment=True)
dh.fill(dst.name, 1.0, ghost_layers=True)

update_rule = ps.Assignment(dst[0, 0], src[-1, 0] + src[0, 0])

opt = {'instruction_set': 'avx', 'assume_aligned': True, 'nontemporal': True, 'assume_inner_stride_one': True}
ast = ps.create_kernel(update_rule, target=dh.default_target, cpu_vectorize_info=opt)
kernel = ast.compile()

dh.run_kernel(kernel)

If alignment is set to false (and thus assume_aligned and nontemporal) everything works fine.

Even with the alignment of the array set to True and assume_aligned set to false the error does not occur. The error is the following:

ValueError                                Traceback (most recent call last)
<ipython-input-1-f6893d7e30e1> in <module>
     17 kernel = ast.compile()
     18 
---> 19 dh.run_kernel(kernel)

~/pystencils/pystencils/pystencils/datahandling/serial_datahandling.py in run_kernel(self, kernel_function, **kwargs)
    241     def run_kernel(self, kernel_function, **kwargs):
    242         arrays = self.gpu_arrays if kernel_function.ast.backend in self._GPU_LIKE_BACKENDS else self.cpu_arrays
--> 243         kernel_function(**{**arrays, **kwargs})
    244 
    245     def get_kernel_kwargs(self, kernel_function, **kwargs):

~/pystencils/pystencils/pystencils/kernel_wrapper.py in __call__(self, **kwargs)
     16 
     17     def __call__(self, **kwargs):
---> 18         return self.kernel(**kwargs)
     19 
     20     @property

ValueError: Wrong shape of array dst. Expected (133, 130)
Edited by Markus Holzer