| 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 | 235200 | void hadamard_product(float* tabResult, const float* tabX, const float* tabY, size_t nbElement){ | |
| 16 |
2/2✓ Branch 0 (4→3) taken 627200000 times.
✓ Branch 1 (4→5) taken 235200 times.
|
627435200 | for(size_t i(0lu); i < nbElement; ++i){ |
| 17 | 627200000 | tabResult[i] = tabX[i]*tabY[i]; | |
| 18 | } | ||
| 19 | 235200 | } | |
| 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 | 108 | double evaluateHadamardProductNbTestElement(size_t nbTestPerf, size_t nbCallPerTest){ | |
| 27 | 108 | size_t nbElement(NB_ELEMENTS); | |
| 28 | //Allocation of the tables | ||
| 29 |
2/3✓ Branch 0 (2→3) taken 108 times.
✗ Branch 1 (2→4) not taken.
✓ Branch 2 (5→6) taken 108 times.
|
108 | float * tabResult = new float[nbElement]; |
| 30 |
2/3✓ Branch 0 (6→7) taken 108 times.
✗ Branch 1 (6→8) not taken.
✓ Branch 2 (9→10) taken 108 times.
|
108 | float * tabX = new float[nbElement]; |
| 31 |
2/3✓ Branch 0 (10→11) taken 108 times.
✗ Branch 1 (10→12) not taken.
✓ Branch 2 (13→14) taken 108 times.
|
108 | float * tabY = new float[nbElement]; |
| 32 | //Initialisation of the tables | ||
| 33 |
2/2✓ Branch 0 (16→15) taken 288000 times.
✓ Branch 1 (16→17) taken 108 times.
|
288108 | for(size_t i(0lu); i < nbElement; ++i){ |
| 34 | 288000 | tabX[i] = (float)(i*32lu%17lu); | |
| 35 | 288000 | tabY[i] = (float)(i*57lu%31lu); | |
| 36 | } | ||
| 37 | 108 | size_t fullNbElement(nbElement); | |
| 38 | //Stating the timer | ||
| 39 | 108 | double ellapsedTimeNs(0.0), ellapsedTimeErrorNs(0.0), timePerElement(0.0), timeErrorPerElement(0.0); | |
| 40 |
1/1✓ Branch 0 (17→18) taken 108 times.
|
108 | 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 |
1/2✓ Branch 0 (18→19) taken 108 times.
✗ Branch 1 (18→20) not taken.
|
108 | delete[] tabResult; |
| 49 |
1/2✓ Branch 0 (20→21) taken 108 times.
✗ Branch 1 (20→22) not taken.
|
108 | delete[] tabX; |
| 50 |
1/2✓ Branch 0 (22→23) taken 108 times.
✗ Branch 1 (22→24) not taken.
|
108 | delete[] tabY; |
| 51 | 108 | return timePerElement; | |
| 52 | } | ||
| 53 | |||
| 54 | 3 | int main(int argc, char** argv){ | |
| 55 | 3 | return micro_benchmarkParseArg2d(argc, argv, evaluateHadamardProductNbTestElement); | |
| 56 | } | ||
| 57 | |||
| 58 |