GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/PTensor.cpp Lines: 15 18 83.3 %
Date: 2026-03-27 22:08:32 Branches: 9 10 90.0 %

Line Branch Exec Source
1
/***************************************
2
	Auteur : Pierre Aubert
3
	Mail : pierre.aubert@lapp.in2p3.fr
4
	Licence : CeCILL-C
5
****************************************/
6
7
8
#include "PTensor.h"
9
10
///Create an alloc mode with aligend information and padding
11
/**	@param isAligned : true if the data pointer is aligned
12
 * 	@param padding : padding of the table of data
13
*/
14
74
AllocMode::AllocMode tensor_getAllocMode(bool isAligned, size_t padding){
15
	AllocMode::AllocMode allocMode;
16

74
	if(isAligned || padding != 0lu){
17
73
		if(padding != 0lu){
18
72
			allocMode = AllocMode::PADDING;
19
		}else{
20
1
			allocMode = AllocMode::ALIGNED;
21
		}
22
	}else{
23
1
		allocMode = AllocMode::NONE;
24
	}
25
74
	return allocMode;
26
}
27
28
///Get the proper number of element os size blockInSizeRow in nbInRow with neighbours padding : neighborRing
29
/**	@param[out] nbInBlockRow : number of full block of size blockInSizeRow
30
 * 	@param[out] sizeLastInBlockRow : size of the last block
31
 * 	@param[out] blockSizeRow : full size of the block (this input can be adjust if blockInSizeRow > nbInRow)
32
 * 	@param nbRow : full size of the considered dimension
33
 * 	@param neighborRing : size of the neighbours padding
34
 * 	@param vectorNeigbour : number of vectorial neighbours
35
*/
36
32
void splitBlockSize(size_t & nbInBlockRow, size_t & sizeLastInBlockRow, size_t & blockSizeRow, size_t nbRow, size_t neighborRing, size_t vectorNeigbour){
37
32
	size_t blockInSizeRow(blockSizeRow - vectorNeigbour*neighborRing*2lu);
38
32
	size_t nbInRow(nbRow - vectorNeigbour*neighborRing*2lu);	//2 is for up and down
39
32
	if(nbInRow > blockInSizeRow){
40
32
		nbInBlockRow = nbInRow/blockInSizeRow;
41
32
		sizeLastInBlockRow = nbInRow - nbInBlockRow*blockInSizeRow;
42
32
		sizeLastInBlockRow += (sizeLastInBlockRow != 0lu)*2lu*neighborRing*vectorNeigbour;
43
	}else{
44
		nbInBlockRow = 1lu;
45
		blockSizeRow = nbInRow + 2lu*neighborRing*vectorNeigbour;
46
		sizeLastInBlockRow = 0lu;
47
	}
48
32
}
49
50
51