<?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 Strange slowdown on Xeon W3540 in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825074#M1354</link>
    <description>Hi Ruben,&lt;BR /&gt;&lt;BR /&gt;to verify if you indeed have false sharing you can use VTune or PTU tools, please &lt;A href="http://software.intel.com/en-us/articles/avoiding-and-identifying-false-sharing-among-threads/"&gt;see thisarticle&lt;/A&gt;. You can also look at &lt;A href="http://software.intel.com/en-us/articles/using-intel-vtune-performance-analyzer-to-optimize-software-for-the-intelr-coretm-i7-processor-family/" title="this guide"&gt;this guide&lt;/A&gt;to check if there is a different issue causing the slowdown.&lt;BR /&gt;&lt;BR /&gt;Roman</description>
    <pubDate>Mon, 20 Sep 2010 14:41:47 GMT</pubDate>
    <dc:creator>Roman_D_Intel</dc:creator>
    <dc:date>2010-09-20T14:41:47Z</dc:date>
    <item>
      <title>Strange slowdown on Xeon W3540</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825073#M1353</link>
      <description>Hi Everyone,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I have a simple test program which shows some strange slowdown on my desktop computer.&lt;/DIV&gt;&lt;DIV&gt;Desktop is running Linux and the CPU is a quad-core W3540.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;The test creates two threads which iterate over an array of structure whose size is 128 bytes (double the size of cache line). The first thread modifies the first half the structure while the second thread modifies the second half. The array is aligned to cache line boundary so there should not be any false sharing.&lt;/DIV&gt;&lt;DIV&gt;But it shows a slowdown like there is a false sharing.&lt;/DIV&gt;&lt;DIV&gt;However if I increase the structure size to 256 the slowdown goes away. Or if I decrease array size from 46 to 45 the slowdown again goes away.&lt;/DIV&gt;&lt;DIV&gt;I would be glade if someone can explain the reason of such behavior.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I tested this on many computes having different Inter processors, it seems it only happens for W3540.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;There is the source code of my program.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV id="_mcePaste"&gt;#include &lt;PTHREAD.H&gt;&lt;/PTHREAD.H&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;struct S {&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;int m_i[32];&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;} __attribute__((aligned(64)));&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;const int n = 46;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;S data&lt;N&gt;;&lt;/N&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;int m;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;void* f1(void*)&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;{&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;for (int j = 0; j &amp;lt; m; ++j) {&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt; for (int i = 0; i &amp;lt; n; ++i) {&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;  data&lt;I&gt;.m_i[0]++;&lt;/I&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt; }&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;}&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;return 0;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;}&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;void* f2(void*)&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;{&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;for (int j = 0; j &amp;lt; m; ++j) {&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt; for (int i = 0; i &amp;lt; n; ++i) {&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;  data&lt;I&gt;.m_i[16]++;&lt;/I&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt; }&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;}&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;return 0;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;}&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;int main(int argc, char* argv[])&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;{&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;m = 10000000;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;pthread_t t1, t2;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;pthread_create(&amp;amp;t1, 0, f1, 0);&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;pthread_create(&amp;amp;t2, 0, f2, 0);&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;pthread_exit(0);&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;return 0;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;}&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 11 Sep 2010 00:11:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825073#M1353</guid>
      <dc:creator>Ruben_Adamyan</dc:creator>
      <dc:date>2010-09-11T00:11:33Z</dc:date>
    </item>
    <item>
      <title>Strange slowdown on Xeon W3540</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825074#M1354</link>
      <description>Hi Ruben,&lt;BR /&gt;&lt;BR /&gt;to verify if you indeed have false sharing you can use VTune or PTU tools, please &lt;A href="http://software.intel.com/en-us/articles/avoiding-and-identifying-false-sharing-among-threads/"&gt;see thisarticle&lt;/A&gt;. You can also look at &lt;A href="http://software.intel.com/en-us/articles/using-intel-vtune-performance-analyzer-to-optimize-software-for-the-intelr-coretm-i7-processor-family/" title="this guide"&gt;this guide&lt;/A&gt;to check if there is a different issue causing the slowdown.&lt;BR /&gt;&lt;BR /&gt;Roman</description>
      <pubDate>Mon, 20 Sep 2010 14:41:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825074#M1354</guid>
      <dc:creator>Roman_D_Intel</dc:creator>
      <dc:date>2010-09-20T14:41:47Z</dc:date>
    </item>
    <item>
      <title>Strange slowdown on Xeon W3540</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825075#M1355</link>
      <description>The item ofinterest here is when you change the value of n (array of structures size). This should reduce the amount of work by 1/46th, yet the difference in performance is reported as much larger than this. The variation in n will not affect the relativealignment for cache line. However, By varying the array size you are varying the size of a static object preceeding the code. &lt;BR /&gt;&lt;BR /&gt;If I were to make an experienced guess, I would venture to guess that the movement of the code (f1 and f2) affected the alignment for the instruction cache (of one or both loops). This can be confirmed by looking at the dissassembly of the two loops under the two different values for n. Produce the address reports from the very same code that exhibits the difference in performance.&lt;BR /&gt;&lt;BR /&gt;Also, you might consider an alignment of 4096 (typical VM page size), this will (may) reduce the number TLBs required for data&lt;I&gt; from 3 to 2.&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;/I&gt;</description>
      <pubDate>Wed, 22 Sep 2010 16:45:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825075#M1355</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-09-22T16:45:43Z</dc:date>
    </item>
    <item>
      <title>Strange slowdown on Xeon W3540</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825076#M1356</link>
      <description>As you didn't say anything about it, I suppose you have default alternate sector prefetch enabled. If you happen to align to an even cache line boundary, each active thread will attempt to keep both cache lines up to date in cache. This acts like a milder version of false sharing. On some server platforms, there may be a BIOS setup option to disable this style of prefetch. For a desktop with no such option, you (with full administrator rights) should be able to turn it off (for everyone) via MSR, after each reboot. As you said, increasing the structure to keep the data separated by 2 cache lines would prevent the adverse effect.</description>
      <pubDate>Wed, 22 Sep 2010 20:27:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825076#M1356</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2010-09-22T20:27:00Z</dc:date>
    </item>
    <item>
      <title>Strange slowdown on Xeon W3540</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825077#M1357</link>
      <description>&lt;P&gt;This would be true except that the user has a struct of size 128 bytes (32 ints)&lt;BR /&gt;and the user has an array of these structs&lt;BR /&gt;The performance varies greatly dependent upon the number of these structs in his array of structs.&lt;/P&gt;&lt;P&gt;(not the number of ints within each struct)&lt;/P&gt;&lt;P&gt;The relative cache line alignment is the same regardless of the size of array of structs.&lt;/P&gt;&lt;P&gt;This is not to say you are wrong about the prefetch as the two tasks may be in lock-step (working in same struct) or may be skewed (working in different structs), and the numbers of these structs alter the lock-step/skew situation. Running VTune or other profiler that detects cache line evictsion would confirm or disclaim the hypothesis.&lt;/P&gt;&lt;P&gt;I would like to see his reply to running with the array of structs bounded on 4096 byte boundry. (i.e. to potentially reduce the number of TLB's required to map the array of structs).&lt;/P&gt;&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2010 15:04:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Strange-slowdown-on-Xeon-W3540/m-p/825077#M1357</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-09-23T15:04:22Z</dc:date>
    </item>
  </channel>
</rss>

