/*************************************** Auteur : Pierre Aubert Mail : aubertp7@gmail.com Licence : CeCILL-C ****************************************/ #include #include "asterics_hpc.h" using namespace std; ///Do the Hadamard product /** @param[out] ptabResult : table of results of tabX*tabY * @param ptabX : input table * @param ptabY : input table * @param nbElement : number of elements in the tables */ void hadamard_product(float* __restrict__ ptabResult, const float* __restrict__ ptabX, const float* __restrict__ ptabY, long unsigned int nbElement){ const float* tabX = (const float*)__builtin_assume_aligned(ptabX, VECTOR_ALIGNEMENT); const float* tabY = (const float*)__builtin_assume_aligned(ptabY, VECTOR_ALIGNEMENT); float* tabResult = (float*)__builtin_assume_aligned(ptabResult, VECTOR_ALIGNEMENT); for(long unsigned int i(0lu); i < nbElement; ++i){ tabResult[i] = tabX[i]*tabY[i]; } } ///Get the number of cycles per elements of the Hadamard product /** @param nbElement : number of elements of the tables * @param nbRepetition : number of repetition to evaluate the function hadamard_product */ void evaluateHadamardProduct(long unsigned int nbElement, long unsigned int nbRepetition){ float * tabResult = (float*)asterics_malloc(sizeof(float)*nbElement); float * tabX = (float*)asterics_malloc(sizeof(float)*nbElement); float * tabY = (float*)asterics_malloc(sizeof(float)*nbElement); for(long unsigned int i(0lu); i < nbElement; ++i){ tabX[i] = (float)(i*32lu%17lu); tabY[i] = (float)(i*57lu%31lu); } long unsigned int beginTime(rdtsc()); for(long unsigned int i(0lu); i < nbRepetition; ++i){ hadamard_product(tabResult, tabX, tabY, nbElement); } long unsigned int elapsedTime((double)(rdtsc() - beginTime)/((double)nbRepetition)); double cyclePerElement(((double)elapsedTime)/((double)nbElement)); cout << "evaluateHadamardProduct : nbElement = "<