Protecting control dependencies with volatile_if()
Protecting control dependencies with volatile_if()
Posted Jun 20, 2021 0:42 UTC (Sun) by xecycle (subscriber, #140261)Parent article: Protecting control dependencies with volatile_if()
Btw I feel a release order would be needed anyway on the write side, this form probably just exploits dependency order on the read side.
Posted Jun 20, 2021 12:08 UTC (Sun)
by Bigos (subscriber, #96807)
[Link] (1 responses)
int* ptr = READ_ONCE(slot);
This article is about cases where there is no data dependency but there is a control dependency. AFAIK most weak-memory-model architectures respect such a dependency if there is a jump instruction in the middle, but the compiler must first not reorder the instructions itself and must actually generate a jump instruction (which is not always obvious as it could be lowered to a cmove-like instruction).
Regarding memory_order_consume (and [[carries_dependency]]), the problem is with ensuring that there is a dependency without involving the type system. If instead load(std::memory_order_consume) returned Dependent<T> and the compiler promised that loads using it are either data or control dependent on the original load then it would be a lot easier to define and implement. I think this is what the following is about:
Posted Jun 21, 2021 5:40 UTC (Mon)
by xecycle (subscriber, #140261)
[Link]
Protecting control dependencies with volatile_if()
int value = READ_ONCE(ptr);
Protecting control dependencies with volatile_if()