On 9 Mar 2014 at 10:31, Jonathan Wakely wrote:
Can tsan understand when an atomic is being used for serialisation? I can see a CAS lock being heuristically determined, but some of the fancier semaphore based techniques surely need some explicit markup.
I believe it can, because it knows that an atomic store with memory_order_release in one thread and a load with memory_order_acquire in another thread implies an ordering, and so can tell there is no race.
The reason I'm suspicious this is the case is because valgrind doesn't do this, yet it certainly can tell atomic ops from non-atomic ones (besides, on x86/64 loads always acquire and stores always release anyway). I can see maybe that the compiler knows things that valgrind cannot, but I guess we're probably speculating now.
I don't think tsan v2 even supports any explicit markup, so you couldn't use it if you wanted to.
Sure, but tsan v2 is very explicitly said to be unfinished, and really its huge utility right now is that it's usably quick compared to DRD or helgrind rather than having a superior feature set. There's some design document for tsan v2 around which had a list of stuff they planned, can't seem to find it now. Niall -- Currently unemployed and looking for work in Ireland. Work Portfolio: http://careers.stackoverflow.com/nialldouglas/