<?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 Uncacheable page vs Cachable page in Software Tuning, Performance Optimization &amp; Platform Monitoring</title>
    <link>https://community.intel.com/t5/Software-Tuning-Performance/Uncacheable-page-vs-Cachable-page/m-p/1157430#M6963</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to compare the execution time of a read instruction on an uncacheable page and a cacheable page.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I tested simple code, and the uncacheable page showed about &lt;STRONG&gt;10 times longer&lt;/STRONG&gt;&amp;nbsp;than the cacheable page.&lt;/P&gt;&lt;P&gt;Even though array index&amp;nbsp;is set to cause cache misses (stride for cache line), it is difficult to understand that there is a 10 times&amp;nbsp;long execution time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please explain the reason for the difference? (In terms of HW or SW)&lt;/P&gt;&lt;P&gt;The code used in the experiment is attached to help understanding.&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;void perf_time(unsigned int *pt, int size, int num_page, int &amp;amp;temp)
{

#ifdef TIME_PRINT
    struct timespec start, end;
    uint64_t diff;
#endif    
    
    //volatile int sum=0;
    register int sum;

    int tsize = size / sizeof(int); 

#ifdef TIME_PRINT
    clock_gettime(CLOCK_MONOTONIC, &amp;amp;start); /* mark start time */
#endif        

    //cache-line 64B
    for (int i = 0; i &amp;lt; tsize/16; i++){

#ifdef TEST_WR
        #ifdef ALL_CACHE_HIT
            pt[i%16] = sum;   //write test
        #else
            pt[i*16] = sum;   //write test
        #endif

#else
        #ifdef ALL_CACHE_HIT
            //sum = pt[i%16]; //read test
            sum = pt[0]; //read test
        #else            
            sum += pt[i*16]; //read test
        #endif
#endif
}
    
#ifdef TIME_PRINT    
    clock_gettime(CLOCK_MONOTONIC, &amp;amp;end); /* mark the end time */
    diff = BILLION*(end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec);
    printf("CLOCK_MONOTONIC elapsed time = %llu nanoseconds page num %d\n", (long long unsigned int) diff, num_page);
#endif
    
#ifdef TEST_WR    
    temp = pt[10];
#else    
    printf("sum %d\r\n", sum);
#endif    
    
}&lt;/PRE&gt;

&lt;P&gt;//Page attribute set&lt;/P&gt;
&lt;P&gt;//The kernel was modified to set the page attribute.&lt;/P&gt;
&lt;P&gt;//unsigned int *pt = (unsigned int *)mmap(0, size, PROT_WRITE|PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS | MAP_WB, -1, 0);&lt;BR /&gt;//unsigned int *pt = (unsigned int *)mmap(0, size, PROT_WRITE|PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS | MAP_WT, -1, 0);&lt;BR /&gt;//unsigned int *pt = (unsigned int *)mmap(0, size, PROT_WRITE|PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS | MAP_WC, -1, 0);&lt;BR /&gt;unsigned int *pt = (unsigned int *)mmap(0, size, PROT_WRITE|PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS | MAP_UC, -1, 0);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:plain; class-name:dark;"&gt;  400af0:	8b 17                	mov    (%rdi),%edx
  400af2:	48 83 c7 40          	add    $0x40,%rdi
  400af6:	48 39 c7             	cmp    %rax,%rdi
  400af9:	75 f5                	jne    400af0 &amp;lt;_Z9perf_timePjiiRi+0x60&amp;gt;&lt;/PRE&gt;

&lt;P&gt;//Disassemble code in&amp;nbsp;iterative&amp;nbsp;section&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;Changhyun&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2020 07:08:36 GMT</pubDate>
    <dc:creator>Kim__Changhyun</dc:creator>
    <dc:date>2020-04-07T07:08:36Z</dc:date>
    <item>
      <title>Uncacheable page vs Cachable page</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Uncacheable-page-vs-Cachable-page/m-p/1157430#M6963</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to compare the execution time of a read instruction on an uncacheable page and a cacheable page.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I tested simple code, and the uncacheable page showed about &lt;STRONG&gt;10 times longer&lt;/STRONG&gt;&amp;nbsp;than the cacheable page.&lt;/P&gt;&lt;P&gt;Even though array index&amp;nbsp;is set to cause cache misses (stride for cache line), it is difficult to understand that there is a 10 times&amp;nbsp;long execution time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please explain the reason for the difference? (In terms of HW or SW)&lt;/P&gt;&lt;P&gt;The code used in the experiment is attached to help understanding.&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;void perf_time(unsigned int *pt, int size, int num_page, int &amp;amp;temp)
{

#ifdef TIME_PRINT
    struct timespec start, end;
    uint64_t diff;
#endif    
    
    //volatile int sum=0;
    register int sum;

    int tsize = size / sizeof(int); 

#ifdef TIME_PRINT
    clock_gettime(CLOCK_MONOTONIC, &amp;amp;start); /* mark start time */
#endif        

    //cache-line 64B
    for (int i = 0; i &amp;lt; tsize/16; i++){

#ifdef TEST_WR
        #ifdef ALL_CACHE_HIT
            pt[i%16] = sum;   //write test
        #else
            pt[i*16] = sum;   //write test
        #endif

#else
        #ifdef ALL_CACHE_HIT
            //sum = pt[i%16]; //read test
            sum = pt[0]; //read test
        #else            
            sum += pt[i*16]; //read test
        #endif
#endif
}
    
#ifdef TIME_PRINT    
    clock_gettime(CLOCK_MONOTONIC, &amp;amp;end); /* mark the end time */
    diff = BILLION*(end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec);
    printf("CLOCK_MONOTONIC elapsed time = %llu nanoseconds page num %d\n", (long long unsigned int) diff, num_page);
#endif
    
#ifdef TEST_WR    
    temp = pt[10];
#else    
    printf("sum %d\r\n", sum);
#endif    
    
}&lt;/PRE&gt;

&lt;P&gt;//Page attribute set&lt;/P&gt;
&lt;P&gt;//The kernel was modified to set the page attribute.&lt;/P&gt;
&lt;P&gt;//unsigned int *pt = (unsigned int *)mmap(0, size, PROT_WRITE|PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS | MAP_WB, -1, 0);&lt;BR /&gt;//unsigned int *pt = (unsigned int *)mmap(0, size, PROT_WRITE|PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS | MAP_WT, -1, 0);&lt;BR /&gt;//unsigned int *pt = (unsigned int *)mmap(0, size, PROT_WRITE|PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS | MAP_WC, -1, 0);&lt;BR /&gt;unsigned int *pt = (unsigned int *)mmap(0, size, PROT_WRITE|PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS | MAP_UC, -1, 0);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:plain; class-name:dark;"&gt;  400af0:	8b 17                	mov    (%rdi),%edx
  400af2:	48 83 c7 40          	add    $0x40,%rdi
  400af6:	48 39 c7             	cmp    %rax,%rdi
  400af9:	75 f5                	jne    400af0 &amp;lt;_Z9perf_timePjiiRi+0x60&amp;gt;&lt;/PRE&gt;

&lt;P&gt;//Disassemble code in&amp;nbsp;iterative&amp;nbsp;section&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;Changhyun&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 07:08:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Uncacheable-page-vs-Cachable-page/m-p/1157430#M6963</guid>
      <dc:creator>Kim__Changhyun</dc:creator>
      <dc:date>2020-04-07T07:08:36Z</dc:date>
    </item>
    <item>
      <title>It is always a good idea to</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/Uncacheable-page-vs-Cachable-page/m-p/1157431#M6964</link>
      <description>&lt;P&gt;It is always a good idea to provide the absolute timings in addition to the ratio....&lt;/P&gt;&lt;P&gt;The main difference is that independent accesses to cached pages can execute concurrently, while accesses to uncacheable pages execute completely sequentially. &amp;nbsp;Recent Intel processor cores support 10-12 concurrent L1 Data Cache misses, so it is entirely reasonable for the cached version to be 10x faster on independent accesses. &amp;nbsp; The difference would be much smaller if the accesses were dependent -- such as in a pointer-chasing benchmark.&lt;/P&gt;&lt;P&gt;Depending on the specific processor you are using, the latency for uncached accesses should be in the range of 70-90 ns each.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 18:52:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/Uncacheable-page-vs-Cachable-page/m-p/1157431#M6964</guid>
      <dc:creator>McCalpinJohn</dc:creator>
      <dc:date>2020-04-09T18:52:16Z</dc:date>
    </item>
  </channel>
</rss>

