On 07/11/2016 03:23 PM, ag0aep6g wrote:
I think I would prefer if the compiler would generate atomic operations,

Backpedaling on that one.

With automatic atomic loads and stores, one could accidentally write this:

    shared int x;
    x = x + 1; /* atomic load + atomic != atomic increment */

Easy to miss the problem, because the code looks so innocent.

But when the atomic loads and stores must be spelled out it would look like in my original post:

    shared int x;
    atomicStore(x, atomicLoad(x) + 1);

Way more obvious that the code isn't actually thread-safe.

So now I'm leaning towards requiring the verbose version.

Reply via email to