diff --git a/boundaries/boundaryhandling.py b/boundaries/boundaryhandling.py index 264051a2afcaa13ae269230b80b174d3e9a89351..a5ea40a47d752836d83acaa79489dd8424268c2a 100644 --- a/boundaries/boundaryhandling.py +++ b/boundaries/boundaryhandling.py @@ -395,9 +395,9 @@ class BoundaryOffsetInfo(CustomCppCode): @staticmethod def _offset_symbols(dim): - return [TypedSymbol("c_%d" % (d,), create_type(np.int64)) for d in range(dim)] + return [TypedSymbol("c%s" % (d,), create_type(np.int64)) for d in ['x', 'y', 'z'][:dim]] - INV_DIR_SYMBOL = TypedSymbol("inv_dir", "int") + INV_DIR_SYMBOL = TypedSymbol("invdir", "int") def create_boundary_kernel(field, index_field, stencil, boundary_functor, target='cpu', openmp=True): diff --git a/integer_functions.py b/integer_functions.py index c60a5fb2c9bf1bc5a81ace3d95eb5c6293a0bc46..16fa97a8c694489d159502d87dac5d47370b919a 100644 --- a/integer_functions.py +++ b/integer_functions.py @@ -55,7 +55,7 @@ class modulo_ceil(sp.Function): >>> from pystencils import TypedSymbol >>> a, b = TypedSymbol("a", "int64"), TypedSymbol("b", "int32") >>> modulo_ceil(a, b).to_c(str) - '(a) % (b) == 0 ? a : ((int64_t)((a) / (b))+1) * (b)' + '((a) % (b) == 0 ? a : ((int64_t)((a) / (b))+1) * (b))' """ nargs = 2 diff --git a/transformations.py b/transformations.py index 639a4818498186a703af3a820ec968db400794fe..474fa5d6e2682c39f1cbae20a89acd4dfbae8b55 100644 --- a/transformations.py +++ b/transformations.py @@ -72,6 +72,20 @@ def get_common_shape(field_set): return shape +def get_field_accesses(expr, result=set()): + if isinstance(expr, Field.Access): + result.add(expr) + for o in expr.offsets: + get_field_accesses(o, result) + for i in expr.index: + get_field_accesses(i, result) + elif hasattr(expr, 'atoms'): + new_accesses = expr.atoms(Field.Access) + result.update(new_accesses) + for a in new_accesses: + get_field_accesses(a, result) + + def make_loop_over_domain(body, function_name, iteration_slice=None, ghost_layers=None, loop_order=None): """Uses :class:`pystencils.field.Field.Access` to create (multiple) loops around given AST. @@ -88,7 +102,10 @@ def make_loop_over_domain(body, function_name, iteration_slice=None, ghost_layer :class:`LoopOverCoordinate` instance with nested loops, ordered according to field layouts """ # find correct ordering by inspecting participating FieldAccesses - field_accesses = body.atoms(Field.Access) + field_accesses = set() + get_field_accesses(body, field_accesses) + field_accesses = {e for e in field_accesses if not e.is_absolute_access} + # exclude accesses to buffers from field_list, because buffers are treated separately field_list = [e.field for e in field_accesses if not FieldType.is_buffer(e.field)] fields = set(field_list)