<div class="gmail_quote">On Tue, Nov 29, 2011 at 10:35, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":1pe">Synchronization between threads frequently involves the use of spin-wait loops. These loops should make use of the PAUSE instruction to maximize performance and minimize power consumption. The PAUSE instruction can be added to application code now, as it is ignored on all known existing Intel architectures.<br>
</div></blockquote><div><br></div><div>Where are going getting this from?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":1pe">
<br>
So for Q all I need do is<br>
<br>
#define PAUSE<br>
<br>
and then use PAUSE in the spin-wait to get similar performance to the Intel?</div></blockquote></div><br><div><a href="http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/cpp/lin/compiler_c/intref_cls/common/intref_sse2_pause.htm">http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/cpp/lin/compiler_c/intref_cls/common/intref_sse2_pause.htm</a></div>
<div><br></div><div><a href="http://software.intel.com/en-us/articles/introduction-to-hyper-threading-technology/">http://software.intel.com/en-us/articles/introduction-to-hyper-threading-technology/</a></div><div><br></div>
<div><div><b>Use the PAUSE Instruction to Optimize Code</b></div><div>Intel recommends that software developers always use the PAUSE instruction in spin-wait loops.</div><div><br></div><div>Starting with the Intel® Pentium® 4 processor, this recommendation was made for the benefit of power savings. Executing a PAUSE in a spin-wait loop forces the spin-wait to finish one iteration of the loop before starting the next iteration. Halting the spin-wait loop reduces consumption of non-productive resources - and thus power.</div>
<div><br></div><div>With a Hyper-Threading Technology supported processor, using the PAUSE instruction optimizes processing of two threads. Pausing the spin-wait loop frees more resources for the other processor, allowing faster completion of its thread.</div>
</div><div><br></div><div><div><b>Use OS Synchronization Techniques on Long Waits</b></div><div>When a thread suspects a thread will take longer than an OS quantum of time before a lock is released, use OS synchronization techniques to idle the processor until the lock is released. Idling the Hyper-Threading Technology supported processor frees the locked processor to use all resources available to complete its execution. Use OS primitives to release the lock when thread execution has completed.</div>
<div><br></div><div>If a thread suspects a thread will release a lock within an OS quantum, use a spin-wait.</div></div>