5.1.2.2.1 : Implementation
First, we have to include the appropriate files :

1
2
3
4
5
#include <iostream>
#include "asterics_hpc.h"
#include "table_particle.h"

using namespace std;


We add the function to evaluate our kernel :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
///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);
}


Finally, we call the function to evaluate several points in order to make plots :

1
2
3
4
5
6
7
8
9
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;
}