9 #include "IndiceTools.h"
14 /*----------------------------------------------------------------------*\
16 \*---------------------------------------------------------------------*/
18 /*--------------------------------------*\
20 \*-------------------------------------*/
22 /*--------------------------------------*\
24 \*-------------------------------------*/
26 /*----------------------------------------------------------------------*\
28 \*---------------------------------------------------------------------*/
30 /*--------------------------------------*\
32 \*-------------------------------------*/
34 VagueMOO::VagueMOO(unsigned int w
, unsigned int h
, float dt
)
43 this->isEntrelacement
=true;
47 const int NB_THREADS
= OmpTools::setAndGetNaturalGranularity();
48 cout
<< "\n[VAGUE] nbThread = " << NB_THREADS
<< endl
;
51 VagueMOO::~VagueMOO(void)
56 /*--------------------------------------*\
58 \*-------------------------------------*/
60 void VagueMOO::process(uchar4
* ptrTabPixels
, int w
, int h
)
64 entrelacementOMP(ptrTabPixels
, w
, h
); // Plus lent
68 forAutoOMP(ptrTabPixels
, w
, h
); // Plus rapide
71 isEntrelacement
= !isEntrelacement
; // Pour tester que les deux implementations fonctionnent
74 void VagueMOO::animationStep()
83 float VagueMOO::getT()
88 float VagueMOO::getDT()
93 /*--------------------------------------*\
95 \*-------------------------------------*/
98 * Code naturel et direct OMP
100 void VagueMOO::forAutoOMP(uchar4
* ptrTabPixels
, int w
, int h
)
102 VagueMath
vagueMath(w
,h
); // ici pour preparer cuda
104 #pragma omp parallel for
105 for (int i
= 0; i
< h
; i
++)
107 for (int j
= 0; j
< w
; j
++)
109 // int s = i * W + j;
110 int s
= IndiceTools::toS(w
, i
, j
); // i[0,H[ j[0,W[ --> s[0,W*H[
112 vagueMath
.colorIJ(&ptrTabPixels
[s
], i
, j
,t
);
118 * Code entrainement Cuda
120 void VagueMOO::entrelacementOMP(uchar4
* ptrTabPixels
, int w
, int h
)
122 VagueMath
vagueMath(w
,h
); // ici pour preparer cuda
124 const int WH
= w
* h
;
129 const int NB_THREAD
= OmpTools::getNbThread();// dans region parallel
130 const int TID
= OmpTools::getTid();
131 int s
= TID
; // in [0,...
137 IndiceTools::toIJ(s
, w
, &i
, &j
); // s[0,W*H[ --> i[0,H[ j[0,W[
139 vagueMath
.colorIJ(&ptrTabPixels
[s
], i
, j
,t
);
147 /*----------------------------------------------------------------------*\
149 \*---------------------------------------------------------------------*/