-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for docsite-preview canceled.
|
dream189free
approved these changes
May 8, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM~
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
compile_to_offloads
function and move it to theoffload_to_executable
function (link, link, link)ScalarizeLocalPointers
toScalarizePointers
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)MatrixInitStmt
instead of multipleGlobalStoreStmt
s in theExtractLocalPointers
class (link)visit
function forMatrixPtrStmt
in theScalarizePointers
class to improve the readability of the code (link)visit
function forMatrixPtrStmt
in theScalarizePointers
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)visit
function forOffloadedStmt
in theExtractLocalPointers
class to ensure that the extraction process is applied to each offloaded task, which may contain new local pointers introduced by scalarization (link)