-
Notifications
You must be signed in to change notification settings - Fork 418
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
Unexpected behavior of task intents with distributed forall loops #19864
Comments
@vasslitvinov / @mppf: My sense is that the two of you might have the most immediate grasp on what is going on here, though both of you are out today. |
See also #15675 #15676. Our current expectation is that records can be moved across locales without notifying the record implementation in any way. (Unlike in C++, Chapel records can be moved without calling a move constructor or anything like that, and this happens all the time with the code generated by Chapel, such as when returning a record). In the future, however, there would be some way for a record to opt in to taking some action (like serialize/deserialize) in when moving/copying across locales. So, from that standpoint, this isn't necessarily a bug. Note that we currently have chapel/modules/internal/String.chpl Lines 859 to 889 in 67e192a
So far these are undocumented but I think that we are hoping to build upon the approach of them to resolve #15675 and #15676 (by making something similar that is user facing). A different question is - in this particular case, does the compiler need to generate a "move" across locales before running the provided I.e., judging from your description of what you are seeing (I haven't run anything yet), for forall x in xs with (in r) {
assert(r.payload == 123);
} the
But, it could be doing this instead:
Arguably, it is not valid for the generated code to do the "move" above, because the original |
@twesterhout : I always forget about |
@mppf & @bradcray sorry for the delay! Your explanation, Michael, was really helpful, but I'm still a bit confused about the semantics of The following is a copy-paste of my actual code. Don't worry about the specific functions, the purpose is to illustrate the general idea: proc chpl__serialize() {
logDebug("Calling chpl__serialize(" + this.locale:string + ") ...");
return (this.locale.id, payload:c_void_ptr);
}
proc type chpl__deserialize(data) {
const (loc, payload) = data;
logDebug("Calling chpl__deserialize(" + data:string + ") ...");
var json_string : string;
on Locales[loc] {
logDebug("To JSON ...");
const c_str = ls_hs_basis_to_json(payload:c_ptr(ls_hs_basis));
defer ls_hs_destroy_string(c_str);
json_string = c_str:string;
}
return new Basis(json_string);
} What I'm trying to do is to persuade Chapel to use my custom var basis : Basis = ...;
forall x in <some distributed array> {
const localBasis = basis;
// use localBasis
} Messages such as "Calling chpl__serialize" are displayed and the program behaves as expected. However, if I do var basis : Basis = ...;
forall x in <some distributed array> with (in basis) {
// use basis
}
|
Does Remote value forwarding (RVF, the optimization that should fire serialize/deserialize) needs to know the thing that its forwarding is constant. There's no such guarantees with |
No, |
This still looks like an RVF limitation to me, and potentially an arbitrary one. But sometimes I'm too much of an optimist. I'm interested in looking into it, but can't promise much for next week :( |
Consider the following example:
The idea here is to emulate the case when the user wants to implement their custom marshaling of objects. I expected tests one and two to behave very similarly (modulo the actual number of calls to the copy constructor), but they do not.
In the first test, the second branch in the constructor is never taken. The copy constructor is always invoked with a local object.
In the second test, however, the behavior is trivial: depending on the number of locales on which you run the test, up to 3 calls to the copy constructor will be made with remote data.
@bradcray provided some explanation on Gitter:
The text was updated successfully, but these errors were encountered: