GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixMicroBenchmark/TESTS/HadamardProductNbTestElement/main.cpp
Date: 2025-03-14 12:14:21
Exec Total Coverage
Lines: 0 20 0.0%
Branches: 0 10 0.0%

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 void hadamard_product(float* tabResult, const float* tabX, const float* tabY, size_t nbElement){
16 for(size_t i(0lu); i < nbElement; ++i){
17 tabResult[i] = tabX[i]*tabY[i];
18 }
19 }
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 double evaluateHadamardProductNbTestElement(size_t nbTestPerf, size_t nbCallPerTest){
27 size_t nbElement(NB_ELEMENTS);
28 //Allocation of the tables
29 float * tabResult = new float[nbElement];
30 float * tabX = new float[nbElement];
31 float * tabY = new float[nbElement];
32 //Initialisation of the tables
33 for(size_t i(0lu); i < nbElement; ++i){
34 tabX[i] = (float)(i*32lu%17lu);
35 tabY[i] = (float)(i*57lu%31lu);
36 }
37 size_t fullNbElement(nbElement);
38 //Stating the timer
39 double ellapsedTimeNs(0.0), ellapsedTimeErrorNs(0.0), timePerElement(0.0), timeErrorPerElement(0.0);
40 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 delete[] tabResult;
49 delete[] tabX;
50 delete[] tabY;
51 return timePerElement;
52 }
53
54 int main(int argc, char** argv){
55 return micro_benchmarkParseArg2d(argc, argv, evaluateHadamardProductNbTestElement);
56 }
57
58