-
Notifications
You must be signed in to change notification settings - Fork 44
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
Copy / Assignment of dash::Atomic #289
Comments
For now, I added self_t & operator=(const self_t & other) = default; But assignment is still explicitly deleted, so this is not well-defined. |
Yes, that should be fixed. From the type-safety side it would be best to disable all forms of assignment, because the member is always set by DART using memory copy. But if all assignments are disabled, the dash algorithms like AFAIK we have the following options:
|
It's actually to be expected that Similarily, you can;t use In general terms: semantics have priority over algorithm convenience. Especially for non-trivial types like atomics. Assignment and conversion (oh my!) should not be allowed. We might be able to make |
With some knowledge gained the last couple of month, I want to re-think the topic:
No, not really as the assignment operator of
That is only partially correct:
Yes, and the way I intend to do this is by using iterator traits. With the stuff in PR #310 and #300 , it will be easy to switch the algorithm to use an non-localized version (working on the local part, but using DART) . After merging these PRs, I will take care of fixing the implementation. |
Yes, and as fill does not provide emplace the elements have to exist, that's what I wrote. On using iterator traits to dictate the behavior of So if I got your point, you want to specialize First, what's the category of this trait? We would have to invent one. That is, there will be a new category of iterator properties which is orthogonal to all traits that actually specify iterator properties. Then: iterators, hence the name, are a concept for iteration. That's what the iterator tags in the STL all are about: to specify / restrict positioning in the iteration space. But perhaps I got your point wrong in the first place. PS: If the STL consistently does not allow a specific usage (like removing and returning an element in a single operation or turning an address into an atomic reference in mid-air), this is a strong indication that there are reasons not to do it. |
Let me give a short explanation, as multiple people asked me about this issue. I'll try to keep it as brief as possible: Basics
No local accesses to a The atomicity of operations on an dash::Array<dash::Atomic> arr(10);
*(arr.lbegin()) = 1; // must not compile To prohibit this bypassing of the atomic semantics, the corresponding operators are disabled for the atomic type. In this context a differentiation between physical and logical local ranges is important, as pointed out in PR #371. While Performance tuning in DASH algorithms For gaining performance, the DASH algorithms (e.g. How iterator traits can help A common thing with all STL / DASH algorithms is that they take iterators as input. The properties of the iterators can then be accessed using traits, e.g.
This is the point where my idea kicks in: By using the This is perfectly well-defined, as both algorithm variants generate the same output (for a given input). Similar implementations in the STL/Boost For example, @fuchsto see this example for what I meant with |
We discussed this live already, just for documentation: Yes! Looks correctly right to me, will be robust for STL algos. Columbo turning around right before the door Sir ... just one more question. We didn't actually discuss alternatives to the And now we put enable_if-duck tape on algorithms ... because of a GlobRef specialization ... So, assuming there is no better alternative, we would have to add a enable_if-Guard to every interface of any function where GlobPtr / GlobIter are dereferenced to native pointers. Really try to imagine the moment you explain this to an application developer with a straight face, in full color. And then really envision how you add "... and that's cool, because there is no way STL algorithms could break it!" You know, I know, but I'm not sure the world is ready for this. |
Question on
dash::Atomic
:Why is the copy constructor deleted, but assignment is not?
operator=(T)
is deletedoperator=(const self_t &)
is implicitly defaultedThat can't be right
When I explicitly delete assignment, tests don't compile
Also, the constructor
Atomic(T)
is not marked explicit, so it's an implicit conversion constructorWhat's the intended semantics here?
The current implementation contradicts the documentation in dash/include/dash/Atomic.h
The text was updated successfully, but these errors were encountered: