-
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
[opt] Add ExtractPointers pass for dynamic index #7051
Conversation
✅ Deploy Preview for docsite-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
for more information, see https://pre-commit.ci
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.
I was thinking MatrixInitStmt
might have the same optimization opportunity, if we change std::vector<Stmt*> elements
to sth like std::vector<std::optional<Stmt*, TypedConstant>> elements
:
%1 = ConstStmt(1);
%2 = ConstStmt(2);
%3 = MatrixInitStmt({%1, %1, %2, %2});
Ah nice point. My concern here is that |
Issue: taichi-dev#2590 ### Brief Summary Under pure `dynamic_index` setting, `MatrixPtrStmt`s are not scalarized. It actually produces `2n` more instructions (`n` `ConstStmt`s and n `MatrixPtrStmt`s) than the scalarized setting, where `n` is the number of usages of `MatrixPtrStmt`s. This PR adds `ExtractPointers` pass to eliminate all the redundant instructions. See comments in the code for details. After this PR, the number of instructions after the `scalarize()` pass of the script in taichi-dev#6933 under dynamic index reduces from 49589 to 26581, and the compilation time reduces from 20.02s to 7.82s. Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Issue: taichi-dev#2590 ### Brief Summary Under pure `dynamic_index` setting, `MatrixPtrStmt`s are not scalarized. It actually produces `2n` more instructions (`n` `ConstStmt`s and n `MatrixPtrStmt`s) than the scalarized setting, where `n` is the number of usages of `MatrixPtrStmt`s. This PR adds `ExtractPointers` pass to eliminate all the redundant instructions. See comments in the code for details. After this PR, the number of instructions after the `scalarize()` pass of the script in taichi-dev#6933 under dynamic index reduces from 49589 to 26581, and the compilation time reduces from 20.02s to 7.82s. Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Issue: #2590
Brief Summary
Under pure
dynamic_index
setting,MatrixPtrStmt
s are not scalarized. It actually produces2n
more instructions (n
ConstStmt
s and nMatrixPtrStmt
s) than the scalarized setting, wheren
is the number of usages ofMatrixPtrStmt
s. This PR addsExtractPointers
pass to eliminate all the redundant instructions. See comments in the code for details.After this PR, the number of instructions after the
scalarize()
pass of the script in #6933 under dynamic index reduces from 49589 to 26581, and the compilation time reduces from 20.02s to 7.82s.