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

[Bug] [opt] [doc] Fix OffsetAndExtractBitsStmt optimization and improve documentation on virtual/physical indices #1259

Merged
merged 2 commits into from Jun 16, 2020

Conversation

yuanming-hu
Copy link
Member

Comment on lines 210 to 217
int SNode::get_num_bits(int virtual_index) const {
int result = 0;
const SNode *snode = this;
auto physical_index = snode->physical_index_position[virtual_index];
while (snode) {
result += extractors[physical_index].num_bits;
result += snode->extractors[physical_index].num_bits;
snode = snode->parent;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

There are two issues here:

  • We should use virtual indices as input and do a translation to physical indices within the function (see the doc updates)
  • snode->extractors instead of extractors :-)

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the second point, sorry for writing a bug here :)

For the first point, I think we're already using physical indices in LoopIndexStmts. See

Stmt *loop_index = new_statements.push_back<LoopIndexStmt>(
new_for.get(), snode->physical_index_position[i]);

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah you are right! I just now reverted that modification.

Copy link
Collaborator

@xumingkuan xumingkuan left a comment

Choose a reason for hiding this comment

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

LGTM in general, but I'm not sure if get_num_bits should take virtual_index as input.

Comment on lines 210 to 217
int SNode::get_num_bits(int virtual_index) const {
int result = 0;
const SNode *snode = this;
auto physical_index = snode->physical_index_position[virtual_index];
while (snode) {
result += extractors[physical_index].num_bits;
result += snode->extractors[physical_index].num_bits;
snode = snode->parent;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the second point, sorry for writing a bug here :)

For the first point, I think we're already using physical indices in LoopIndexStmts. See

Stmt *loop_index = new_statements.push_back<LoopIndexStmt>(
new_for.get(), snode->physical_index_position[i]);

taichi/transforms/ir_printer.cpp Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 16, 2020

Codecov Report

Merging #1259 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1259      +/-   ##
==========================================
+ Coverage   84.78%   84.81%   +0.02%     
==========================================
  Files          18       18              
  Lines        3267     3273       +6     
  Branches      613      615       +2     
==========================================
+ Hits         2770     2776       +6     
  Misses        360      360              
  Partials      137      137              
Impacted Files Coverage Δ
python/taichi/lang/snode.py 77.33% <100.00%> (+1.97%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 035bcb9...3c7a297. Read the comment docs.

Copy link
Collaborator

@xumingkuan xumingkuan left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM.

@yuanming-hu yuanming-hu merged commit 7738915 into taichi-dev:master Jun 16, 2020
@FantasyVR FantasyVR mentioned this pull request Jun 17, 2020
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.

None yet

2 participants