_mm_pause usage in gcc on Intel
<p>I have refered to this webpage :
<a href="https://software.intel.com/en-us/articles/benefitting-power-and-performance-sleep-loops" rel="noreferrer">https://software.intel.com/en-us/articles/benefitting-power-and-performance-sleep-loops</a>  ,  the following I can not understand :</p>

<blockquote>
  <p>the pause instruction gives a hint to the processor that the calling thread is in a "spin-wait" loop. In addition, the pause instruction is a no-op when used on x86 architectures that do not support Intel SSE2, meaning it will still execute without doing anything or raising a fault. While this means older x86 architectures that don’t support Intel SSE2 won’t see the benefits of the pause, it also means that you can keep one straightforward code path that works across the board.</p>
</blockquote>

<p>I like to know ,  lscpu in linux will showes  cpu information , but I have no idea  if the cpu i have support SSE2 or not ,  how can I check it myself ?!</p>

<pre><code>Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                24
On-line CPU(s) list:   0-23
Thread(s) per core:    2
Core(s) per socket:    6
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 63
Model name:            Intel(R) Xeon(R) CPU E5-2643 v3 @ 3.40GHz
Stepping:              2
CPU MHz:               3599.882
BogoMIPS:              6804.22
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              20480K
NUMA node0 CPU(s):     0,2,4,6,8,10,12,14,16,18,20,22
NUMA node1 CPU(s):     1,3,5,7,9,11,13,15,17,19,21,23
</code></pre>

<p>Also , currently I use _mm_pause  or  __asm volatile ("pause" ::: "memory");
the  cpu idle will be exhausted to zero  in that core ,  but the following code using nanosleep  is too slow for me :</p>

<pre><code>while(1){
    nanosleep();
    dosomething..... ; 
}
</code></pre>

<p>I observe nanosleep will delayed 60 microseconds in my box , Is there any solution  faster than nanosleep   also not to exhaust cpu core like _mm_pause() or __asm volatile ("pause" ::: "memory")  ?! </p>

<p>Edit :</p>

<pre><code>struct timespec req={0};
req.tv_sec=0;
req.tv_nsec=100 ;
nanosleep(&amp;req,NULL) ;
</code></pre>

<p>This  nanosleep cost 60 microseconds in the box I have which cpu is above ,
I have no idea how come it happened ?!</p>