GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: TESTS/HadamardProductNbTestElement/main.cpp Lines: 21 21 100.0 %
Date: 2025-03-16 06:08:08 Branches: 9 14 64.3 %

Line Branch Exec Source
1
/***************************************
2
	Auteur : Pierre Aubert
3
	Mail : pierre.aubert@lapp.in2p3.fr
4
	Licence : CeCILL-C
5
****************************************/
6
7
#include "micro_benchmark.h"
8
9
///Do the Hadamard product
10
/**	@param[out] tabResult : table of results of tabX*tabY
11
 * 	@param tabX : input table
12
 * 	@param tabY : input table
13
 * 	@param nbElement : number of elements in the tables
14
*/
15
23185200
void hadamard_product(float* tabResult, const float* tabX, const float* tabY, size_t nbElement){
16
61850385200
	for(size_t i(0lu); i < nbElement; ++i){
17
61827200000
		tabResult[i] = tabX[i]*tabY[i];
18
	}
19
23185200
}
20
21
///Get the number of nanoseconds per elements of the Hadamard product
22
/**	@param nbTestPerf : number of performance test to be performed
23
 * 	@param nbCallPerTest : number of call per test
24
 * 	@return time of the kernel per element
25
*/
26
300
double evaluateHadamardProductNbTestElement(size_t nbTestPerf, size_t nbCallPerTest){
27
300
	size_t nbElement(NB_ELEMENTS);
28
	//Allocation of the tables
29
300
	float * tabResult = new float[nbElement];
30
300
	float * tabX = new float[nbElement];
31
300
	float * tabY = new float[nbElement];
32
	//Initialisation of the tables
33
800300
	for(size_t i(0lu); i < nbElement; ++i){
34
800000
		tabX[i] = (float)(i*32lu%17lu);
35
800000
		tabY[i] = (float)(i*57lu%31lu);
36
	}
37
300
	size_t fullNbElement(nbElement);
38
	//Stating the timer
39
300
	double ellapsedTimeNs(0.0), ellapsedTimeErrorNs(0.0), timePerElement(0.0), timeErrorPerElement(0.0);
40
300
	micro_benchmarkNs(ellapsedTimeNs, ellapsedTimeErrorNs, timePerElement, timeErrorPerElement, nbTestPerf, nbCallPerTest, fullNbElement,
41
				hadamard_product, tabResult, tabX, tabY, nbElement);
42
43
// 	micro_benchmarkNsPrint("evaluateHadamardProductNbTestElement",
44
// 			nbTestPerf, nbCallPerTest, fullNbElement, hadamard_product,
45
// 			tabResult, tabX, tabY, nbElement);
46
47
	//Deallocate the tables
48
300
	delete[] tabResult;
49
300
	delete[] tabX;
50
300
	delete[] tabY;
51
300
	return timePerElement;
52
}
53
54
3
int main(int argc, char** argv){
55
3
	return micro_benchmarkParseArg2d(argc, argv, evaluateHadamardProductNbTestElement);
56
}
57