X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda%2Fsrc%2Fcpp%2Fcore%2F01_Hello%2F01_helloCuda.cu;fp=WCudaMSE%2FStudent_Cuda%2Fsrc%2Fcpp%2Fcore%2F01_Hello%2F01_helloCuda.cu;h=5c1b75312d54bfb5282f1fccc05304f7433d6780;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/Student_Cuda/src/cpp/core/01_Hello/01_helloCuda.cu b/WCudaMSE/Student_Cuda/src/cpp/core/01_Hello/01_helloCuda.cu new file mode 100755 index 0000000..5c1b753 --- /dev/null +++ b/WCudaMSE/Student_Cuda/src/cpp/core/01_Hello/01_helloCuda.cu @@ -0,0 +1,86 @@ +// Attention : Extension .cu + +#include +#include "cudaTools.h" +#include "Device.h" + +using std::cout; +using std::endl; + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Imported *| + \*-------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +__host__ bool helloCuda(void); //__host__ facultatif + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +__global__ static void kernelHello(void); +__device__ static void doSomethingHello(void); + +/*----------------------------------------------------------------------*\ + |* Implementation *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +/** + * resumer commande cuda: + * http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/index.html + */ +__host__ bool helloCuda(void) //__host__ facultatif + { + cout << endl << "[Hello Cuda 1]" << endl; + + // Specifier nb thread : ici 1 thread au total ! + dim3 dg = dim3(1, 1, 1); + dim3 db = dim3(1, 1, 1); + + // Debug + //Device::print(dg, db); + Device::checkDimError(dg,db); + + kernelHello<<>>(); // asynchrone !! + Device::checkKernelError("kernelHello"); // facultatif + + return true; + } + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + + +/** + * output : void + */ +__global__ void kernelHello(void) + { + doSomethingHello(); + } + +/** + * Can be call only by device + * inliner by nvcc (nvidia compiler) + */ +__device__ void doSomethingHello(void) + { + // rien + } + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/ +