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

transformations: Split varith into neighbour and own data across csl_stencil regions #3307

Merged
merged 12 commits into from
Oct 24, 2024

Conversation

n-io
Copy link
Collaborator

@n-io n-io commented Oct 16, 2024

Background: The csl_stencil.apply op does communicate-and-compute on a given stencil buffer. It holds two regions, one for processing chunks of neighbour data (of this one buffer only), and one region for processing everything else after the exchange is done. The convert-stencil-to-csl-stencil pass splits the computation of the stencil.apply op across these two regions.

The split was done in two steps, first re-ordering arith ops in the RestructureSymmetricReductionPattern, and then calling the get_ops_split function on the re-shuffled arith ops. Intuitively, the re-order pass would identify chained reductions (arith.addf, arith.mulf) and restructure them such that all neighbour data which should end up in the first region is consumed first, and the chained arith ops become easily splittable.

This PR replaces this logic by converting arith to varith, splitting the varith op into neighbour/other data in the SplitVarithOpPattern rewrite, and then proceeding with get_ops_split and everything else as before. At the end, varith is converted back to arith.

Minor improvements:

  • Constants are now always duplicated and appear on both regions, which dce can clean up

Note:

@n-io n-io added the transformations Changes or adds a transformatio label Oct 16, 2024
@n-io n-io self-assigned this Oct 16, 2024
@n-io n-io changed the title transformations: (convert-stencil-to-csl-stencil) Support varith transformations: Split varith into neighbour and own data across csl_stencil regions Oct 16, 2024
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.04%. Comparing base (8781282) to head (b83551c).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3307      +/-   ##
==========================================
- Coverage   90.06%   90.04%   -0.02%     
==========================================
  Files         446      446              
  Lines       56382    56401      +19     
  Branches     5409     5417       +8     
==========================================
+ Hits        50779    50788       +9     
- Misses       4177     4183       +6     
- Partials     1426     1430       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@n-io n-io requested review from dk949 and emmau678 October 23, 2024 09:31
@n-io n-io marked this pull request as ready for review October 23, 2024 13:01
@n-io n-io requested a review from tobiasgrosser October 23, 2024 13:34
Copy link
Collaborator

@dk949 dk949 left a comment

Choose a reason for hiding this comment

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

A few minor comments

xdsl/transforms/convert_stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/convert_stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
@n-io n-io requested a review from dk949 October 24, 2024 08:47
Copy link
Collaborator

@dk949 dk949 left a comment

Choose a reason for hiding this comment

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

Looks good to go 👍

@n-io n-io merged commit 61bf632 into main Oct 24, 2024
14 checks passed
@n-io n-io deleted the nicolai/csl-stencil-varith branch October 24, 2024 10:11
EdmundGoodman pushed a commit to EdmundGoodman/xdsl that referenced this pull request Dec 6, 2024
…stencil regions (xdslproject#3307)

Background: The `csl_stencil.apply` op does communicate-and-compute on a
given stencil buffer. It holds two regions, one for processing chunks of
neighbour data (of this one buffer only), and one region for processing
everything else after the exchange is done. The
`convert-stencil-to-csl-stencil` pass splits the computation of the
`stencil.apply` op across these two regions.

The split was done in two steps, first re-ordering arith ops in the
`RestructureSymmetricReductionPattern`, and then calling the
`get_ops_split` function on the re-shuffled arith ops. Intuitively, the
re-order pass would identify chained reductions (`arith.addf`,
`arith.mulf`) and restructure them such that all neighbour data which
should end up in the first region is consumed first, and the chained
arith ops become easily splittable.

This PR replaces this logic by converting arith to varith, splitting the
varith op into neighbour/other data in the `SplitVarithOpPattern`
rewrite, and then proceeding with `get_ops_split` and everything else as
before. At the end, varith is converted back to arith.

Minor improvements:
* Constants are now always duplicated and appear on both regions, which
`dce` can clean up

---------

Co-authored-by: n-io <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
transformations Changes or adds a transformatio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants