GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/reshuffle_tensor_impl.h Lines: 8 8 100.0 %
Date: 2026-03-27 22:08:32 Branches: 6 6 100.0 %

Line Branch Exec Source
1
/***************************************
2
	Auteur : Pierre Aubert
3
	Mail : pierre.aubert@lapp.in2p3.fr
4
	Licence : CeCILL-C
5
****************************************/
6
7
#ifndef __RESHUFFLE_TENSOR_IMPL_H__
8
#define __RESHUFFLE_TENSOR_IMPL_H__
9
10
#include <string.h>
11
#include "reshuffle_tensor.h"
12
13
///Broadcast the data of the tensorScal in a vectorial one
14
/**	@param[out] tensorBroadCast : tensor where each scalar value is dupplicated vectorSize times, should be aligned for better performances (size[nbRow, nbCol*vectorSize])
15
 * 	@param tensorScal : scalar tensor to be broadcasted
16
 * 	@param nbRow : number of rows of the scalar tensor
17
 * 	@param nbCol : number of column of the scalar tensor
18
 * 	@param padding : padding of the scalar tensor
19
 * 	@param vectorSize : number of element in the vectorial register (to make vectorial register usable as element)
20
*/
21
template<typename T>
22
1
void reshuffle_broadcastTensor(T * tensorBroadCast, const T * tensorScal, size_t nbRow, size_t nbCol,  size_t padding, size_t vectorSize){
23
1
	size_t rowSize(nbCol + padding), outRowSize(nbCol*vectorSize);
24
5
	for(size_t i(0lu); i < nbRow; ++i){
25
16
		for(size_t j(0lu); j < nbCol; ++j){
26
12
			T value(tensorScal[i*rowSize + j]);
27
60
			for(size_t k(0lu); k < vectorSize; ++k){
28
48
				tensorBroadCast[outRowSize*i + vectorSize*j + k] = value;
29
			}
30
		}
31
	}
32
1
}
33
34
///Update the value of the dupplicated vectorial neighbours with an average
35
/**	@param[out] tensor : pointer to the tensor to be updated
36
 * 	@param nbRow : number of rows of the tensor
37
 * 	@param nbCol : number of columns of the tensor
38
 * 	@param vectorSize : number of element in the vectorial register (to make vectorial register usable as element)
39
 * 	First row is updated with the value of the last but one row shifted to the right column
40
 * 	Last row is updated sith the value of the second row shifted to the left column
41
*/
42
template<typename T>
43
void reshuffle_updateDupplicateVecNeighbour(T* tensor, size_t nbRow, size_t nbCol, size_t vectorSize){
44
	if(nbRow < 4lu){return;}
45
	size_t lastRowIdx(nbRow - 1lu);
46
	size_t prevLastRowIdx(lastRowIdx - 1lu);
47
	size_t nbCompute(nbCol/vectorSize);
48
	size_t nbComputeVec(vectorSize - 1lu);
49
	for(size_t i(0lu); i < nbCompute; ++i){
50
		for(size_t j(0lu); j < nbComputeVec; ++j){
51
			tensor[i*vectorSize + 1lu + j] = tensor[prevLastRowIdx*nbCol + i*vectorSize + j];
52
			tensor[lastRowIdx*nbCol + i*vectorSize + j] = tensor[nbCol + i*vectorSize + 1lu + j];
53
		}
54
	}
55
}
56
57
58
#endif
59