DIP 1024--Shared Atomics--Community Review Round 1

Gregor Mückl gregormueckl at gmx.de
Wed Oct 16 18:43:30 UTC 2019

On Tuesday, 15 October 2019 at 11:28:24 UTC, Ola Fosheim Grøstad 
> On Tuesday, 15 October 2019 at 10:25:54 UTC, Gregor Mückl wrote:
>> generated by at most one of the running threads. So there is 
>> no need to synchronize memory writes when the underlying 
>> hardware architecture provides sufficient cache coherency 
>> guarantees.
> So what you basically is saying is that a low level language 
> should be careful about assuming a particular hardware model 
> and leave more to intrinsics and libraries. I think that is 
> reasonable, because hardware does change and concurrent 
> programming strategies change.

I'm not sure if this is quite what I'm saying. I guess I'm fine 
with the compiler telling me that a piece of code tries to access 
shared data without any annotation that this is what is desired. 
In my opinion, it then needs to be up to the developer to deal 
with this. It is *not* OK for the compiler to go and secretly 
insert synchronization mechanisms (memory barriers, atomic 
operations, etc...) behind the developer's back. If such an 
automatism must exist, it also must be invoked by the developer 
explicitly ("Computer, generate automatic synchronization!"). And 
there must be a way to tell the compiler that the developer is a 
responsible adult who knows what he/she is doing and that the 
code is OK for reasons unknown to the compiler.

More information about the Digitalmars-d mailing list