5.1.1.3.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
46
47
48
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/

#include <iostream>
#include <vector>
#include "asterics_hpc.h"
#include "Particle.h"

using namespace std;

///Get the number of cycles per elements of the function move of Particle
/**	@param nbElement : number of elements of the tables
 * 	@param nbRepetition : number of repetition to evaluate the function move of Particle
*/
void evaluateClassParticlePropagation(long unsigned int nbElement, long unsigned int nbRepetition){
	//Allocation of the tables
	std::vector<Particle> vecParticle(nbElement);
	for(std::vector<Particle>::iterator it(vecParticle.begin()); it != vecParticle.end(); ++it){
		it->randomInit();
	}
	
	//Stating the timer
	long unsigned int beginTime(rdtsc());
	for(long unsigned int i(0lu); i < nbRepetition; ++i){
		for(std::vector<Particle>::iterator it(vecParticle.begin()); it != vecParticle.end(); ++it){
			it->move(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 << "evaluateClassParticlePropagation : nbElement = "<<nbElement<<", cyclePerElement = " << cyclePerElement << " cy/el, elapsedTime = " << elapsedTime << " cy" << endl;
	cerr << nbElement << "\t" << cyclePerElement << "\t" << elapsedTime << endl;
}

int main(int argc, char** argv){
	cout << "Particle propagation with class" << endl;
	evaluateClassParticlePropagation(1000lu, 10000lu);
	evaluateClassParticlePropagation(2000lu, 10000lu);
	evaluateClassParticlePropagation(3000lu, 10000lu);
	evaluateClassParticlePropagation(5000lu, 10000lu);
	evaluateClassParticlePropagation(10000lu, 10000lu);
	return 0;
}


You can download it here.