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
Reduce loop cloning in fast followers #16229
Merged
e-kayrakli
merged 11 commits into
chapel-lang:master
from
e-kayrakli:static-fast-follower
Aug 13, 2020
Merged
Reduce loop cloning in fast followers #16229
e-kayrakli
merged 11 commits into
chapel-lang:master
from
e-kayrakli:static-fast-follower
Aug 13, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ronawho
reviewed
Aug 12, 2020
ronawho
reviewed
Aug 12, 2020
ronawho
reviewed
Aug 12, 2020
e-kayrakli
force-pushed
the
static-fast-follower
branch
from
August 12, 2020 23:32
c3ad587
to
cf250d3
Compare
ronawho
reviewed
Aug 13, 2020
ronawho
reviewed
Aug 13, 2020
ronawho
approved these changes
Aug 13, 2020
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.
👍 Left 2 minor nits, but I think the core of this looks great.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adjusts the module support for fast followers to reduce the amount of
loop cloning we do.
Initially attempted at #16001
Also see #16053, which has done
similar reductions in loop cloning that happens with fast followers
Motivation
The static check that we do today is way too lax. Because for a leader that
supports fast followers, we always have a fast loop. However that loop is unused
if any of the followers don't support fast followers and/or not of same type as
the leader.
This decision seems to be made in 2010 when fast followers were first
implemented. I assume that compiler wasn't this powerful and slow and/or there
wasn't param unfolding etc.
The commit where this was added is 0dd8331.
Citing part of it that alludes to this decision:
Where there is no strong argument for having this behavior.
I believe these type of false optimizations are the main reason for the
performance overhead of fast followers.
Approach
The fast follower implementation in general is too complicated. I think the
reason for that was we were overloading the meaning of static and dynamic checks
probably to reduce the amount of code. These checks return a bool and thus can
be used for binary choices. However, we have a more complicated taxonomy of
types w.r.t fast followers:
Arrays
followers
followers
Domains: Can lead fast followers. Can take place among other fast followers in
a zippered loop.
Other iterators: Cannot lead or generate fast followers. However, can take
place among other fast followers in a zippered loop
This PR adds three helpers (and their overloads) to distinguish these:
chpl__canHaveFastFollowers
: Returns true for an array, or a zip tuple thathas at least one array. (This check doesn't involve the specific type of the
array, it is still handled by
chpl__staticFastFollowCheck
chpl__canLeadFastFollowers
: Returns true for arrays and domains.chpl__hasInertFastFollowers
: Returns false for arrays. For a zip tuple, itreturns false if there is one array.
These helpers are used in the other existing checks to limit loop cleaning and
improve readability.
Performance
For benchmarks where fast followers are used heavily (stream, prk-stencil) there
isn't any change in compiler or application performance. We see small
improvements in benchmarks where we create fast followers unnecessarily
(cross-type array assignments/zippering are examples where this may happen).
On miniMD: I see 3 seconds faster --fast compilation on XC and locally
On SSCA2: I see 6 seconds faster --fast compilation locally, but not so much of
an improvement on XC.
The reduction in the code size is there but its impact on performance is a bit
of a hit-and-miss and depends on where you compile.
Readability Advantages
sense
true
for generic argument.Test: