<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic All I can say is that I can in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950548#M19429</link>
    <description>&lt;P&gt;All I can say is that I can reproduce the issue with mpss 3.4, 3,5 and 3.6 ; the clocksource on my MICs is set to "tsc" yet a &amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;nanosleep(50000000)&lt;/PRE&gt;

&lt;P&gt;or even&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;usleep(5000)&lt;/PRE&gt;

&lt;P&gt;result in an elapsed time of ~ 15 ms (instead of 5). This happens with both a 5120 and a 7120.&lt;/P&gt;

&lt;P&gt;It does not depend on the version of ICC used - I can also reproduce it by building a binary using gcc-for-Phi.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Apr 2016 22:52:20 GMT</pubDate>
    <dc:creator>JJK</dc:creator>
    <dc:date>2016-04-18T22:52:20Z</dc:date>
    <item>
      <title>Sleep thread issues on Xeon Phi</title>
      <link>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950544#M19425</link>
      <description>&lt;P&gt;I am attempting to use the nanosleep function (defined here:&amp;nbsp;&lt;A href="http://linux.die.net/man/2/nanosleep"&gt;http://linux.die.net/man/2/nanosleep&lt;/A&gt;) on the Xeon Phi. It is very similar to the standard (and by standard I just mean widely-used, I know there is no true standard) sleep function, but it is higher-resolution, a requirement for our software.&lt;/P&gt;
&lt;P&gt;I know that no sleep function can be perfect, except maybe on embedded software, so I came in expecting some margin of error. However, I found that asking it to sleep for 5 ms (or&amp;nbsp;5000000 nanoseconds) resulting in it sleeping for approx 20 ms on the Xeon Phi. Did I discover a hardware bug, or is this a known issue? Is there a known better way to "sleep" a thread on a Xeon Phi?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code for reproducing below:&lt;/P&gt;
&lt;P&gt;[cpp]&lt;/P&gt;
&lt;P&gt;#include &amp;lt;stdint.h&amp;gt;&lt;BR /&gt;#include &amp;lt;time.h&amp;gt;&lt;BR /&gt;#include &amp;lt;iostream&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;inline int64_t picosecondTime() {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; timespec systemtime;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; clock_gettime(CLOCK_REALTIME, &amp;amp;systemtime);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return (int64_t) ((systemtime.tv_sec * 1000000000000UL)&amp;nbsp;+ (systemtime.tv_nsec * 1000UL));&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;int main(int argc, char *argv[]) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; struct timespec tim;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; tim.tv_sec = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; //time is picosecond granularity in software&lt;BR /&gt;&amp;nbsp; &amp;nbsp; int64_t picosToSleep = 5000000000;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; //convert to nanoseconds, lowest granularity of sleep&lt;BR /&gt;&amp;nbsp; &amp;nbsp; tim.tv_nsec = picosToSleep / 1000;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; int64_t currentTime = picosecondTime();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; int err = nanosleep(&amp;amp;tim, NULL);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if (err == -1) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; std::cout &amp;lt;&amp;lt; "sleep error, disregard this test" &amp;lt;&amp;lt; std::endl;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; int64_t awokeTime = picosecondTime();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; int64_t shouldAwakeTime = (currentTime + picosToSleep);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; std::cout &amp;lt;&amp;lt; "Went to sleep at: " &amp;lt;&amp;lt; currentTime &amp;lt;&amp;lt; std::endl;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; std::cout &amp;lt;&amp;lt; "Should awake at: " &amp;lt;&amp;lt; shouldAwakeTime &amp;lt;&amp;lt; std::endl;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; std::cout &amp;lt;&amp;lt; "Actually awoke at: " &amp;lt;&amp;lt; awokeTime &amp;lt;&amp;lt; std::endl;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; std::cout &amp;lt;&amp;lt; "Is difference of: " &amp;lt;&amp;lt; (awokeTime - shouldAwakeTime) &amp;lt;&amp;lt; std::endl;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;[/cpp]&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2013 20:30:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950544#M19425</guid>
      <dc:creator>Jonathan_J_</dc:creator>
      <dc:date>2013-07-15T20:30:58Z</dc:date>
    </item>
    <item>
      <title>Hi Jonathan,</title>
      <link>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950545#M19426</link>
      <description>&lt;P&gt;Hi Jonathan,&lt;/P&gt;
&lt;P&gt;Let me investigate the issue you found. Regards.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2013 17:27:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950545#M19426</guid>
      <dc:creator>Loc_N_Intel</dc:creator>
      <dc:date>2013-08-05T17:27:17Z</dc:date>
    </item>
    <item>
      <title>Hi Jonathan,</title>
      <link>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950546#M19427</link>
      <description>&lt;P&gt;Hi Jonathan,&lt;/P&gt;
&lt;P&gt;I confirmed that using nanosleep() and usleep() for 5 msec on Intel(R) Xeon Phi(TM), it is not accurate as it is in Xeon (the difference is ~5 msec on Xeon Phi and ~0.1 msec on Xeon). I will file a problem tracking for this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you and regards.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2013 01:18:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950546#M19427</guid>
      <dc:creator>Loc_N_Intel</dc:creator>
      <dc:date>2013-08-06T01:18:18Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950547#M19428</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I know this is a quite old post but I've fallen into the same problem. Is there any newer information about this?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 15:12:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950547#M19428</guid>
      <dc:creator>Yiannis_N_</dc:creator>
      <dc:date>2016-04-12T15:12:00Z</dc:date>
    </item>
    <item>
      <title>All I can say is that I can</title>
      <link>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950548#M19429</link>
      <description>&lt;P&gt;All I can say is that I can reproduce the issue with mpss 3.4, 3,5 and 3.6 ; the clocksource on my MICs is set to "tsc" yet a &amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;nanosleep(50000000)&lt;/PRE&gt;

&lt;P&gt;or even&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;usleep(5000)&lt;/PRE&gt;

&lt;P&gt;result in an elapsed time of ~ 15 ms (instead of 5). This happens with both a 5120 and a 7120.&lt;/P&gt;

&lt;P&gt;It does not depend on the version of ICC used - I can also reproduce it by building a binary using gcc-for-Phi.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2016 22:52:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Sleep-thread-issues-on-Xeon-Phi/m-p/950548#M19429</guid>
      <dc:creator>JJK</dc:creator>
      <dc:date>2016-04-18T22:52:20Z</dc:date>
    </item>
  </channel>
</rss>

