| 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 | 7200000 | void hadamard_product(float* tabResult, const float* tabX, const float* tabY, size_t nbElement){ | |
| 16 |
2/2✓ Branch 0 (4→3) taken 3000000000 times.
✓ Branch 1 (4→5) taken 7200000 times.
|
3007200000 | for(size_t i(0lu); i < nbElement; ++i){ |
| 17 | 3000000000 | tabResult[i] = tabX[i]*tabY[i]; | |
| 18 | } | ||
| 19 | 7200000 | } | |
| 20 | |||
| 21 | ///Get the number of nanoseconds per elements of the Hadamard product | ||
| 22 | /** @param nbElement : number of elements of the tables | ||
| 23 | */ | ||
| 24 | 30 | void evaluateHadamardProduct(size_t nbElement){ | |
| 25 | //Allocation of the tables | ||
| 26 |
2/3✓ Branch 0 (2→3) taken 30 times.
✗ Branch 1 (2→4) not taken.
✓ Branch 2 (5→6) taken 30 times.
|
30 | float * tabResult = new float[nbElement]; |
| 27 |
2/3✓ Branch 0 (6→7) taken 30 times.
✗ Branch 1 (6→8) not taken.
✓ Branch 2 (9→10) taken 30 times.
|
30 | float * tabX = new float[nbElement]; |
| 28 |
2/3✓ Branch 0 (10→11) taken 30 times.
✗ Branch 1 (10→12) not taken.
✓ Branch 2 (13→14) taken 30 times.
|
30 | float * tabY = new float[nbElement]; |
| 29 | //Initialisation of the tables | ||
| 30 |
2/2✓ Branch 0 (16→15) taken 12500 times.
✓ Branch 1 (16→17) taken 30 times.
|
12530 | for(size_t i(0lu); i < nbElement; ++i){ |
| 31 | 12500 | tabX[i] = (float)(i*32lu%17lu); | |
| 32 | 12500 | tabY[i] = (float)(i*57lu%31lu); | |
| 33 | } | ||
| 34 | 30 | size_t nbTestPerf(400lu); | |
| 35 | 30 | size_t nbCallPerTest(600lu); | |
| 36 | 30 | size_t fullNbElement(nbElement); | |
| 37 | //Stating the timer | ||
| 38 |
2/2✓ Branch 0 (19→20) taken 30 times.
✓ Branch 2 (20→21) taken 30 times.
|
30 | micro_benchmarkRdtscPrint("evaluateHadamardProduct", |
| 39 | nbTestPerf, nbCallPerTest, fullNbElement, hadamard_product, | ||
| 40 | tabResult, tabX, tabY, nbElement); | ||
| 41 | |||
| 42 | //Deallocate the tables | ||
| 43 |
1/2✓ Branch 0 (23→24) taken 30 times.
✗ Branch 1 (23→25) not taken.
|
30 | delete[] tabResult; |
| 44 |
1/2✓ Branch 0 (25→26) taken 30 times.
✗ Branch 1 (25→27) not taken.
|
30 | delete[] tabX; |
| 45 |
1/2✓ Branch 0 (27→28) taken 30 times.
✗ Branch 1 (27→29) not taken.
|
30 | delete[] tabY; |
| 46 | 30 | } | |
| 47 | |||
| 48 | 5 | int main(int argc, char** argv){ | |
| 49 | 5 | return micro_benchmarkParseArg(argc, argv, evaluateHadamardProduct); | |
| 50 | } | ||
| 51 | |||
| 52 |