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

(transform): convert to csl_stencil.apply #2803

Merged
merged 13 commits into from
Jul 5, 2024
Merged

Conversation

n-io
Copy link
Collaborator

@n-io n-io commented Jun 28, 2024

This PR implements the conversion to csl_stencil.apply op as outlined in Step 2 of #2747

The csl_stencil.apply op combines a csl_stencil.prefetch (symmetric buffer communication across a given stencil shape) with a stencil.apply.

The transformation consists of several steps:

  • When rewriting a stencil.apply, select the csl_stencil.prefetch with the biggest memory overhead (if several are present) to be fused with the apply op into a csl_stencil.apply
  • Find a suitable split of ops to be divided across the two code blocks
    • Re-order arithmetic e.g. (a+b)+c -> (c+a)+b to access, consume, and reduce data of neighbours (for input stencil only)
    • Move this into first code block, move all other ops into second code block
    • Fallback strategy: Move everything into first code block
  • Add tensor.InsertSliceOp to insert computed chunk into returned z-value tensor
  • Set up code block args
  • Move ops into new regions according to determined split
  • Translate arg usage to match new block args
  • Set up yield ops
  • Run tensor update shape on chunk region

@n-io n-io added the transformations Changes or adds a transformatio label Jun 28, 2024
@n-io n-io self-assigned this Jun 28, 2024
Copy link

codecov bot commented Jun 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.84%. Comparing base (1825c02) to head (f531936).
Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2803      +/-   ##
==========================================
+ Coverage   89.79%   89.84%   +0.04%     
==========================================
  Files         394      397       +3     
  Lines       48747    49342     +595     
  Branches     7471     7592     +121     
==========================================
+ Hits        43774    44332     +558     
- Misses       3793     3815      +22     
- Partials     1180     1195      +15     

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

xdsl/dialects/csl/csl_stencil.py Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Show resolved Hide resolved
@n-io n-io requested a review from AntonLydike July 2, 2024 15:09
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Outdated Show resolved Hide resolved
xdsl/transforms/stencil_to_csl_stencil.py Show resolved Hide resolved
@n-io n-io requested review from dk949 and AntonLydike July 4, 2024 10:41
@n-io n-io merged commit 731a3ed into main Jul 5, 2024
10 checks passed
@n-io n-io deleted the nicolai/convert-csl-stencil-apply branch July 5, 2024 07:48
n-io added a commit that referenced this pull request Jul 26, 2024
Adds a canonicalisation pass for `csl_stencil.apply`. The op takes an
empty tensor as`iter_arg`, which it does not manage itself. The
conversion pass in #2803 initialises an `iter_arg` for each instance of
`apply`. This canonicalisation pass identifies where this can be
re-used, effectively removing redundant allocations.

---------

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