Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 00_Rippling_warmup / 02_cuda / rippling0.cu
diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/00_Rippling_warmup/02_cuda/rippling0.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/00_Rippling_warmup/02_cuda/rippling0.cu
new file mode 100755 (executable)
index 0000000..eb778bf
--- /dev/null
@@ -0,0 +1,91 @@
+#include <iostream>\r
+#include <stdlib.h>\r
+\r
+#include "Indice2D.h"\r
+#include "IndiceTools.h"\r
+#include "cudaTools.h"\r
+#include "Device.h"\r
+\r
+#include "Rippling0Math.h"\r
+\r
+using std::cout;\r
+using std::endl;\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Declaration                                     *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Imported                *|\r
+ \*-------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+\r
+\r
+/*--------------------------------------*\\r
+ |*            Private                 *|\r
+ \*-------------------------------------*/\r
+\r
+static __global__ void rippling0(uchar4* ptrDevPixels,int w, int h,float t);\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Implementation                                  *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+void launchKernelRippling0(uchar4* ptrDevPixels, int w, int h, float t)\r
+    {\r
+    dim3 dg = dim3(8, 8, 1); // disons, a optimiser\r
+    dim3 db = dim3(16, 16, 1); // disons, a optimiser\r
+\r
+    //Device::print(dg, db);\r
+     Device::checkDimError(dg,db);\r
+\r
+    rippling0<<<dg,db>>>(ptrDevPixels,w,h,t);\r
+    Device::checkKernelError("rippling0");\r
+    }\r
+\r
+/*--------------------------------------*\\r
+ |*            Private                 *|\r
+ \*-------------------------------------*/\r
+\r
+__global__ void rippling0(uchar4* ptrDevPixels, int w, int h, float t)\r
+    {\r
+    Rippling0Math rippling0Math = Rippling0Math(w, h);\r
+\r
+    const int TID = Indice2D::tid();\r
+    const int NB_THREAD = Indice2D::nbThread();\r
+\r
+    const int WH=w*h;\r
+\r
+    uchar4 color;\r
+    color.w = 255; // alpha\r
+\r
+    int pixelI;\r
+    int pixelJ;\r
+\r
+    int s = TID;\r
+    while (s < WH)\r
+       {\r
+       IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ)\r
+\r
+       rippling0Math.color(pixelI, pixelJ, t, &color); // update color\r
+       ptrDevPixels[s] = color;\r
+\r
+       s += NB_THREAD;\r
+       }\r
+\r
+    }\r
+\r
+\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    End                                             *|\r
+ \*---------------------------------------------------------------------*/\r
+\r