Commit f092e2af authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add function to initialise all the temporary matrices

parent 5529c63a
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include "temporary_alloc.h"
///Allocate temporary
/** @param[out] tmpU1 : matrix temporary U
* @param[out] tmpU2 : matrix temporary U
* @param[out] tmpV1 : matrix temporary V
* @param[out] tmpV2 : matrix temporary V
* @param[out] tmpInU : Tensor temporary in U
* @param[out] tmpInV : Tensor temporary in V
* @param[out] tmpOutU : Tensor temporary out U
* @param[out] tmpOutV : Tensor temporary out V
* @param nbRow : number of rows of the matrices to be created
* @param nbCol : number of columns of the matrices to be created
*/
void allocate_temporary(float *& tmpU1, float *& tmpU2, float *& tmpV1, float *& tmpV2,
PTensor<float> & tmpInU, PTensor<float> & tmpInV, PTensor<float> & tmpOutU, PTensor<float> & tmpOutV,
size_t nbRow, size_t nbCol)
{
tmpInU.resize(AllocMode::ALIGNED, nbRow, nbCol);
tmpInV.resize(AllocMode::ALIGNED, nbRow, nbCol);
tmpOutU.resize(AllocMode::ALIGNED, nbRow, nbCol);
tmpOutV.resize(AllocMode::ALIGNED, nbRow, nbCol);
tmpInU.fill(1.0f);
tmpOutU.fill(1.0f);
tmpInV.fill(0.0f);
tmpOutV.fill(0.0f);
size_t frac(9lu), numBegin(4lu), numEnd(5lu), rowShift(-25lu);
for(size_t i(rowShift + (numBegin*nbRow)/frac); i < rowShift + (numEnd*nbRow)/frac; ++i){
for(size_t j((numBegin*nbCol)/frac); j < (numEnd*nbCol)/frac; ++j){
tmpInU.setValue(i, j, 0.0f);
tmpInV.setValue(i, j, 1.0f);
}
}
tmpU1 = tmpInU.getData();
tmpU2 = tmpOutU.getData();
tmpV1 = tmpInV.getData();
tmpV2 = tmpOutV.getData();
}
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __TEMPORARY_ALLOC_H__
#define __TEMPORARY_ALLOC_H__
#include "PTensor.h"
///Swap two values
/** @param[out] a : value will be b
* @param[out] b : value will be a
*/
template<typename T>
void swapValue(T & a, T & b){
T c(a);
a = b;
b = c;
}
void allocate_temporary(float *& tmpU1, float *& tmpU2, float *& tmpV1, float *& tmpV2,
PTensor<float> & tmpInU, PTensor<float> & tmpInV, PTensor<float> & tmpOutU, PTensor<float> & tmpOutV,
size_t nbRow, size_t nbCol);
#endif
......@@ -5,7 +5,7 @@
****************************************/
#include "OptionParser.h"
#include "PTensor.h"
#include "temporary_alloc.h"
#include "ProgressTime.h"
#include "naive_propagation.h"
......@@ -41,17 +41,6 @@ OptionParser createOptionParser(){
return parser;
}
///Swap two values
/** @param[out] a : value will be b
* @param[out] b : value will be a
*/
template<typename T>
void swapValue(T & a, T & b){
T c(a);
a = b;
b = c;
}
///Simulate the images
/** @param nbRow : number of rows of the images to be created
* @param nbCol : number of columns of the images to be created
......@@ -70,25 +59,9 @@ bool simulateImage(size_t nbRow, size_t nbCol, size_t nbImage, size_t nbExtraSte
fullMat.setAllDim(nbCol, nbRow);
fullMat.resize(nbImage);
PTensor<float> tmpInU(AllocMode::ALIGNED, nbRow, nbCol);
PTensor<float> tmpInV(AllocMode::ALIGNED, nbRow, nbCol);
PTensor<float> tmpOutU(AllocMode::ALIGNED, nbRow, nbCol);
PTensor<float> tmpOutV(AllocMode::ALIGNED, nbRow, nbCol);
tmpInU.fill(1.0f);
tmpOutU.fill(1.0f);
tmpInV.fill(0.0f);
tmpOutV.fill(0.0f);
size_t frac(9lu), numBegin(4lu), numEnd(5lu), rowShift(-25lu);
for(size_t i(rowShift + (numBegin*nbRow)/frac); i < rowShift + (numEnd*nbRow)/frac; ++i){
for(size_t j((numBegin*nbCol)/frac); j < (numEnd*nbCol)/frac; ++j){
tmpInU.setValue(i, j, 0.0f);
tmpInV.setValue(i, j, 1.0f);
}
}
float *tmpU1 = tmpInU.getData(), *tmpU2 = tmpOutU.getData();
float *tmpV1 = tmpInV.getData(), *tmpV2 = tmpOutV.getData();
PTensor<float> tmpInU, tmpInV, tmpOutU, tmpOutV;
float *tmpU1 = NULL, *tmpU2 = NULL, *tmpV1 = NULL, *tmpV2 = NULL;
allocate_temporary(tmpU1, tmpU2, tmpV1, tmpV2, tmpInU, tmpInV, tmpOutU, tmpOutV, nbRow, nbCol);
long nbStencilRow(3l), nbStencilCol(3l);
......
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