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

Rewrite IREquality to use a more compact stack instead of deep recursion #8198

Merged
merged 6 commits into from
Apr 18, 2024

Conversation

abadams
Copy link
Member

@abadams abadams commented Apr 17, 2024

Deletes a bunch of code and speeds up lowering time of local laplacian with 20 pyramid levels by ~2.5%

Also fix some cases where equal wasn't considering recently-added IR node fields like partition_policy (suggestions for some way to guarantee this can't happen would be welcome).

Also changed calls to equal(..., true) to just is_const_one

Deletes a bunch of code and speeds up lowering time of local laplacian
with 20 pyramid levels by ~2.5%
@abadams
Copy link
Member Author

abadams commented Apr 17, 2024

Now more like 4% faster, and fast enough to delete the specialized version of equal in IRMatch.cpp

@abadams abadams mentioned this pull request Apr 17, 2024
return result;
}
size_t hash(const IRNode *a, const IRNode *b) {
uintptr_t pa = (uintptr_t)a;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to comment what hash algo this is for future reference

// structs. We now need to distinguish between different C++
// pointer types (e.g. char * vs const float *). If would be nice
// if the structs were unique per C++ type. Then comparing the
// pointers above would be sufficient. Unfortunately, different
Copy link
Contributor

Choose a reason for hiding this comment

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

Highly useful comment!

void cmp(double a, double b) {
// Floating point scalars need special handling, due to NaNs.
if (std::isnan(a) && std::isnan(b)) {
} else if (std::isnan(a)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to leave the both-nan case empty? If so, please add a comment like /*deliberately empty, leave comparison state unchanged */

@steven-johnson steven-johnson self-requested a review April 18, 2024 16:11
Copy link
Contributor

@steven-johnson steven-johnson left a comment

Choose a reason for hiding this comment

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

LGTM pending comments

@abadams
Copy link
Member Author

abadams commented Apr 18, 2024

Merging. Bots were all green a few commits ago and I've only tweaked comments since then.

@abadams abadams merged commit 4e0b313 into main Apr 18, 2024
9 of 14 checks passed
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.

2 participants