1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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 = "<<nbElement<<", cyclePerElement = " << cyclePerElement << " cy/el, elapsedTime = " << elapsedTime << " cy" << endl;
cerr << nbElement << "\t" << cyclePerElement << "\t" << elapsedTime << endl;
asterics_free(tabResult);
asterics_free(tabX);
asterics_free(tabY);
}
|