Open mroethlin opened 5 years ago
This is also something we are interested in here at ETH.
My suggestion on how they should be
Stmt
.
It should contain a block of statements, the loop statements, as children.
It should refer (by name or id) to an integer loop variable, whose scope is restricted to the for's block of statements.
The loop variable's range and step should be specified as 3 generic expressions (Expr
) which are members (also children) of the for statement: range_start:step:range_end
, with step!=0
.
Their interpretation (same as MATLAB) corresponds to the following C implementation:
for(int i=range_start; step>0 ? i<=range_end : i>=range_start; i+=step) {...}
Stmt
and should contain a block of loop statements as children.
No explicit loop variable here, but just a condition (Expr
) that needs to be evaluated before each loop iteration.Another approach, which may simplify our lives, would be to keep just the while
in the SIR and the IIR and let the frontend translate the for
into a while
by adding the loop variable, its initialization, its step-increment and the within-range check as loop condition.
Note: adding it to the AST will also allow to use this in the control flow.
In ICON there is pattern where a stencil has an innermost loop. This can for example be a summation over a cell local array of fixed length (e.g. computation of Gauss quadrature weights) or a
DO ... WHILE
loop to ensure convergence of a quantity (c.f.upwind_vflux_ppm_cfl
for an example).This work item is about the elicitation of detailed requirements for introducing for loops as innermost loops as an IIR concept. No code shall be written for the completion of this work item, but a detailed plan to actually follow through with a specific implementation is to be made.