1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#ifndef __BLOCK_COPY_IMPL_H__ |
8 |
|
|
#define __BLOCK_COPY_IMPL_H__ |
9 |
|
|
|
10 |
|
|
#include <string.h> |
11 |
|
|
#include "block_copy.h" |
12 |
|
|
|
13 |
|
|
///Copy a tensor into a block |
14 |
|
|
/** @param[out] block : pointor to the block data |
15 |
|
|
* @param nbRowBlock : number of rows of the block |
16 |
|
|
* @param nbColBlock : number of column of the block |
17 |
|
|
* @param paddingBlock : padding of the block |
18 |
|
|
* @param blockPosRow : position of the block in rows |
19 |
|
|
* @param blockPosCol : position of the block in columns |
20 |
|
|
* @param tensor : pointor of the tensor data |
21 |
|
|
* @param nbColTensor : number of columns of the tensor |
22 |
|
|
* @param paddingTensor : padding of the tensor |
23 |
|
|
*/ |
24 |
|
|
template<typename T> |
25 |
|
71 |
void block_copy_tensorToBlock(T * block, size_t nbRowBlock, size_t nbColBlock, size_t paddingBlock, |
26 |
|
|
size_t blockPosRow, size_t blockPosCol, |
27 |
|
|
const T * tensor, size_t nbColTensor, size_t paddingTensor) |
28 |
|
|
{ |
29 |
|
71 |
size_t blockColSize(nbColBlock + paddingBlock); |
30 |
|
71 |
size_t tensorColSize(nbColTensor + paddingTensor); |
31 |
✓✓ |
1021 |
for(size_t i(0lu); i < nbRowBlock; ++i){ |
32 |
|
950 |
memcpy(block + i*blockColSize, tensor + (i + blockPosRow)*tensorColSize + blockPosCol, nbColBlock*sizeof(T)); |
33 |
|
|
} |
34 |
|
71 |
} |
35 |
|
|
|
36 |
|
|
///Copy a block into a tensor |
37 |
|
|
/** @param[out] tensor : pointor of the tensor data |
38 |
|
|
* @param nbColTensor : number of columns of the tensor |
39 |
|
|
* @param paddingTensor : padding of the tensor |
40 |
|
|
* @param block : pointor to the block data |
41 |
|
|
* @param nbRowBlock : number of rows of the block |
42 |
|
|
* @param nbColBlock : number of column of the block |
43 |
|
|
* @param paddingBlock : padding of the block |
44 |
|
|
* @param blockPosRow : position of the block in rows |
45 |
|
|
* @param blockPosCol : position of the block in columns |
46 |
|
|
* @param neighbourRing : number of border ring neighbours |
47 |
|
|
* @param nbVecNeighbour : number of vectorial neighbours |
48 |
|
|
*/ |
49 |
|
|
template<typename T> |
50 |
|
71 |
void block_copy_blockToTensor(T * tensor, size_t nbColTensor, size_t paddingTensor, |
51 |
|
|
const T * block, size_t nbRowBlock, size_t nbColBlock, size_t paddingBlock, |
52 |
|
|
size_t blockPosRow, size_t blockPosCol, size_t neighbourRing, size_t nbVecNeighbour) |
53 |
|
|
{ |
54 |
|
71 |
size_t colShitf(neighbourRing*nbVecNeighbour); |
55 |
|
71 |
size_t blockColSize(nbColBlock + paddingBlock); |
56 |
|
71 |
size_t tensorColSize(nbColTensor + paddingTensor); |
57 |
|
71 |
nbColBlock -= 2lu*colShitf; |
58 |
✓✓ |
969 |
for(size_t i(neighbourRing); i < nbRowBlock - neighbourRing; ++i){ |
59 |
|
898 |
memcpy(tensor + (i + blockPosRow)*tensorColSize + blockPosCol + colShitf, block + i*blockColSize + colShitf, nbColBlock*sizeof(T)); |
60 |
|
|
} |
61 |
|
71 |
} |
62 |
|
|
|
63 |
|
|
|
64 |
|
|
#endif |