Skip to content

Experimental Inline Pass#1153

Draft
mroethlin wants to merge 11 commits intoMeteoSwiss-APN:masterfrom
mroethlin:experimentalInlinePass
Draft

Experimental Inline Pass#1153
mroethlin wants to merge 11 commits intoMeteoSwiss-APN:masterfrom
mroethlin:experimentalInlinePass

Conversation

@mroethlin
Copy link
Copy Markdown
Contributor

@mroethlin mroethlin commented Aug 10, 2021

DO NOT MERGE, HAS CONCEPTUAL ISSUES

Technical Description

The inlining pass present in dawn (PassInlining) is not designed to inline computations within stencils, but inlines stencil functions. It is also untested. This PR is a proof of concept a simple inlining pass that argues over computations within a single stencil scope. It performs one time temporary inlining if and only if the result is story into temporary field or var that is only written to once.

Example

def subseq(inF: Field[Cell], outF: Field[Vertex]):
  tempF: Field[Edge]
  with domain.upward:
    tempF = sum_over(Edge > Cell, inF)   
    outF = sum_over(Vertex > Edge, tempF)

is inlined to

def subseq(inF: Field[Cell], outF: Field[Vertex]):
  with domain.upward:
    outF = sum_over(Vertex > Edge, sum_over(Edge > Cell, inF))

No attempt is made to inline e.g.

def subseq(inF: Field[Cell], outF: Field[Vertex]):
  tempF: Field[Edge]
  with domain.upward:
    tempF = sum_over(Edge > Cell, inF)   
    tempF = tempF + 1 
    outF = sum_over(Vertex > Edge, tempF)

Testing

Two tests reflecting the examples above are introduced.

Dependencies

This PR is independent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant