-#include <iostream>\r
-#include <omp.h>\r
-\r
-#include "RipplingMOO.h"\r
-#include "OmpTools.h"\r
-\r
-#include "RipplingMath.h"\r
-\r
-using std::cout;\r
-using std::endl;\r
-using std::string;\r
-\r
-/*----------------------------------------------------------------------*\\r
- |* Declaration *|\r
- \*---------------------------------------------------------------------*/\r
-\r
-/*--------------------------------------*\\r
- |* Public *|\r
- \*-------------------------------------*/\r
-\r
-/*--------------------------------------*\\r
- |* Private *|\r
- \*-------------------------------------*/\r
-\r
-/*----------------------------------------------------------------------*\\r
- |* Implementation *|\r
- \*---------------------------------------------------------------------*/\r
-\r
-/*--------------------------------------*\\r
- |* Public *|\r
- \*-------------------------------------*/\r
-\r
-RipplingMOO::RipplingMOO(unsigned int w, unsigned int h, float dt)\r
- {\r
- this->t=0;\r
- this->dt=dt;\r
- }\r
-\r
-RipplingMOO::~RipplingMOO(void)\r
- {\r
- // rien\r
- }\r
-\r
-\r
-/*--------------------------------------*\\r
- |* Public *|\r
- \*-------------------------------------*/\r
-\r
-void RipplingMOO::process(uchar4* ptrTabPixels, int w, int h)\r
- {\r
- if (isEntrelacement)\r
- {\r
- entrelacementOMP(ptrTabPixels); // Plus lent\r
- }\r
- else\r
- {\r
- forAutoOMP(ptrTabPixels); // Plus rapide\r
- }\r
-\r
- isEntrelacement=!isEntrelacement;// Pour tester que les deux implementations fonctionnent\r
- }\r
-\r
-\r
-void RipplingMOO::animationStep()\r
- {\r
- t+=dt;\r
- }\r
-\r
-/*--------------*\\r
- |* get *|\r
- \*-------------*/\r
-\r
-float RipplingMOO::getT()\r
- {\r
- return t;\r
- }\r
-\r
-/*--------------------------------------*\\r
- |* Private *|\r
- \*-------------------------------------*/\r
-\r
-/**\r
- * Code entrainement Cuda\r
- */\r
-void RipplingMOO::entrelacementOMP(uchar4* ptrTabPixels)\r
- {\r
- // TODO\r
- }\r
-\r
-/**\r
- * Code naturel et direct OMP\r
- */\r
-void RipplingMOO::forAutoOMP(uchar4* ptrTabPixels)\r
- {\r
- // TODO\r
- }\r
-\r
-/*----------------------------------------------------------------------*\\r
- |* End *|\r
- \*---------------------------------------------------------------------*/\r
+#include <iostream>
+#include <omp.h>
+
+#include "RipplingMOO.h"
+#include "RipplingMath.h"
+
+#include "OmpTools.h"
+#include "IndiceTools.h"
+
+
+using std::cout;
+using std::endl;
+using std::string;
+
+/*----------------------------------------------------------------------*\
+ |* Declaration *|
+ \*---------------------------------------------------------------------*/
+
+/*--------------------------------------*\
+ |* Public *|
+ \*-------------------------------------*/
+
+/*--------------------------------------*\
+ |* Private *|
+ \*-------------------------------------*/
+
+/*----------------------------------------------------------------------*\
+ |* Implementation *|
+ \*---------------------------------------------------------------------*/
+
+/*--------------------------------------*\
+ |* Public *|
+ \*-------------------------------------*/
+
+RipplingMOO::RipplingMOO(unsigned int w, unsigned int h, float dt)
+ : w(w), h(h), t(0), dt(dt), isEntrelacement(false)
+ {
+ }
+
+RipplingMOO::~RipplingMOO(void)
+ {
+ // rien
+ }
+
+
+/*--------------------------------------*\
+ |* Public *|
+ \*-------------------------------------*/
+
+void RipplingMOO::process(uchar4* ptrTabPixels, int w, int h) // Pourquoi w et h ne sont pas utilisé??
+ {
+ if (this->isEntrelacement)x
+ this->entrelacementOMP(ptrTabPixels); // Plus lent
+ else
+ this->forAutoOMP(ptrTabPixels); // Plus rapide
+
+ this->isEntrelacement = ! this->isEntrelacement; // Pour tester que les deux implementations fonctionnent
+ }
+
+
+void RipplingMOO::animationStep()
+ {
+ this->t += this->dt;
+ }
+
+/*--------------*\
+ |* get *|
+ \*-------------*/
+
+float RipplingMOO::getT()
+ {
+ return this->t;
+ }
+
+/*--------------------------------------*\
+ |* Private *|
+ \*-------------------------------------*/
+
+/**
+ * Code entrainement Cuda
+ */
+void RipplingMOO::entrelacementOMP(uchar4* ptrTabPixels)
+ {
+ RipplingMath ripplingMath(w,h); // ici pour preparer cuda
+ const int WH = w * h;
+
+#pragma omp parallel
+ {
+ const int NB_THREAD = OmpTools::getNbThread();
+ const int TID = OmpTools::getTid();
+ int s = TID;
+
+ int i, j;
+ while (s < WH)
+ {
+ IndiceTools::toIJ(s, w, &i, &j); // s[0,W*H[ --> i[0,H[ j[0,W[
+ ripplingMath.colorIJ(&ptrTabPixels[s], i, j,t);
+ s += NB_THREAD;
+ }
+ }
+ }
+
+/**
+ * Code naturel et direct OMP
+ */
+void RipplingMOO::forAutoOMP(uchar4* ptrTabPixels)
+ {
+ RipplingMath ripplingMath(w,h); // ici pour preparer cuda
+
+#pragma omp parallel for
+ for (int i = 0; i < h; i++)
+ {
+ for (int j = 0; j < w; j++)
+ {
+ // int s = i * W + j;
+ const int s = IndiceTools::toS(w, i, j); // i[0,H[ j[0,W[ --> s[0,W*H[
+ ripplingMath.colorIJ(&ptrTabPixels[s], i, j,t);
+ }
+ }
+ }
+
+/*----------------------------------------------------------------------*\
+ |* End *|
+ \*---------------------------------------------------------------------*/