Advertisement
Guest User

Untitled

a guest
Oct 10th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. localacc@scrooge:~/src/cuda_samples/kerneltest$ cat simple1.cu
  2. #include <stdio.h>
  3.  
  4. __global__ void kernel2 ()
  5. {
  6. int iIdx = threadIdx.x ;
  7. printf ("hi from id : %d\n", iIdx) ;
  8. }
  9.  
  10. __global__ void kernel1 ()
  11. {
  12. kernel2 <<<1,2>>> () ;
  13. }
  14.  
  15. int some()
  16. {
  17. kernel1 <<<2,2>>> () ;
  18. cudaDeviceSynchronize () ;
  19.  
  20. printf( "Hello, World! \n");
  21. return 0;
  22. }
  23.  
  24. int main (void)
  25. {
  26. printf ("Hi there !!\n") ;
  27.  
  28. some () ;
  29.  
  30. return 0 ;
  31. }
  32. localacc@scrooge:~/src/cuda_samples/kerneltest$ nvcc -arch=sm_35 -rdc=true simple1.cu -o simple1 -lcudadevrt
  33. localacc@scrooge:~/src/cuda_samples/kerneltest$ ./simple1
  34. Hi there !!
  35. hi from id : 0
  36. hi from id : 1
  37. hi from id : 0
  38. hi from id : 1
  39. hi from id : 0
  40. hi from id : 1
  41. hi from id : 0
  42. hi from id : 1
  43. Hello, World!
  44. localacc@scrooge:~/src/cuda_samples/kerneltest$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement