Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Student_Cuda / src / cpp / core / 01_Hello / 01_helloCuda.cu
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 (executable)
index 0000000..5c1b753
--- /dev/null
@@ -0,0 +1,86 @@
+// Attention : Extension .cu\r
+\r
+#include <iostream>\r
+#include "cudaTools.h"\r
+#include "Device.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
+__host__  bool helloCuda(void); //__host__ facultatif\r
+\r
+/*--------------------------------------*\\r
+ |*            Private                 *|\r
+ \*-------------------------------------*/\r
+\r
+__global__ static void kernelHello(void);\r
+__device__ static void doSomethingHello(void);\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    Implementation                                  *|\r
+ \*---------------------------------------------------------------------*/\r
+\r
+/*--------------------------------------*\\r
+ |*            Public                  *|\r
+ \*-------------------------------------*/\r
+\r
+/**\r
+ * resumer commande cuda:\r
+ * http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/index.html\r
+ */\r
+__host__ bool helloCuda(void) //__host__ facultatif\r
+    {\r
+    cout << endl << "[Hello Cuda 1]" << endl;\r
+\r
+    // Specifier nb thread : ici 1 thread au total !\r
+    dim3 dg = dim3(1, 1, 1);\r
+    dim3 db = dim3(1, 1, 1);\r
+\r
+    // Debug\r
+    //Device::print(dg, db);\r
+     Device::checkDimError(dg,db);\r
+\r
+    kernelHello<<<dg,db>>>();  // asynchrone !!\r
+    Device::checkKernelError("kernelHello"); // facultatif\r
+\r
+    return true;\r
+    }\r
+\r
+/*--------------------------------------*\\r
+ |*            Private                 *|\r
+ \*-------------------------------------*/\r
+\r
+\r
+/**\r
+ * output : void\r
+ */\r
+__global__ void kernelHello(void)\r
+    {\r
+    doSomethingHello();\r
+    }\r
+\r
+/**\r
+ * Can be call only by device\r
+ * inliner by nvcc (nvidia compiler)\r
+ */\r
+__device__ void doSomethingHello(void)\r
+    {\r
+    // rien\r
+    }\r
+\r
+/*----------------------------------------------------------------------*\\r
+ |*                    End                                             *|\r
+ \*---------------------------------------------------------------------*/\r
+\r