-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 sharedarray indexing regression #12964
Conversation
@@ -97,6 +97,11 @@ for p in procs(d) | |||
@test d[idxl] == p | |||
end | |||
|
|||
d = SharedArray(Float64, (2,3)) | |||
for x in 1:100000 | |||
d[:,2] |
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.
This isn't quite a real test, since it doesn't explicitly fail for the reason you want it to.
How about test the return type?
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.
That would of course be the other, better way of testing this, agreed. This way you just run out of file descriptors and crash, I guess...
Good catch. They are of course fine if you always just index scalars, but I agree this should be fixed. This is one way to fix it; another would be to have |
Regarding |
Thinking about it, I believe it's better to leave |
There are, but on the other hand it means that |
True. |
Implemented now by making similar always return a non-shared array. Works, except for the unit test for #6362 in https://github.com/rened/julia/blob/shgetindex/test/parallel.jl#L184-L192 - now, the result of Also, now, there is no clean way of getting a similar shared array (which, e.g., lies on the same pids). I think is good that working on a shared array does not create new shared arrays - that should be an explicit operation. Loosing the ability to get an actually |
I'm of the opinion that |
You can always get a shared array with I am torn about changing |
I believe this is the better approach, yes. Updated the unit test for |
Ok, I'm going to trust the practical experience here. |
Fix sharedarray indexing regression
|
@amitmurthy care to comment? you have the most detailed view of this I guess! |
Actually, since I don't use this stuff in any real world applications, I would withhold any detailed opinion except to observe that while Tony's view is more purist in nature, Tim's is more practical. |
I'm not sure it is different than other types. For example, I think if it were returning something of the same type, it would be called |
Reminding me why I dislike |
I agree this isn't easy. But even if one only wanted a "modifiability" exemption, this might pass it: if it returns a SharedArray, then in principle other processes can modify elements in this new thing. If it's an Array, they can't. |
There's been some more discussion around this in packages, see JuliaStats/NullableArrays.jl#56 (comment). I really think that similar just means: "give me the best mutable subtype of AbstractArray for a given shape and element type, stemming from this source array." I hold that this operation is crucially important, and really needs to be flexible enough to be guided by practical experience. Sure, it's a subjective choice. But there's definitely value in allowing the flexibility to make good, practical choices here. |
Dunno, the subjectivity of the manual array type mapping in I guess we can try this out for a while, but for the examples of |
I agree with @tkelman, something like A + 3 should definitely return a shared array here. Otherwise it destroys the whole PGAS abstraction. |
Generic programming with array types that require certain algorithmic complexities is extremely hard. My instinct has been to make the base library correct in terms of the index=>value mapping, and then punt to the individual subtypes for specializations that provide different algorithmic complexities. But I'm learning to appreciate that a fallback with a wrong complexity class for some applications may even be worse than if it were not implemented in the first place. I'm not sure how much the base library can do here. There's no limit to how much we can divide up The question, then, is who has to pay the price of not fitting in? And where is that price the lowest? The answer may be that |
That is fine, but you are concentrating too much on computational complexity and leaving out memory / space requirements. You can have an out-of-core shared array, you cannot have one (well preserving the abstraction) if *edited |
Yes, that's precisely what I mean to say by algorithmic complexity, that is, including both space and time complexities for the data structure and common operations on it. |
Ok fair enough, |
This choice makes it extremely hard to allow |
Now that we have good views (SubArray, ReshapedArray, ReinterpretArray, MappedArray) there's a lot you can do without ever needing to create new storage. So the landscape may have changed. But it will take someone sitting down and thinking out a proposal for how to manage the issues above. EDIT: a recommendation would to be implement the change locally and see if you still like it a week later. |
#12560 got rid of pass-through
getindex
/setindex
definitions forSharedArray
. This causesgetindex(::SharedArray, ...)
to always create new shared arrays and thus quickly running out of open file handles. Instead, normal arrays should be returned. This PR reintroduces the old behavior.To trigger the problem in current master:
I think this is a blocker for 0.4, as SharedArrays are totally unusable in the current state.
cc @timholy @amitmurthy