def make_field_acc(name): return sir.FieldAccessExpr(name=name, vertical_offset=0, horizontal_offset=sir.ZeroOffset())
# -*- coding: utf-8 -*- # Eve toolchain from devtools import debug # noqa: F401 import eve # noqa: F401 from gtc import common, sir from gtc.unstructured import naive_codegen, sir_to_naive field_acc_a = sir.FieldAccessExpr(name="field_a", vertical_offset=0, horizontal_offset=sir.ZeroOffset()) field_acc_b = sir.FieldAccessExpr(name="field_b", vertical_offset=0, horizontal_offset=sir.ZeroOffset()) assign_expr = sir.AssignmentExpr(left=field_acc_a, op="=", right=field_acc_b) assign_expr_stmt = sir.ExprStmt(expr=assign_expr) root = sir.BlockStmt(statements=[assign_expr_stmt]) ast = sir.AST(root=root) vert_decl_stmt = sir.VerticalRegionDeclStmt(vertical_region=sir.VerticalRegion( ast=ast, interval=sir.Interval(), loop_order=common.LoopOrder.FORWARD)) ctrl_flow_ast = sir.AST(root=sir.BlockStmt(statements=[vert_decl_stmt])) field_a = sir.Field( name="field_a", is_temporary=False, field_dimensions=sir.FieldDimensions( horizontal_dimension=sir.UnstructuredDimension( dense_location_type=sir.LocationType.Cell)),
# "0.5", SIR.BuiltinType.Float), "*", sir_utils.make_reduction_over_neighbor_expr( # "+", # sir_utils.make_field_access_expr("pp"), # sir_utils.make_literal_access_expr( # "0.0", SIR.BuiltinType.Float), # lhs_location=SIR.LocationType.Value('Edge'), # rhs_location=SIR.LocationType.Value('Vertex') # # TODO assumed iflip==0, i.e. current implementation zbc = 1 # )) # ), zavg_red = sir.ReductionOverNeighborExpr( op="+", rhs=sir.FieldAccessExpr(name="pp", vertical_offset=0, horizontal_offset=sir.ZeroOffset()), init=sir.LiteralAccessExpr( value="0.0", data_type=sir.BuiltinType(type_id=common.DataType.FLOAT64), ), chain=[sir.LocationType.Edge, sir.LocationType.Vertex], ) zavg_mul = sir.BinaryOperator( op="*", left=sir.LiteralAccessExpr( value="0.5", data_type=sir.BuiltinType(type_id=common.DataType.FLOAT64), ), right=zavg_red, ) zavg_decl = sir.VarDeclStmt(