Do not merge: working PR for NASA crew#2364
Draft
romanc wants to merge 16 commits into
Draft
Conversation
2 tasks
alexnick83
suggested changes
May 11, 2026
alexnick83
left a comment
Contributor
There was a problem hiding this comment.
This looks fine. I would add a test that demonstrates the issue described in the PR (up/downcasting of data) and confirms that it is now resolved. I guess just one test for, e.g., asin would be enough.
Contributor
Author
|
Make sense, I'll add something tomorrow. I think I can build upon |
7 tasks
Contributor
Author
|
putting this back into a draft state because it is now our de-facto working branch and I've started to push more unrelated changes. I'll pull this apart later and make nice PRs with unrelated changes and tests. |
math.hPlease enter the commit message for your changes. Lines starting
Names/Labels of LoopRegions need to be unique inside the CFG (validation checks that). So far, we didn't have problems. However, with "no simplify before stree", we are getting in places where this is an issue. This commit deploys a simple fix to ensure unique names of LoopRegions.
Every tree node has functions to calculate input and output memlets (of that node). Tree scopes have a default implementation to gather all inputs/outputs of their children. That default implementation for scopes didn't consider read after write (within the same scope). This caused "too many inputs" to be returned, which - in turn - caused the dependency analysis of the state boundary inserter to generate wrong results. This could lead to **missing** state boundaries. We saw write/write races in D2A2C_Vect of pyFV3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
dace/math.hre-exposes a couple of math functions fromcmath, e.g.std::sin(x), which has overloads for e.g.floatanddouble. Some functions, e.g.asin(x), were not exposed in this way. This leads to precision issues whenasin(x)is called with afloatbecause in the generated code,asinwill be mapped to the C version, which is only defined for doubles. There is thus an implicit cast happening of the argument and the computation is done in double precision. Worse, the return type is always adouble, which will force the rest of the calculation to be up-casted to double precision ifasin()is used in an expression.TODO list for later
std::log10(x)in a cpp-tasklet)memlets_in_ast()(subscript access, scalar access, indirect array access)memlets_in_ast()memlets_in_ast()is reliable, we can inline conditionals and loop condition/update (in stree as well as in gt4py bridge)tn.IfScope/tn.ElifScope/tn.ElseScopetotn.ConditionalScope