PhoenixHardware
0.2.0
Tools to get hardware information
Toggle main menu visibility
Loading...
Searching...
No Matches
phoenix_transpose_impl.h
Go to the documentation of this file.
1
/***************************************
2
Auteur : Pierre Aubert
3
Mail : pierre.aubert@lapp.in2p3.fr
4
Licence : CeCILL-C
5
****************************************/
6
7
#ifndef __PHOENIX_TRANSPOSE_IMPL_H__
8
#define __PHOENIX_TRANSPOSE_IMPL_H__
9
10
#include <algorithm>
11
#include "
phoenix_transpose.h
"
12
14
21
template
<
typename
T,
typename
U>
22
void
phoenix_transpose_copy
(T* __restrict__ ptabOutput,
const
U * __restrict__ ptabInput,
23
size_t
nbRowOut,
size_t
nbColOut,
size_t
outputPadding,
bool
isTransposed)
24
{
25
T* tabOutput =
phoenix_assume_aligned
(ptabOutput);
26
const
U* tabInput =
phoenix_assume_aligned
(ptabInput);
27
size_t
outputRowSize(nbColOut + outputPadding);
28
if
(!isTransposed){
29
for
(
size_t
i(0lu); i < nbRowOut; ++i){
30
for
(
size_t
j(0lu); j < nbColOut; ++j){
31
tabOutput[i*outputRowSize + j] = tabInput[i*nbColOut + j];
32
}
33
}
34
}
else
{
//The bad slices rejection from real data have to be done here !!!!!
35
for
(
size_t
j(0lu); j < nbColOut; ++j){
36
for
(
size_t
i(0lu); i < nbRowOut; ++i){
37
tabOutput[i*outputRowSize + j] = tabInput[i + j*nbRowOut];
38
}
39
}
40
}
41
}
42
44
52
template
<
typename
T,
typename
U>
53
void
phoenix_transpose_block
(T* __restrict__ ptabOutput,
const
U * __restrict__ ptabInput,
54
size_t
nbRowOut,
size_t
nbColOut,
size_t
nbBlockRowOut,
size_t
nbBlockColOut,
size_t
outputPadding)
55
{
56
T* tabOutput =
phoenix_assume_aligned
(ptabOutput);
57
const
U* tabInput =
phoenix_assume_aligned
(ptabInput);
58
// T* tabOutput = ptabOutput;
59
// const U* tabInput = ptabInput;
60
// std::cerr << "phoenix_transpose_block : nbRowOut = " << nbRowOut << ", nbColOut = " << nbColOut << ", nbBlockRowOut = " << nbBlockRowOut << ", nbBlockColOut = " << nbBlockColOut << std::endl;
61
size_t
outputRowSize(nbColOut + outputPadding);
62
for
(
size_t
i(0lu); i < nbColOut; i += nbBlockColOut){
63
for
(
size_t
j(0lu); j < nbRowOut; j += nbBlockRowOut){
64
// transpose the block beginning at [i,j]
65
for
(
size_t
k(i); k < std::min(i + nbBlockColOut, nbColOut); ++k){
66
for
(
size_t
l(j); l < std::min(j + nbBlockRowOut, nbRowOut); ++l){
67
// std::cerr << "phoenix_transpose_block : (i = "<<i<<", j = "<<j<<") tabOutput["<<k<<" + "<<l<<"*"<<outputRowSize<<"] = tabInput["<<l<<" + "<<k<<"*"<<nbRowOut<<"]" << std::endl;
68
tabOutput[l*outputRowSize + k] = tabInput[k*nbRowOut + l];
69
}
70
}
71
}
72
}
73
}
74
76
85
template
<
typename
T,
typename
U>
86
void
phoenix_transpose_block_copy
(T* __restrict__ ptabOutput,
const
U * __restrict__ ptabInput,
87
size_t
nbRowOut,
size_t
nbColOut,
size_t
nbBlockRowOut,
size_t
nbBlockColOut,
size_t
outputPadding,
bool
isTransposed)
88
{
89
if
(!isTransposed){
90
T* tabOutput =
phoenix_assume_aligned
(ptabOutput);
91
const
U* tabInput =
phoenix_assume_aligned
(ptabInput);
92
size_t
outputRowSize(nbColOut + outputPadding);
93
for
(
size_t
i(0lu); i < nbColOut; i += nbBlockColOut){
94
for
(
size_t
j(0lu); j < nbRowOut; j += nbBlockRowOut){
95
// transpose the block beginning at [i,j]
96
for
(
size_t
k(i); k < std::min(i + nbBlockColOut, nbColOut); ++k){
97
for
(
size_t
l(j); l < std::min(j + nbBlockRowOut, nbRowOut); ++l){
98
tabOutput[l*outputRowSize + k] = tabInput[l*nbRowOut + k];
99
}
100
}
101
}
102
}
103
}
else
{
//The bad slices rejection from real data have to be done here !!!!!
104
phoenix_transpose_block
(ptabOutput, ptabInput,
105
nbRowOut, nbColOut, nbBlockRowOut, nbBlockColOut, outputPadding);
106
}
107
}
108
109
110
#endif
111
phoenix_assume_aligned
const T * phoenix_assume_aligned(const T *tabValue)
Call __builtin_assume_aligned with proper argument by respect to the table type.
Definition
phoenix_assume_aligned.h:17
phoenix_transpose.h
phoenix_transpose_block
void phoenix_transpose_block(T *__restrict__ ptabOutput, const U *__restrict__ ptabInput, size_t nbRowOut, size_t nbColOut, size_t nbBlockRowOut, size_t nbBlockColOut, size_t outputPadding)
Transpose and convert the table of U into a table of T.
Definition
phoenix_transpose_impl.h:53
phoenix_transpose_block_copy
void phoenix_transpose_block_copy(T *__restrict__ ptabOutput, const U *__restrict__ ptabInput, size_t nbRowOut, size_t nbColOut, size_t nbBlockRowOut, size_t nbBlockColOut, size_t outputPadding, bool isTransposed)
Convert the table of U into a table of T.
Definition
phoenix_transpose_impl.h:86
phoenix_transpose_copy
void phoenix_transpose_copy(T *__restrict__ ptabOutput, const U *__restrict__ ptabInput, size_t nbRowOut, size_t nbColOut, size_t outputPadding, bool isTransposed)
Convert the table of U into a table of T.
Definition
phoenix_transpose_impl.h:22
src
phoenix_transpose_impl.h
Generated by
1.17.0