diff --git a/pystencils/gpucuda/kernelcreation.py b/pystencils/gpucuda/kernelcreation.py index 29211586afd1baea8467e850b11246ffb8c2490c..7bc7fb9dd6326a806ee95fa245bb46f5429b7089 100644 --- a/pystencils/gpucuda/kernelcreation.py +++ b/pystencils/gpucuda/kernelcreation.py @@ -44,7 +44,9 @@ def create_cuda_kernel(assignments: Union[AssignmentCollection, NodeCollection], field_accesses = {e for e in field_accesses if not e.is_absolute_access} num_buffer_accesses += sum(1 for access in eq.atoms(Field.Access) if FieldType.is_buffer(access.field)) + # common shape and field to from the iteration space common_shape = get_common_shape(fields_without_buffers) + common_field = list(sorted(fields_without_buffers, key=lambda e: str(e)))[0] if iteration_slice is None: # determine iteration slice from ghost layers @@ -62,7 +64,7 @@ def create_cuda_kernel(assignments: Union[AssignmentCollection, NodeCollection], iteration_slice.append(slice(ghost_layers[i][0], -ghost_layers[i][1] if ghost_layers[i][1] > 0 else None)) - indexing = indexing_creator(field=list(fields_without_buffers)[0], iteration_slice=iteration_slice) + indexing = indexing_creator(field=common_field, iteration_slice=iteration_slice) coord_mapping = indexing.coordinates cell_idx_assignments = [SympyAssignment(LoopOverCoordinate.get_loop_counter_symbol(i), value)