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

[opt] Add ImmediateIRModifier to provide amortized constant-time replace_usages_with() #7001

Merged
merged 4 commits into from
Dec 30, 2022

Conversation

strongoier
Copy link
Contributor

@strongoier strongoier commented Dec 28, 2022

Issue: #6933

Brief Summary

ImmediateIRModifier aims at replacing Stmt::replace_usages_with, which visits the whole tree for a single replacement. ImmediateIRModifier is currently associated with a pass, visits the whole tree once at the beginning of that pass, and performs a single replacement with amortized constant time. It is now used in two most recent passes, eliminate_immutable_local_vars and scalarize. More passes can be modified to leverage it in the future.

After this PR, the profiling result of the script in #6933 shows that the time of eliminate_immutable_local_vars reduces from 0.956 s to 0.162 s, the time of scalarize reduces from 3.510 s to 0.478 s, and the total time of compile reduces from 8.550 s to 4.696 s.

@netlify
Copy link

netlify bot commented Dec 28, 2022

Deploy Preview for docsite-preview canceled.

Name Link
🔨 Latest commit e547fb0
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/63ae83276a30bd0009754afa

@strongoier strongoier added the full-ci Run complete set of CI tests label Dec 28, 2022
@bobcao3 bobcao3 self-requested a review December 29, 2022 23:03
@bobcao3
Copy link
Collaborator

bobcao3 commented Dec 29, 2022

/rerun

@strongoier
Copy link
Contributor Author

/rebase

@bobcao3
Copy link
Collaborator

bobcao3 commented Dec 30, 2022

/rerun

@strongoier strongoier merged commit 26b81e7 into taichi-dev:master Dec 30, 2022
@strongoier strongoier deleted the compile-speed branch December 30, 2022 14:03
feisuzhu pushed a commit to feisuzhu/taichi that referenced this pull request Jan 5, 2023
…ace_usages_with() (taichi-dev#7001)

Issue: taichi-dev#6933

### Brief Summary

`ImmediateIRModifier` aims at replacing `Stmt::replace_usages_with`,
which visits the whole tree for a single replacement.
`ImmediateIRModifier` is currently associated with a pass, visits the
whole tree once at the beginning of that pass, and performs a single
replacement with amortized constant time. It is now used in two most
recent passes, `eliminate_immutable_local_vars` and `scalarize`. More
passes can be modified to leverage it in the future.

After this PR, the profiling result of the script in taichi-dev#6933 shows that
the time of `eliminate_immutable_local_vars` reduces from `0.956 s` to
`0.162 s`, the time of `scalarize` reduces from `3.510 s` to `0.478 s`,
and the total time of `compile` reduces from `8.550 s` to `4.696 s`.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels pushed a commit to quadpixels/taichi that referenced this pull request May 13, 2023
…ace_usages_with() (taichi-dev#7001)

Issue: taichi-dev#6933

### Brief Summary

`ImmediateIRModifier` aims at replacing `Stmt::replace_usages_with`,
which visits the whole tree for a single replacement.
`ImmediateIRModifier` is currently associated with a pass, visits the
whole tree once at the beginning of that pass, and performs a single
replacement with amortized constant time. It is now used in two most
recent passes, `eliminate_immutable_local_vars` and `scalarize`. More
passes can be modified to leverage it in the future.

After this PR, the profiling result of the script in taichi-dev#6933 shows that
the time of `eliminate_immutable_local_vars` reduces from `0.956 s` to
`0.162 s`, the time of `scalarize` reduces from `3.510 s` to `0.478 s`,
and the total time of `compile` reduces from `8.550 s` to `4.696 s`.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full-ci Run complete set of CI tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants