Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] While loop and function create bad generation (dace:cpu) #62

Closed
FlorianDeconinck opened this issue Sep 18, 2024 · 2 comments
Closed
Assignees

Comments

@FlorianDeconinck
Copy link
Collaborator

Porting UW showed than in dace:cpu, when a gtscript.function is called within a while the system allows itself to optimize code outside of the while loop, breaking control flow.

Use case from UW.

This works for tracer 15, slope is a gtscript.function:

 temp[0,0,0] = tr0[0,0,0][15]
 temp_above[0,0,0] = tr0[0,0,1][15]
 temp_below[0,0,0] = tr0[0,0,-1][15]
 sstr0[0,0,0][15] = slope(kmask,temp,temp_above,temp_below,pmid0,pmid0_above,pmid0_below)

When written properly in a while loop, generated code is broken (sstr0 is set outside of the loop!)

n=0
while n < constants.ncnst:
  temp[0,0,0] = tr0[0,0,0][n]
  temp_above[0,0,0] = tr0[0,0,1][n]
  temp_below[0,0,0] = tr0[0,0,-1][n]
  sstr0[0,0,0][n] = slope(kmask,temp,temp_above,temp_below,pmid0,pmid0_above,pmid0_below)
  n+=1
@FlorianDeconinck FlorianDeconinck self-assigned this Sep 27, 2024
@FlorianDeconinck
Copy link
Collaborator Author

This is due to fauly CallInliner missing the While loop visitor to inline the statements of the function call. PR upcoming.

@FlorianDeconinck
Copy link
Collaborator Author

PR on gt4py: GridTools/gt4py#1669

@FlorianDeconinck FlorianDeconinck changed the title While loop and function create bad generation (dace:cpu) [Bug] While loop and function create bad generation (dace:cpu) Oct 4, 2024
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

No branches or pull requests

1 participant