title: Accumulate vector of integer with sse
body: <p>I tried to change this code to handle <code>std::vector&lt;int&gt;</code>.</p>
  
  <pre><code>float accumulate(const std::vector&lt;float&gt;&amp; v)
  {
   // copy the length of v and a pointer to the data onto the local stack
   const size_t N = v.size();
   const float* p = (N &gt; 0) ? &amp;v.front() : NULL;
  
   __m128 mmSum = _mm_setzero_ps();
   size_t i = 0;
  
   // unrolled loop that adds up 4 elements at a time
   for(; i &lt; ROUND_DOWN(N, 4); i+=4)
   {
    mmSum = _mm_add_ps(mmSum, _mm_loadu_ps(p + i));
   }
  
   // add up single values until all elements are covered
   for(; i &lt; N; i++)
   {
    mmSum = _mm_add_ss(mmSum, _mm_load_ss(p + i));
   }
  
   // add up the four float values from mmSum into a single value and return
   mmSum = _mm_hadd_ps(mmSum, mmSum);
   mmSum = _mm_hadd_ps(mmSum, mmSum);
   return _mm_cvtss_f32(mmSum);
  }
  </code></pre>
  
  <p>Ref: <a href="http://fastcpp.blogspot.com.au/2011/04/how-to-process-stl-vector-using-sse.html" rel="nofollow">http://fastcpp.blogspot.com.au/2011/04/how-to-process-stl-vector-using-sse.html</a></p>
  
  <p>I changed <code>_mm_setzero_ps</code> to <code>_mm_setzero_si128</code>, <code>_mm_loadu_ps</code> to <code>mm_loadl_epi64</code> and <code>_mm_add_ps</code> to <code>_mm_add_epi64</code>.</p>
  
  <p>I get this error:</p>
  
  <pre><code>error: cannot convert ‘const int*’ to ‘const __m128i* {aka const __vector(2) long long int*}’ for argument ‘1’ to ‘__m128i _mm_loadl_epi64(const __m128i*)’
           mmSum = _mm_add_epi64(mmSum, _mm_loadl_epi64(p + i + 0));
  </code></pre>
  
  <p>I am novice in this field. Is there any good source to learn these things?</p>