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

feat[next][dace]: DaCe support for temporaries #1351

Merged
merged 32 commits into from
Feb 6, 2024

Conversation

edopao
Copy link
Contributor

@edopao edopao commented Oct 19, 2023

Description

Lift operators are removed by an ITIR transformation by introducing temporaries. Temporaries are implemented in DaCe backend as transient arrays. This PR adds extraction of temporaries and generation of corresponding transient arrays in the SDFG representation.

@edopao edopao changed the title feat[next]: Dace support for temporaries feat[next]: DaCe support for temporaries Oct 19, 2023
@edopao edopao requested a review from petiaccja October 20, 2023 11:19
@edopao edopao marked this pull request as ready for review October 20, 2023 11:19
@edopao edopao force-pushed the dace-temporaries branch 2 times, most recently from e2564f8 to 326748a Compare October 20, 2023 19:34
Copy link
Contributor

@tehrengruber tehrengruber left a comment

Choose a reason for hiding this comment

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

Drive-by review.

@edopao
Copy link
Contributor Author

edopao commented Oct 23, 2023

@tehrengruber Thank you for the review comments. At last week's DaCe workshop, we were informed that array offsets will be deprecated in DaCe. The reason is that offsets are difficult to translate across nested-SDFG boundaries, and therefore very error prone during SDFG transformation. Currently the domain of temporary fields contains offsets in range definitions. The SDFG generated by this PR works, but It's not guarantee to still work in the future. In DaCe front-ends, in order to avoid offsets, they are running a pass to normalize all array access to be 0-based. We could discuss how to do it in ITIR as well.

Copy link
Contributor

@DropD DropD left a comment

Choose a reason for hiding this comment

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

Small changes to conform to upcomming error message guidelines.

@edopao
Copy link
Contributor Author

edopao commented Feb 5, 2024

I would like to merge this PR, in order to stop overriding lift_mode in gt4py unit tests, which is misleading. The support for temporaries will be extended once the improvement on the temporary pass is merged. This extension includes, for example, a generic ITIR pass to sanitize unicode symbols, if we still see the need for it. Another extension could be the normalization of field domain in order to avoid array offsets, if we see that DaCe cannot handle it in SDFG transformations.

@@ -189,6 +197,103 @@ def add_storage(
raise NotImplementedError()
self.storage_types[name] = type_

def generate_temporaries(
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure about the name.
What confuses me is that self.tmps are the temporaries, or not?
And later you call this function only if self.tmps is not empty, which seems a bit contradictory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, function name changed to add_storage_for_temporaries


symbol_dtype = dace.int64
tmp_symbols: dict[str, TaskletExpr] = {}
for tmp in self.tmps:
Copy link
Contributor

Choose a reason for hiding this comment

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

You spend ~70 lines on filling tmp_symbols and does not explains what the loop does or the variable represents.
But for the small loop above you write a description, this seems a bit strange.

@edopao edopao changed the title feat[next]: DaCe support for temporaries feat[next][dace]: DaCe support for temporaries Feb 5, 2024
Copy link
Contributor

@philip-paul-mueller philip-paul-mueller left a comment

Choose a reason for hiding this comment

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

There are two suggestions, however, they are not mandatory in my view, so I will approve it.

shape_var = unique_var_name()
program_sdfg.add_scalar(shape_var, symbol_dtype, transient=True)
shape_node = defs_state.add_access(shape_var)
defs_state.add_edge(
Copy link
Contributor

Choose a reason for hiding this comment

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

According to my understanding, you should be able to put even complex expressions in assignments on interstate edge.

@edopao edopao dismissed petiaccja’s stale review February 6, 2024 06:33

The pass to sanitize unicode symbols is not needed at this stage. We will introduce it in separate PR, if needed in the future.

@edopao edopao merged commit 6509dd9 into GridTools:main Feb 6, 2024
28 checks passed
@edopao edopao deleted the dace-temporaries branch February 6, 2024 06:34
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.

6 participants