-
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
[async] Support SFG-level DSE for scalar SNodes #1907
Conversation
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.
Thank you! I would leave the control_flow_graph
part to @xumingkuan but everything else LGTM!
stats = ti.get_kernel_stats() | ||
stats.clear() | ||
|
||
for _ in range(5): |
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.
for _ in range(5): | |
for _ in range(2): |
Does this make the test stricter?
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.
Actually the DSE works pretty deterministically :) I just wasn't sure if it was a good idea to be very specific about how many DSE has been done..
Co-authored-by: Yuanming Hu <yuanming-hu@users.noreply.github.com>
Co-authored-by: Yuanming Hu <yuanming-hu@users.noreply.github.com>
Co-authored-by: Yuanming Hu <yuanming-hu@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## master #1907 +/- ##
=======================================
Coverage 43.83% 43.83%
=======================================
Files 45 45
Lines 6194 6194
Branches 1100 1100
=======================================
Hits 2715 2715
Misses 3310 3310
Partials 169 169 Continue to review full report at Codecov.
|
34c56a7
to
2989b55
Compare
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.
The control_flow_graph
part LGTM!
d8ea33d
to
51f9219
Compare
Sorry for this large change. It shouldn't be as complicated as the size implies.. The approach is basically to find out those scalar SNodes whose values are not read by the successor tasks. We then pass in these SNodes to the CFG pass, and instruct the live variable analysis not to add them into the final node's
live_gen
.There are a few special handlings for scalar SNodes here:
GlobalStoreStmt
when constructing the task meta, we add the SNode to the input (reader) states, iff. it is not a scalar.taichi/taichi/program/async_utils.cpp
Lines 127 to 130 in 3aeff7c
SFG::optimize_dead_store()
, if the state forms a flow edge, we also check if it's a scalar and if the successor task actually reads it.taichi/taichi/program/state_flow_graph.cpp
Lines 800 to 801 in 3aeff7c
serial
tasks. I also made them handle scalars as well.taichi/taichi/ir/control_flow_graph.cpp
Line 403 in 3aeff7c
Finally, the optimization result is cached, much like what @xumingkuan has done in #1889.
Related issue = #742
[Click here for the format server]