Gitlab is now running v13.10.2 - More info -> here <-

Commit 1c5561ba authored by Pierre Aubert's avatar Pierre Aubert

Add function to reshuffle tensor in vector mode

parent def1f070
Pipeline #99804 failed with stages
in 4 minutes
......@@ -6,4 +6,5 @@ add_subdirectory(TEST_TENSOR_SIZE)
add_subdirectory(TEST_TENSOR_MESSAGE)
add_subdirectory(TEST_TENSOR_FILE)
add_subdirectory(TEST_TENSOR_COPY_POINTER)
add_subdirectory(TEST_TENSOR_RESHUFFLE)
......@@ -10,7 +10,7 @@
#include <stdio.h>
#include "data_all.h"
#include "template_alloc.h"
#include "reshuffle_tensor.h"
///@brief Deal with general tensor, allocation and other stuff
template<typename T>
......
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __RESHUFFLE_TENSOR_H__
#define __RESHUFFLE_TENSOR_H__
#include <iostream>
template<typename T>
void reshuffle_row_toVecNeighbour(T * rowVecNeighbour, size_t paddingVec, const T * rowScalNeighbour, size_t nbCol, size_t vectorSize);
template<typename T>
void reshuffle_row_toScalNeighbour(T * rowScalNeighbour, const T * rowVecNeighbour, size_t paddingVec, size_t nbCol, size_t vectorSize);
template<typename T>
void reshuffle_tensor_toVecNeighbour(T * tensorVecNeighbour, size_t paddingVec, const T * tensorScalNeighbour, size_t paddingScal, size_t nbRow, size_t nbCol, size_t vectorSize);
template<typename T>
void reshuffle_tensor_toScalNeighbour(T * tensorScalNeighbour, size_t paddingScal, const T * tensorVecNeighbour, size_t paddingVec, size_t nbRow, size_t nbCol, size_t vectorSize);
#include "reshuffle_tensor_impl.h"
#endif
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __RESHUFFLE_TENSOR_IMPL_H__
#define __RESHUFFLE_TENSOR_IMPL_H__
#include "reshuffle_tensor.h"
///Convert a row of a tensor with neigbhour in the given register size
/** @param[out] rowVecNeighbour : pointer to the reordered row
* @param paddingVec : padding of the vectorial row
* @param rowScalNeighbour : pointer to the row to be reoganised
* @param nbCol : number of column of the row
* @param vectorSize : number of element in the vectorial register (to make vectorial register usable as element)
*/
template<typename T>
void reshuffle_row_toVecNeighbour(T * rowVecNeighbour, size_t paddingVec, const T * rowScalNeighbour, size_t nbCol, size_t vectorSize){
size_t rowSizeVec(nbCol + paddingVec);
for(size_t i(0lu); i < nbCol; ++i){
T value(rowScalNeighbour[i]);
size_t shift(i*vectorSize / rowSizeVec);
size_t vecIndex((i*vectorSize + shift) % rowSizeVec);
rowVecNeighbour[vecIndex] = value;
}
}
///Convert a row of a reshuffled tensor with neigbhour back with scalar neigbhours
/** @param[out] rowScalNeighbour : pointer to the reordered row
* @param rowVecNeighbour : pointer to the row to be reoganised
* @param paddingVec : padding of the vectorial row
* @param nbCol : number of column of the row
* @param vectorSize : number of element in the vectorial register (to make vectorial register usable as element)
*/
template<typename T>
void reshuffle_row_toScalNeighbour(T * rowScalNeighbour, const T * rowVecNeighbour, size_t paddingVec, size_t nbCol, size_t vectorSize){
size_t rowSizeVec(nbCol + paddingVec);
for(size_t i(0lu); i < nbCol; ++i){
size_t shift(i*vectorSize / rowSizeVec);
size_t vecIndex((i*vectorSize + shift) % rowSizeVec);
T value(rowVecNeighbour[vecIndex]);
rowScalNeighbour[i] = value;
}
}
///Convert a tensor with scalar neigbhours (sa a classical tensor) in tensor with vectorial neigbhours with the given register size
/** @param[out] tensorVecNeighbour : pointer to the reordered tensor
* @param paddingVec : padding of the vectorial tensor
* @param tensorScalNeighbour : pointer to the row to be reoganised
* @param paddingScal : padding of the scalar tensor
* @param nbRow : number of rows of the tensor
* @param nbCol : number of column of the tensor
* @param vectorSize : number of element in the vectorial register (to make vectorial register usable as element)
*/
template<typename T>
void reshuffle_tensor_toVecNeighbour(T * tensorVecNeighbour, size_t paddingVec, const T * tensorScalNeighbour, size_t paddingScal, size_t nbRow, size_t nbCol, size_t vectorSize){
size_t rowSizeScal(nbCol + paddingScal), rowSizeVec(nbCol + paddingVec);
for(size_t i(0lu); i < nbRow; ++i){
reshuffle_row_toVecNeighbour(tensorVecNeighbour + i*rowSizeVec, paddingVec, tensorScalNeighbour + i*rowSizeScal, nbCol, vectorSize);
}
}
///Convert a reshuffled tensor with neigbhour back with scalar neigbhours
/** @param[out] tensorScalNeighbour : pointer to the reordered tensor
* @param paddingScal : padding of the scalar tensor
* @param tensorVecNeighbour : pointer to the tensor to be reoganised
* @param paddingVec : padding of the vectorial tensor
* @param nbRow : number of rows of the tensor
* @param nbCol : number of column of the tensor
* @param vectorSize : number of element in the vectorial register (to make vectorial register usable as element)
*/
template<typename T>
void reshuffle_tensor_toScalNeighbour(T * tensorScalNeighbour, size_t paddingScal, const T * tensorVecNeighbour, size_t paddingVec, size_t nbRow, size_t nbCol, size_t vectorSize){
size_t rowSizeScal(nbCol + paddingScal), rowSizeVec(nbCol + paddingVec);
for(size_t i(0lu); i < nbRow; ++i){
reshuffle_row_toScalNeighbour(tensorScalNeighbour + i*rowSizeScal, tensorVecNeighbour + i*rowSizeVec, paddingVec, nbCol, vectorSize);
}
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment