Note that there are some explanatory texts on larger screens.

plurals
  1. POVery high uncertainty in timings after cache flush
    primarykey
    data
    text
    <p>I am using the following code to test the effect of flushing the cache after initialization on the runtime a daxpy routine (the full code with the fill() and wall_time() routines is here: <a href="http://codepad.org/QuLT3cbD" rel="nofollow">http://codepad.org/QuLT3cbD</a> - it is 150 lines):</p> <pre><code>#define KB 1024 int main() { int cache_size = 32*KB; double alpha = 42.5; int operand_size = cache_size/(sizeof(double)*2); double* X = new double[operand_size]; double* Y = new double[operand_size]; //95% confidence interval double max_risk = 0.05; //Interval half width double w; int n_iterations = 100; students_t dist(n_iterations-1); double T = boost::math::quantile(complement(dist,max_risk/2)); accumulator_set&lt;double, stats&lt;tag::mean,tag::variance&gt; &gt; unflushed_acc; for(int i = 0; i &lt; n_iterations; ++i) { fill(X,operand_size); fill(Y,operand_size); double seconds = wall_time(); daxpy(alpha,X,Y,operand_size); seconds = wall_time() - seconds; unflushed_acc(seconds); } w = T*sqrt(variance(unflushed_acc))/sqrt(count(unflushed_acc)); printf("Without flush: time=%g +/- %g ns\n",mean(unflushed_acc)*1e9,w*1e9); //Using clflush instruction //We need to put the operands back in cache accumulator_set&lt;double, stats&lt;tag::mean,tag::variance&gt; &gt; clflush_acc; for(int i = 0; i &lt; n_iterations; ++i) { fill(X,operand_size); fill(Y,operand_size); flush_array(X,operand_size); flush_array(Y,operand_size); double seconds = wall_time(); daxpy(alpha,X,Y,operand_size); seconds = wall_time() - seconds; clflush_acc(seconds); } w = T*sqrt(variance(clflush_acc))/sqrt(count(clflush_acc)); printf("With clflush: time=%g +/- %g ns\n",mean(clflush_acc)*1e9,w*1e9); return 0; } </code></pre> <p>When I run this code, it reports these numbers for the rate and uncertainty therein (at the 95% confidence level): </p> <p>Without flush: time=3103.75 +/- 0.524506 ns With clflush: time=4651.72 +/- 201.25 ns</p> <p>Why does flushing the operands X and Y from cache with clflush increase the noise in the measurements by over 100x?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload