5.1.2.2.2 : Summary main.cpp
Here is the full main.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
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/

#include <iostream>
#include "asterics_hpc.h"
#include "table_particle.h"

using namespace std;

///Get the number of cycles per elements of the moveParticle function
/**	@param nbElement : number of elements of the tables
 * 	@param nbRepetition : number of repetition to evaluate the function moveParticle
*/
void evaluateMoveParticle(long unsigned int nbElement, long unsigned int nbRepetition){
	//Allocation of the tables
	TableParticle tp;
	allocTableParticle(tp, nbElement);
	initTableParticle(tp);
	//Stating the timer
	long unsigned int beginTime(rdtsc());
	for(long unsigned int i(0lu); i < nbRepetition; ++i){
		moveParticle(tp, 0.005f);
	}
	//Get the time of the nbRepetition calls
	long unsigned int elapsedTime((double)(rdtsc() - beginTime)/((double)nbRepetition));
	
	double cyclePerElement(((double)elapsedTime)/((double)nbElement));
	cout << "evaluateMoveParticle : nbElement = "<<nbElement<<", cyclePerElement = " << cyclePerElement << " cy/el, elapsedTime = " << elapsedTime << " cy" << endl;
	cerr << nbElement << "\t" << cyclePerElement << "\t" << elapsedTime << endl;
	//Deallocate the tables
	freeTableParticle(tp);
}

int main(int argc, char** argv){
	cout << "Table Particle implementation" << endl;
	evaluateMoveParticle(1000lu, 10000lu);
	evaluateMoveParticle(2000lu, 10000lu);
	evaluateMoveParticle(3000lu, 10000lu);
	evaluateMoveParticle(5000lu, 10000lu);
	evaluateMoveParticle(10000lu, 10000lu);
	return 0;
}


You can download it here.