title: 32-bit versus 64-bit floating-point performance
body: <p>I have ran into a curious problem. An algorithm I am working on consists of lots of computations like this</p>
  
  <pre><code>q = x(0)*y(0)*z(0) + x(1)*y(1)*z(1) + ...
  </code></pre>
  
  <p>where the length of summation is between 4 and 7.</p>
  
  <p>The original computations are all done using 64-bit precision. For experimentation, I tried using 32-bit precision for x,y,z input values (so that computations are performed using 32-bit), and storing final result as 64-bit value (straightforward cast).</p>
  
  <p>I expected 32-bit performance to be better (cache size, <a href="http://en.wikipedia.org/wiki/SIMD" rel="nofollow noreferrer">SIMD</a> size, etc.), but to my surprise there was no difference in performance, maybe even decrease.</p>
  
  <p>The architecture in question is Intel 64, Linux, and <a href="http://en.wikipedia.org/wiki/GNU_Compiler_Collection" rel="nofollow noreferrer">GCC</a>. Both codes do seem to use <a href="http://en.wikipedia.org/wiki/Streaming_SIMD_Extensions" rel="nofollow noreferrer">SSE</a> and arrays in both cases are aligned to 16 byte boundary.</p>
  
  <p>Why would it be so? My guess so far is that 32-bit precision can use SSE only on the first four elements, with the rest being done serially compounded by cast overhead.</p>