Threads in the new ISO C Standard from 2011
Threads in the new ISO C Standard from 2011
Threads in the new ISO C Standard from 2011
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
More Details About Dependences<br />
Recall <strong>the</strong> <strong>in</strong>tra-thread A carries a dependency to B.<br />
The compiler becomes responsible for not optimiz<strong>in</strong>g away such<br />
dependences.<br />
This might sound trivial but is not. See below.<br />
A dependency is started with a consume operation:<br />
p = atomic_load(q, memory_order_consume);<br />
a = *p + 1;<br />
A root of a dependency tree is created with <strong>the</strong> consume, and <strong>the</strong><br />
memory read <strong>in</strong> *p becomes ordered, as we expect.<br />
The compiler or hardware is not allowed to move <strong>the</strong> *p to before <strong>the</strong><br />
first l<strong>in</strong>e which would probably not make much sense, anyway.<br />
Behaviour is as we want and expect.<br />
Jonas Skeppstedt (js@cs.lth.se) Lecture 6 2013 41 / 70