-
Notifications
You must be signed in to change notification settings - Fork 441
Fix toArray() for standard collections of non-default initializable records (lists, sets, …) #28259
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
Fix toArray() for standard collections of non-default initializable records (lists, sets, …) #28259
Conversation
…types --- Signed-off-by: Brad Chamberlain <[email protected]>
|
@jabraham17 : Would you be up for giving this a review? |
jabraham17
left a comment
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.
looks good!
--- Signed-off-by: Brad Chamberlain <[email protected]>
…ap use While testing my new test, I found that it was getting weird behavior when running on multiple locales, due to having the map live on one locale and the task running the iterator on another. I'm not sure what's causing this, so added a future capturing the behavior and avoided the remote iteration in my new test for now. --- Signed-off-by: Brad Chamberlain <[email protected]>
--- Signed-off-by: Brad Chamberlain <[email protected]>
In re-reviewing my PR this morning, I realized that I'd mis-named the .bad file. Associating it with the future test (-loc.chpl) causes failures due to differing behaviors on different runs, so I'm just removing the .bad file instead. Meanwhile, I tightened up the SKIPIF to only apply to the future since the other case works with or without comm=none --- Signed-off-by: Brad Chamberlain <[email protected]>
|
@jabraham17 : As discussed on slack, I've expanded the original PR you reviewed to cover Map, Set, and Heap as well, and to add a future for a bug in Map that I ran across along the way. If you could re-review (or just review the diff between your last review and now), I'd appreciate it. |
--- Signed-off-by: Brad Chamberlain <[email protected]>
This PR rewrites
list.toArray()to avoid the use of an on-clause, and therefore the delayed initialization of the temporary array being returned, in order to resolve #28201 and #28202. It also adds a test based on the code in #28201, though extends it to do cross-locale calls to ensure that everything works in single- and multi-locale settings (acrosscomm=nonevs.!=nonetesting configurations).As noted in #28201 (comment), this rewrite could have an adverse impact on performance if the list is on a distinct locale from the task calling
.toArray(), but I think this is the right change all the same since (a) correctness and generality are more important than performance and (b) the case where the list and calling task are on distinct locales seems unlikely to be a frequent occurrence in practice. Moreover, for the case where the two are co-located, this should accelerate things by avoiding the creation/copy of a second array (though perhaps we would have successfully stolen it anyway?).Ultimately, if/when we care about optimizing performance, we should probably use bulk copies from the list's sub-arrays to the result array anyway, which would be faster for both the co-located and distributed cases.
That original fix was then propagated to the other standard collection types (sets, maps, heaps) and tests were added for them as well. The one case that's not as strong as the others is the map version, which results in undefined behavior when run on multiple locales due to #28266 and this PR includes a future in support of that (new) issue.
Resolves #28201
Resolves #28202