Skip to content

Modified SDFGState.unordered_arglist() #1708

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

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

philip-paul-mueller
Copy link
Collaborator

This PR fixes the way how arguments are detected in scopes.

Technically this only affects GPU code generation, but it is a side effect of how the code is generated.
In GPU mode a Map is translated into one kernel, for this reason a signature must be computed (this is the reason why CPU code generation is not affected, no function call is produced).
To compute this signature the unsorted_arglist() function scans what is needed.
However, this was implemented not correctly.
Assume that AccessNode for array A is outside the map and inside the map a temporary scalar, tmp_in is defined and initialized to tmp_in = A[__i0, __i1], see also this image:

argliost_situation

If the data property of the Memlet that connects the MapEntry with the AccessNode for tmp_in is referencing A then the (old) function would find that A is needed inside, although there is no AccessNode for A inside the map.
If however, this Memlet referrers tmp_in (which is not super standard, but should be allowed), then the old version would not pick up.
This would then lead to a code generation error.

This PR modifies the function such that such cases are handled.
This is done by following all edges that are adjacent to the MapEntry (from the inside) to where the are actually originate.

Technically this only affects GPU code generation, but it is a side effect of how the code is generated.
In GPU mode a `Map` is translated into one kernel, for this reason a signature must be computed (this is the reason why CPU code generation is not affected, no function call is produced).
To compute this signature the `unsorted_arglist()` function scans what is needed.
However, this was implemented not correctly.
Assume that AccessNode for array `A` is outside the map and inside the map a temporary scalar, `tmp` is defined and initialized to `tmp = A[__i0, __i1]`.
If the `data` property of the Memlet that connects the MapEntry with the AccessNode for `tmp` is referencing `A` then the (old) function would find that `A` is needed inside, although there is no AccessNode for `A`  inside the map.
If however, this Memlet referrers `tmp` (which is not super standard, but should be allowed), then the old version would not pick up.
This would then lead to a code generation error.

This commit modifies the function such that such cases are handled.
This is done by following all edges that are adjacent to the MapEntry (from the inside) to where the are actually originate.
Copy link
Contributor

@alexnick83 alexnick83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

@alexnick83 alexnick83 added this pull request to the merge queue Oct 25, 2024
Merged via the queue into spcl:main with commit 813a2f4 Oct 25, 2024
10 checks passed
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.

2 participants