/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/
#include "randinit.h"
#include "micro_benchmark.h"
#include "PTensor.h"
#include INCLUDE_FUNCTION_NAME
///Get the number of nanoseconds per elements of the Hadamard product
/**	@param nbElement : number of elements of the tables
*/
void evaluateHadamardProduct(size_t nbElement){
	//Allocation of the tensors
	PTensor<float> tensorX(AllocMode::ALIGNED, nbElement);
	PTensor<float> tensorY(AllocMode::ALIGNED, nbElement);
	PTensor<float> tensorOut(AllocMode::ALIGNED, nbElement);
	//Initialisation of the tables
	tensorOut.fill(0.0f);
	for(size_t i(0lu); i < nbElement; ++i){
		tensorX.setValue(i, (float)(i*32lu%17lu) + 42.0f);
		tensorY.setValue(i, (float)(i*57lu%31lu) + 12.5f);
	}
#if defined(RATIO_NB_NAN) && defined(VALUE_DEF)
	size_t nbNan((size_t)(RATIO_NB_NAN*((double)nbElement)));
	setValueInTable(tensorX.getData(), nbElement, nbNan, VALUE_DEF);
	setValueInTable(tensorY.getData(), nbElement, nbNan, VALUE_DEF);
#endif
	size_t fullNbElement(nbElement);
	//Stating the timer
	micro_benchmarkAutoNsPrint("evaluate " KERNEL_STR_FUNCTION_NAME, fullNbElement, FUNCTION_NAME,
					tensorOut.getData(), tensorX.getData(), tensorY.getData(), nbElement);
}

int main(int argc, char** argv){
#ifdef DENORM_SET_TO_ZERO
	_mm_setcsr(_mm_getcsr() | (_MM_DENORMALS_ZERO_ON));
#endif
#if defined(RATIO_NB_NAN) && defined(VALUE_DEF)
	initRandom();
#endif
	return micro_benchmarkParseArg(argc, argv, evaluateHadamardProduct);
}

