I want sum up all elements of a big vector ary
. My idea was to do it with a horizontal sum.
const int simd_width = 16/sizeof(float);
float helper[simd_width];
//take the first 4 elements
const __m128 a4 = _mm_load_ps(ary);
for(int i=0; i<N-simd_width; i+=simd_width){
const __m128 b4 = _mm_load_ps(ary+i+simd_width);
//save temporary result in helper array
_mm_store_ps(helper, _mm_hadd_ps(a4,b4)); //C
const __m128 a4 = _mm_load_ps(helper);
}
I looked for a method, with which i can assign the resulting vector directly to the quadfloat a4
directly like _mm_store_ps(a4, _mm_hadd_ps(a4,b4))
Is there such a Intel method?
(It is my first time to work with SSE -maybe the whole code snippet is wrong)