Previous The reduction_intrinsics_interleave4.h file |
Parent Interleaving 4 times |
Outline | Next The main_intrinsics_interleave4.cpp file |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
#include <immintrin.h> #include "reduction_intrinsics_interleave4.h" ///Do the Reduction /** @param ptabValue : input table * @param nbElement : number of elements in the input table * @return sum of all the elements of the input table */ float reduction(const float * tabValue, long unsigned int nbElement){ long unsigned int vecSize(VECTOR_ALIGNEMENT/sizeof(float)); long unsigned int nbVec(nbElement/(vecSize*4lu)); float res(0.0f); __m256 vecRes1 = _mm256_broadcast_ss(&res); __m256 vecRes2 = _mm256_broadcast_ss(&res); __m256 vecRes3 = _mm256_broadcast_ss(&res); __m256 vecRes4 = _mm256_broadcast_ss(&res); for(long unsigned int i(0lu); i < nbVec; ++i){ __m256 vecValue1 = _mm256_load_ps(tabValue + 4lu*i*vecSize); vecRes1 = _mm256_add_ps(vecRes1, vecValue1); __m256 vecValue2 = _mm256_load_ps(tabValue + (4lu*i + 1lu)*vecSize); vecRes2 = _mm256_add_ps(vecRes2, vecValue2); __m256 vecValue3 = _mm256_load_ps(tabValue + (4lu*i + 2lu)*vecSize); vecRes3 = _mm256_add_ps(vecRes3, vecValue3); __m256 vecValue4 = _mm256_load_ps(tabValue + (4lu*i + 3lu)*vecSize); vecRes4 = _mm256_add_ps(vecRes4, vecValue4); } __m256 vecRes12 = _mm256_add_ps(vecRes1, vecRes2); __m256 vecRes34 = _mm256_add_ps(vecRes3, vecRes4); __m256 vecRes = _mm256_add_ps(vecRes12, vecRes34); float tmp[8lu]; _mm256_storeu_ps(tmp, vecRes); for(long unsigned int i(0lu); i < 8lu; ++i){ res += tmp[i]; } return res; } |
Previous The reduction_intrinsics_interleave4.h file |
Parent Interleaving 4 times |
Outline | Next The main_intrinsics_interleave4.cpp file |