9.3.6 : The main_barycentre_vectorizeSplit.cpp

There is the main_barycentre_vectorizeSplit.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
38
39
40
41
42
43
44
45
#include <iostream>
#include "asterics_hpc.h"
#include "barycentre_vectorizeSplit.h"

using namespace std;

///Get the number of cycles per elements of the reduction
/**	@param nbElement : number of elements of the tables
 * 	@param nbRepetition : number of repetition to evaluate the function reduction
*/
void evaluateBarycentre(long unsigned int nbElement, long unsigned int nbRepetition){
	float * tabX = (float*)asterics_malloc(sizeof(float)*nbElement);
	float * tabY = (float*)asterics_malloc(sizeof(float)*nbElement);
	float * tabA = (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*77lu%31lu);
		tabA[i] = (float)(i*73lu%27lu);
	}
	float gx(0.0f), gy(0.0f);
	long unsigned int beginTime(rdtsc());
	for(long unsigned int i(0lu); i < nbRepetition; ++i){
		barycentre(gx, gy, tabX, tabY, tabA, nbElement);
	}
	long unsigned int elapsedTime((double)(rdtsc() - beginTime)/((double)nbRepetition));
	
	double cyclePerElement(((double)elapsedTime)/((double)nbElement));
	cout << "evaluateBarycentre : nbElement = "<<nbElement<<", cyclePerElement = " << cyclePerElement << " cy/el, elapsedTime = " << elapsedTime << " cy" << endl;
	cerr << nbElement << "\t" << cyclePerElement << "\t" << elapsedTime << endl;
	
	asterics_free(tabA);
	asterics_free(tabY);
	asterics_free(tabX);
}

int main(int argc, char** argv){
	cout << "Barycentre vectorize" << endl;
	evaluateBarycentre(1000lu, 1000000lu);
	evaluateBarycentre(2000lu, 1000000lu);
	evaluateBarycentre(3000lu, 1000000lu);
	evaluateBarycentre(5000lu, 1000000lu);
	evaluateBarycentre(10000lu, 1000000lu);
	return 0;
}