8.3.2 : The reduction_vectorize.cpp

There is the reduction_vectorize.cpp file :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "reduction_vectorize.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 * __restrict__ ptabValue, long unsigned int nbElement){
	const float* tabValue = (const float*)__builtin_assume_aligned(ptabValue, VECTOR_ALIGNEMENT);
	float res(0.0f);
	for(long unsigned int i(0lu); i < nbElement; ++i){
		res += tabValue[i];
	}
	return res;
}