diff --git a/pystencils/cpu/kernelcreation.py b/pystencils/cpu/kernelcreation.py index 1aa102e4fd7fdecabc22e47605ccb6647aead9ef..eecfb4687ee6220748bcb6c5c69051bdec43d6a6 100644 --- a/pystencils/cpu/kernelcreation.py +++ b/pystencils/cpu/kernelcreation.py @@ -94,7 +94,7 @@ def create_kernel(assignments: Union[NodeCollection], return ast_node -def create_indexed_kernel(assignments: Union[AssignmentCollection, NodeCollection], +def create_indexed_kernel(assignments: NodeCollection, config: CreateKernelConfig) -> KernelFunction: """ Similar to :func:`create_kernel`, but here not all cells of a field are updated but only cells with @@ -115,16 +115,28 @@ def create_indexed_kernel(assignments: Union[AssignmentCollection, NodeCollectio fields_written = assignments.bound_fields fields_read = assignments.rhs_fields + + Index_IDBefore = "" + for index_field in index_fields: + Index_IDBefore += f"index field name: {index_field.name}: {str(id(index_field))}" + assignments = assignments.all_assignments assignments = add_types(assignments, config) + all_fields = fields_read.union(fields_written) + AllFieldsIDSBefore = "" + for field in all_fields: + AllFieldsIDSBefore += f"field name: {field.name}: {str(id(field))}" for index_field in index_fields: index_field.field_type = FieldType.INDEXED assert FieldType.is_indexed(index_field) assert index_field.spatial_dimensions == 1, "Index fields have to be 1D" + Index_IDAfter = "" + for index_field in index_fields: + Index_IDAfter += f"index field name: {index_field.name}: {str(id(index_field))}" non_index_fields = [f for f in all_fields if f not in index_fields] spatial_coordinates = {f.spatial_dimensions for f in non_index_fields} assert len(spatial_coordinates) == 1, f"Non-index fields do not have the same number of spatial coordinates " \ @@ -132,7 +144,11 @@ def create_indexed_kernel(assignments: Union[AssignmentCollection, NodeCollectio f"{spatial_coordinates} and len(spatial coordiantes) is " \ f"{len(spatial_coordinates)}, " \ f"index_fields in config: {config.index_fields}, " \ - f"extracted index fields: {index_fields} " + f"extracted index fields: {index_fields} " \ + f"Index_IDBefore {Index_IDBefore} " \ + f"Index_IDAfter {Index_IDAfter} " \ + f"AllFieldsIDSBefore {AllFieldsIDSBefore}" + spatial_coordinates = list(spatial_coordinates)[0] def get_coordinate_symbol_assignment(name):