exemple_kernel.cu 495 B

1234567891011121314151617181920212223
  1. #include <starpu.h>
  2. #include <starpu_cuda.h>
  3. static __global__ void myf(int *dMatA)
  4. {
  5. int tidy = threadIdx.y;
  6. dMatA[ tidy ] = dMatA[ tidy ] * 5;
  7. }
  8. extern "C" void my_codelet_gpu(void *descr[], void *_args)
  9. {
  10. unsigned nx = STARPU_VECTOR_GET_NX(descr[0]);
  11. int *sub = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
  12. dim3 dimGrid(1,1);
  13. dim3 dimBlock(nx,nx);
  14. myf<<<dimGrid, dimBlock, 0, starpu_cuda_get_local_stream()>>>(sub);
  15. cudaStreamSynchronize(starpu_cuda_get_local_stream());
  16. }