浏览代码

kernel cuda

This line, and those below, will be ignored--

 simple_ex/exemple_kernel.cu
Andra Hugo 14 年之前
父节点
当前提交
2c591a8c48
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22 0
      simple_ex/exemple_kernel.cu

+ 22 - 0
simple_ex/exemple_kernel.cu

@@ -0,0 +1,22 @@
+#include <starpu.h>
+#include <starpu_cuda.h>
+
+static __global__ void myf(int *dMatA)
+{
+  int tidy = threadIdx.y;
+
+  dMatA[ tidy ] = dMatA[ tidy ]  * 5;
+}
+
+extern "C" void my_codelet_gpu(void *descr[], void *_args)
+{
+  unsigned nx = STARPU_VECTOR_GET_NX(descr[0]);
+  int *sub = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
+
+  dim3 dimGrid(1,1);
+  dim3 dimBlock(nx,nx);
+
+  myf<<<dimGrid, dimBlock, 0, starpu_cuda_get_local_stream()>>>(sub);
+ 
+  cudaStreamSynchronize(starpu_cuda_get_local_stream());
+}