Jump to page: 1 24  
Page
Thread overview
Fixing core.atomic
May 30, 2021
rm
May 30, 2021
Johan Engelen
May 30, 2021
Johan Engelen
May 30, 2021
rm
May 30, 2021
IGotD-
May 31, 2021
Zardoz
Jun 01, 2021
sarn
Jun 02, 2021
rm
Jun 02, 2021
sarn
Jun 06, 2021
rm
May 31, 2021
Guillaume Piolat
May 31, 2021
IGotD-
May 31, 2021
Paul Backus
May 31, 2021
Guillaume Piolat
May 31, 2021
Guillaume Piolat
May 31, 2021
rm
May 31, 2021
Guillaume Piolat
May 31, 2021
IGotD-
May 31, 2021
Max Haughton
May 31, 2021
Max Haughton
May 31, 2021
Max Haughton
Jun 02, 2021
rm
Jun 02, 2021
rm
Jun 02, 2021
Max Haughton
Jun 02, 2021
rm
May 30, 2021
I plan on making core.atomic more consistent and easier to use. Please provide me with your feedback.


https://github.com/rymrg/drm/blob/main/atomic.d
https://github.com/rymrg/drm/blob/main/atomic_rationale.md
May 30, 2021

On Sunday, 30 May 2021 at 20:41:29 UTC, rm wrote:

>

I plan on making core.atomic more consistent and easier to use. Please provide me with your feedback.

https://github.com/rymrg/drm/blob/main/atomic.d
https://github.com/rymrg/drm/blob/main/atomic_rationale.md

Pretty nice initiative.
fadd --> fetchadd or increment. fadd and fsub look like floatingpoint add/sub to me...

cheers,
Johan

May 30, 2021
On Sunday, 30 May 2021 at 20:41:29 UTC, rm wrote:
> I plan on making core.atomic more consistent and easier to use. Please provide me with your feedback.
>
>
> https://github.com/rymrg/drm/blob/main/atomic.d
> https://github.com/rymrg/drm/blob/main/atomic_rationale.md

I would also make the template accept more than just integral types, and only add the increment/binop functions for integral types.
May 30, 2021
On Sunday, 30 May 2021 at 20:41:29 UTC, rm wrote:
> I plan on making core.atomic more consistent and easier to use. Please provide me with your feedback.
>
>
> https://github.com/rymrg/drm/blob/main/atomic.d
> https://github.com/rymrg/drm/blob/main/atomic_rationale.md

Definitely, the D atomic library is cumbersome to use. C++ std::atomic supports operator overloading for example.

atomicVar += 1;

will create an atomic add as atomicVar is of the atomic type. D doesn't have this and I think D should add atomic types like std::atomic<T>. I like this because then I can easily switch between atomic operations and normal operations by just changing the type and very few changes.
May 31, 2021
On 30/05/2021 23:49, Johan Engelen wrote:
> On Sunday, 30 May 2021 at 20:41:29 UTC, rm wrote:
>> I plan on making core.atomic more consistent and easier to use. Please provide me with your feedback.
>>
>>
>> https://github.com/rymrg/drm/blob/main/atomic.d
>> https://github.com/rymrg/drm/blob/main/atomic_rationale.md
> 
> I would also make the template accept more than just integral types, and only add the increment/binop functions for integral types.

The plan is to support pointers as this will be really useful for lock free data structures.
Currently `isPointer` is defined  in `core.internal.traits`. So I haven't written this usage.
May 31, 2021
On Sunday, 30 May 2021 at 20:58:56 UTC, IGotD- wrote:
> On Sunday, 30 May 2021 at 20:41:29 UTC, rm wrote:
>> I plan on making core.atomic more consistent and easier to use. Please provide me with your feedback.
>>
>>
>> https://github.com/rymrg/drm/blob/main/atomic.d
>> https://github.com/rymrg/drm/blob/main/atomic_rationale.md
>
> Definitely, the D atomic library is cumbersome to use. C++ std::atomic supports operator overloading for example.
>
> atomicVar += 1;
>
> will create an atomic add as atomicVar is of the atomic type. D doesn't have this and I think D should add atomic types like std::atomic<T>. I like this because then I can easily switch between atomic operations and normal operations by just changing the type and very few changes.

Yes, please! This should be merged ASAP.
May 31, 2021
On Sunday, 30 May 2021 at 20:41:29 UTC, rm wrote:
> I plan on making core.atomic more consistent and easier to use. Please provide me with your feedback.
>
>
> https://github.com/rymrg/drm/blob/main/atomic.d
> https://github.com/rymrg/drm/blob/main/atomic_rationale.md

I have once implemented an atomic struct like this and the first thing that happened is that you would write:


s = s + 1;

Breaking atomicity.
May 31, 2021
On Monday, 31 May 2021 at 08:18:35 UTC, Guillaume Piolat wrote:
>
> I have once implemented an atomic struct like this and the first thing that happened is that you would write:
>
>
> s = s + 1;
>
> Breaking atomicity.

Yes, so the programmers must be aware of this. In C++ only the unary -= and += are supported and -- and ++.

Is it possible to overload binary operators so that they cause an compiler error? In order achieve the same s = s + 1; you need to write.

s.store(s.load() + 1)

However, the assignment operator writing s = 1 is nice instead of s.store(1).
May 31, 2021
On 31/05/2021 11:18, Guillaume Piolat wrote:
> 
> I have once implemented an atomic struct like this and the first thing that happened is that you would write:
> 
> 
> s = s + 1;
> 
> Breaking atomicity.

I don't consider this a problem. In this case you have a load and a store. This is a non-atomic RMW. On the other hand, you do get sequential consistency synchronization from this process.
May 31, 2021

On Monday, 31 May 2021 at 08:52:33 UTC, IGotD- wrote:

>

Is it possible to overload binary operators so that they cause an compiler error?

@disable opBinary should do it.

« First   ‹ Prev
1 2 3 4