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

[Lang] Migrate irpass::scalarize() after irpass::detect_read_only() #7939

Merged
merged 8 commits into from
May 8, 2023

Conversation

jim19930609
Copy link
Contributor

@jim19930609 jim19930609 commented May 6, 2023

Issue: #

Brief Summary

🤖 Generated by Copilot at e7b3921

This pull request refactors the IR scalarization pass and the local pointer extraction pass, and moves the scalarization pass to a later stage in the compilation pipeline. These changes aim to separate the IR transformation and code generation stages, and to enable more optimizations for scalarized matrices.

Walkthrough

🤖 Generated by Copilot at e7b3921

  • Refactor the IR transformation and code generation stages to separate the scalarization pass from the compile_to_offloads function and move it to the offload_to_executable function (link, link, link)
  • Add a full simplification pass after scalarization to optimize the scalarized IR and eliminate redundant statements (link)
  • Rename the class ScalarizeLocalPointers to ScalarizePointers and update the constructor to reflect its ability to handle both local and global matrix pointers, as well as matrix pointers from external arrays (link, link, link)
  • Simplify the logic for initializing a local tensor with zero values by using a MatrixInitStmt instead of multiple GlobalStoreStmts in the ExtractLocalPointers class (link)
  • Move the comment explaining the logic of the visit function for MatrixPtrStmt in the ScalarizePointers class to improve the readability of the code (link)
  • Add a new logic branch to the visit function for MatrixPtrStmt in the ScalarizePointers class to handle the case where the matrix pointer originates from a global temporary statement, and simplify the global temporary statement by adding the matrix offset to the original offset (link)
  • Add a new visit function for OffloadedStmt in the ExtractLocalPointers class to ensure that the extraction process is applied to each offloaded task, which may contain new local pointers introduced by scalarization (link)

@netlify
Copy link

netlify bot commented May 6, 2023

Deploy Preview for docsite-preview canceled.

Name Link
🔨 Latest commit 70f2171
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/645854c5bf546a0008cb84d5

Copy link
Contributor

@dream189free dream189free left a comment

Choose a reason for hiding this comment

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

LGTM~

@jim19930609 jim19930609 merged commit 751dd59 into taichi-dev:master May 8, 2023
quadpixels pushed a commit to quadpixels/taichi that referenced this pull request May 13, 2023
…aichi-dev#7939)

Issue: #

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at e7b3921</samp>

This pull request refactors the IR scalarization pass and the local
pointer extraction pass, and moves the scalarization pass to a later
stage in the compilation pipeline. These changes aim to separate the IR
transformation and code generation stages, and to enable more
optimizations for scalarized matrices.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at e7b3921</samp>

* Refactor the IR transformation and code generation stages to separate
the scalarization pass from the `compile_to_offloads` function and move
it to the `offload_to_executable` function
([link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-8fde186587db97b3bbc8a856e59bc4467b30257335b0fad064b4eebd521a912bL130-L137),
[link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-8fde186587db97b3bbc8a856e59bc4467b30257335b0fad064b4eebd521a912bR182-R189),
[link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-97b0d9ab204b703802b3b5d04d036d30f66b34b726128216faf0d8a2a8564528L1121-R1157))
* Add a full simplification pass after scalarization to optimize the
scalarized IR and eliminate redundant statements
([link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-8fde186587db97b3bbc8a856e59bc4467b30257335b0fad064b4eebd521a912bR182-R189))
* Rename the class `ScalarizeLocalPointers` to `ScalarizePointers` and
update the constructor to reflect its ability to handle both local and
global matrix pointers, as well as matrix pointers from external arrays
([link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-97b0d9ab204b703802b3b5d04d036d30f66b34b726128216faf0d8a2a8564528L884-R884),
[link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-97b0d9ab204b703802b3b5d04d036d30f66b34b726128216faf0d8a2a8564528L893-R893),
[link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-97b0d9ab204b703802b3b5d04d036d30f66b34b726128216faf0d8a2a8564528L1121-R1157))
* Simplify the logic for initializing a local tensor with zero values by
using a `MatrixInitStmt` instead of multiple `GlobalStoreStmt`s in the
`ExtractLocalPointers` class
([link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-d47b571f975c1002b8cb93634ac2a3d5f090f3fa9676ec3e0004c2ec4116ee21L536-R548))
* Move the comment explaining the logic of the `visit` function for
`MatrixPtrStmt` in the `ScalarizePointers` class to improve the
readability of the code
([link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-97b0d9ab204b703802b3b5d04d036d30f66b34b726128216faf0d8a2a8564528L951-R960))
* Add a new logic branch to the `visit` function for `MatrixPtrStmt` in
the `ScalarizePointers` class to handle the case where the matrix
pointer originates from a global temporary statement, and simplify the
global temporary statement by adding the matrix offset to the original
offset
([link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-97b0d9ab204b703802b3b5d04d036d30f66b34b726128216faf0d8a2a8564528L982-R1010))
* Add a new `visit` function for `OffloadedStmt` in the
`ExtractLocalPointers` class to ensure that the extraction process is
applied to each offloaded task, which may contain new local pointers
introduced by scalarization
([link](https://github.com/taichi-dev/taichi/pull/7939/files?diff=unified&w=0#diff-97b0d9ab204b703802b3b5d04d036d30f66b34b726128216faf0d8a2a8564528R1058-R1065))
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