-
Notifications
You must be signed in to change notification settings - Fork 419
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
Dyno: resolve foo()
to foo(standalone)
if serial version of the iterator is not available.
#26023
Merged
DanilaFe
merged 12 commits into
chapel-lang:main
from
DanilaFe:reresolve-serial-to-parallel
Oct 4, 2024
Merged
Dyno: resolve foo()
to foo(standalone)
if serial version of the iterator is not available.
#26023
DanilaFe
merged 12 commits into
chapel-lang:main
from
DanilaFe:reresolve-serial-to-parallel
Oct 4, 2024
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
Signed-off-by: Danila Fedorin <[email protected]>
This will help knowing when to re-resolve calls if they fail Signed-off-by: Danila Fedorin <[email protected]>
…call Signed-off-by: Danila Fedorin <[email protected]>
…ters Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
…able David's test Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Anna Rift <[email protected]>
Signed-off-by: Anna Rift <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
2 tasks
Noting this will now also resolve https://github.com/Cray/chapel-private/issues/6720 |
dlongnecke-cray
approved these changes
Oct 3, 2024
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.
LGTM
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.
Closes https://github.com/Cray/chapel-private/issues/6720 by rolling in a minor fix (see 8320546)
This PR intends to address a longstanding concern with the leader/follower API design in which to use a parallel iterator, you need to define a serial iterator as well. Thus, you can't iterate over
foo()
if onlyfoo(standalone)
orfoo(leader)/foo(follower)
are defined. This PR implements this, detecting calls to iterators that were discarded only because of thetag
/followThis
arguments, and re-trying them with the tags in priority order.The key observation is that the formal-actual map, when it's checking alignment, is actually very well positioned to determine if a call is valid with the exception of missing a
tag
argument: it iterates over all formals of a potential candidate, and checks if they have a corresponding actual. Thus, if the following conditions are met, we have candidate that was rejected by may constitute a parallel version of the current call:tag
andfollowThis
If this situation is detected, I store the candidate in a separate list of "rejected iterator candidates". This is intended for future optimization opportunities; see the "Optimization Opportunities" section below. The presence of rejected candidates is propagated to the
CallResolutionResult
. Other code (currently, theCall*
handling in the resolver) can check theCallResolutionResult
, and attempt to re-run resolution withiterKind.standalone
if it failed before. I added logic that does this, storing the repeated resolution attempts as associated actions.The fact that all call handling uniformily approaches re-resolving with
tag
means that parallel iterators are invoked in other contexts thanfor
loops; returning afoo()
from a function, or storing it in a variable, is still an acceptable way to invoke astandalone
-only version offoo
.Optimization Opportunities
The call resolution process has a lot of steps, including handling last resort candidates, forwarding, and POI scopes. In my opinion, the re-written (
foo()
->foo(standalone)
) calls should still obey the same rules as all other calls for overloading and candidate selection (meaning they should respect last-resort candidates, "distance", forwarding order etc.). My original intention was to simply treat "fallback" iterator functions as another kind of last resort candidate, and thus haveresolveCall
succeed forfoo()
by rewriting the call tofoo(standalone)
where appropriate. However, this would effectively require a duplication of all handling for last-resort candidates (we'd need "last resort groups" and "last-resort groups of fallback iterators", for example), and generally seems to increase complexity dramatically.As a result, I went with the "set a flag on CallResolutionResult" approach. Calling code can re-invoke
resolveCall
with the necessary tag arguments, and call resolution would take care (as it normally does) of precedence, forwarding, receivers, etc. The disadvantage here is that there is likely a lot of overlap when collecting candidates (into a vector of IDs), and that this work is likely performed multiple times in such a case. TherejectedIteratorsMissingTag
field is intended as a stub that can be grown if we choose to re-attempt the approach from the previous paragraph, and handle the fallback iterator functions in a single pass.Reviewed by @dlongnecke-cray -- thanks!
Testing