GCC Code Coverage Report


Directory: ./
File: src/phoenix_template_alloc.cpp
Date: 2025-08-06 14:32:39
Exec Total Coverage
Lines: 27 27 100.0%
Functions: 4 4 100.0%
Branches: 24 26 92.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 <string.h>
8 #include "phoenix_template_alloc.h"
9
10 ///Get the fulle size of the tensor
11 /** @param tabDim : table of the dimensions of the tensor
12 * @param nbDim : number of dimensions of the tensor
13 * @return size of the tensor
14 */
15 1 size_t phoenix_getFullSize(const size_t * tabDim, size_t nbDim){
16 1 size_t fullSize(1lu);
17
2/2
✓ Branch 0 (4→3) taken 1 times.
✓ Branch 1 (4→5) taken 1 times.
2 for(size_t i(0lu); i < nbDim; ++i){
18 1 fullSize *= tabDim[i];
19 }
20 1 return fullSize;
21 }
22
23 ///Copy a shape of a tensor into an other
24 /** @param[out] destTabDim : copy of the table of the size of each dimension
25 * @param tabDim : table of the size of each dimension
26 * @param nbDim : number of dimensions
27 */
28 5 void phoenix_copyShape(size_t *& destTabDim, const size_t * tabDim, size_t nbDim){
29
2/2
✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→6) taken 4 times.
5 if(destTabDim != NULL){
30
1/2
✓ Branch 0 (3→4) taken 1 times.
✗ Branch 1 (3→5) not taken.
1 delete [] destTabDim;
31 1 destTabDim = NULL;
32 }
33
4/4
✓ Branch 0 (6→7) taken 3 times.
✓ Branch 1 (6→8) taken 2 times.
✓ Branch 2 (7→8) taken 1 times.
✓ Branch 3 (7→9) taken 2 times.
5 if(nbDim == 0lu || tabDim == NULL){
34 3 destTabDim = NULL;
35 3 return;
36 }
37
1/2
✓ Branch 0 (9→10) taken 2 times.
✗ Branch 1 (9→11) not taken.
2 destTabDim = new size_t[nbDim];
38 2 memcpy(destTabDim, tabDim, nbDim*sizeof(size_t));
39 }
40
41 ///Copy a shape of a tensor into an other
42 /** @param[out] destTabDim : copy of the table of the size of each dimension
43 * @param[out] destNbDim : copy of the number of dimensions
44 * @param tabDim : table of the size of each dimension
45 * @param nbDim : number of dimensions
46 */
47 5 void phoenix_copyShape(size_t *& destTabDim, size_t & destNbDim, const size_t * tabDim, size_t nbDim){
48 5 destNbDim = nbDim;
49 5 phoenix_copyShape(destTabDim, tabDim, nbDim);
50 5 }
51
52 ///Say if two shapes are the same or not
53 /** @param tabDim1 : table of the size of each dimension
54 * @param nbDim1 : number of dimensions
55 * @param tabDim2 : table of the size of each dimension
56 * @param nbDim2 : number of dimensions
57 * @return true if the shapes are equal, false otherwise
58 */
59 11 bool phoenix_isSameShape(const size_t * tabDim1, size_t nbDim1, const size_t * tabDim2, size_t nbDim2){
60
4/4
✓ Branch 0 (2→3) taken 6 times.
✓ Branch 1 (2→5) taken 5 times.
✓ Branch 2 (3→4) taken 4 times.
✓ Branch 3 (3→5) taken 2 times.
11 if(tabDim1 == NULL && tabDim2 == NULL){return true;}
61
6/6
✓ Branch 0 (5→6) taken 5 times.
✓ Branch 1 (5→8) taken 2 times.
✓ Branch 2 (6→7) taken 4 times.
✓ Branch 3 (6→8) taken 1 times.
✓ Branch 4 (7→8) taken 1 times.
✓ Branch 5 (7→9) taken 3 times.
7 if(nbDim1 != nbDim2 || tabDim1 == NULL || tabDim2 == NULL){return false;}
62 3 bool isSameSize(true);
63 3 size_t i(0lu);
64
4/4
✓ Branch 0 (11→12) taken 11 times.
✓ Branch 1 (11→13) taken 1 times.
✓ Branch 2 (12→10) taken 9 times.
✓ Branch 3 (12→13) taken 2 times.
12 while(isSameSize && i < nbDim1){
65 9 isSameSize = tabDim1[i] == tabDim2[i];
66 9 ++i;
67 }
68 3 return isSameSize;
69 }
70
71
72