X-Git-Url: http://git.euphorik.ch/?p=GPU.git;a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F06_Convolution%2Fmoo%2Fhost%2FConvolution.cu;fp=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F06_Convolution%2Fmoo%2Fhost%2FConvolution.cu;h=ecc44643334e65a5baf8e8f24d690c1c9300059c;hp=0000000000000000000000000000000000000000;hb=4182eb3a07b7143afb8ebebfe77e8ef8e8abc266;hpb=fd0031be0a39a5d902750affaff6322fcd5229b1 diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/06_Convolution/moo/host/Convolution.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/06_Convolution/moo/host/Convolution.cu new file mode 100644 index 0000000..ecc4464 --- /dev/null +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/06_Convolution/moo/host/Convolution.cu @@ -0,0 +1,67 @@ +#include +#include +#include +using namespace std; + +#include "Device.h" + +#include "Convolution.h" +#include "ConvolutionDevice.h" + + +const float Convolution::kernel[9][9] = + {{0.0828, 0.1987, 0.3705, 0.5366, 0.6063, 0.5366, 0.3705, 0.1987, 0.0828}, + {0.1987, 0.4746, 0.8646, 1.1794, 1.2765, 1.1794, 0.8646, 0.4746, 0.1987}, + {0.3705, 0.8646, 1.3475, 1.0033, 0.4061, 1.0033, 1.3475, 0.8646, 0.3705}, + {0.5366, 1.1794, 1.0033, -2.8306, -6.4829, -2.8306, 1.0033, 1.1794, 0.5366}, + {0.6063, 1.2765, 0.4061, -6.4829, -12.7462, -6.4829, 0.4061, 1.2765, 0.6063}, + {0.5366, 1.1794, 1.0033, -2.8306, -6.4829, -2.8306, 1.0033, 1.1794, 0.5366}, + {0.3705, 0.8646, 1.3475, 1.0033, 0.4061, 1.0033, 1.3475, 0.8646, 0.3705}, + {0.1987, 0.4746, 0.8646, 1.1794, 1.2765, 1.1794, 0.8646, 0.4746, 0.1987}, + {0.0828, 0.1987, 0.3705, 0.5366, 0.6063, 0.5366, 0.3705, 0.1987, 0.0828}}; + +Convolution::Convolution(int w, int h) : + w(w), h(h), + dg(8, 8, 1), + db(32, 32, 1), + title("Convolution") + { + Device::assertDim(dg, db); + } + +Convolution::~Convolution() + { + } + +void Convolution::runGPU(uchar4* ptrDevPixels) + { + convolution<<>>(ptrDevPixels, this->w, this->h, this->t); + + // HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG). + } + +void Convolution::animationStep() + { + this->t += 0.1; // TODO. + } + +int Convolution::getW() + { + return this->w; + } + +int Convolution::getH() + { + return this->h; + } + +float Convolution::getT() + { + return this->t; + } + +string Convolution::getTitle() + { + return this->title; + } +