X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F03_Newton%2Fmoo%2Fdevice%2FNewtonDevice.cu;fp=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F03_Newton%2Fmoo%2Fdevice%2FNewtonDevice.cu;h=536b75bd3c0adbe09900a937f28c36c978aafc8e;hb=7b1db14e9df63c577384e1722d2028438a51944e;hp=0000000000000000000000000000000000000000;hpb=bd178531f80f8bc41c998d1c4588f9e18cc29389;p=GPU.git diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/NewtonDevice.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/NewtonDevice.cu new file mode 100755 index 0000000..536b75b --- /dev/null +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/NewtonDevice.cu @@ -0,0 +1,43 @@ +#include + +#include "Indice2D.h" +#include "IndiceTools.h" +#include "DomaineMath.h" +#include "cudaTools.h" +#include "Device.h" + +#include "NewtonMath.h" + +using std::cout; +using std::endl; + +__global__ void newton(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath) + { + const int TID = Indice2D::tid(); + const int NB_THREAD = Indice2D::nbThread(); + const int WH = w * h; + + NewtonMath newtonMath; + + uchar4 color; + color.z = 255; // Par défaut, l'image est opaque. + + double x, y; + int pixelI, pixelJ; + + int s = TID; + while (s < WH) + { + IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ) + + // (i,j) domaine ecran + // (x,y) domaine math + domaineMath.toXY(pixelI, pixelJ, &x, &y); // (i,j) -> (x,y) + + newtonMath.colorXY(&color, x, y); + + ptrDevPixels[s] = color; + + s += NB_THREAD; + } + }