Last active
June 21, 2018 20:14
-
-
Save kaityo256/0241257bda1d97da1c95 to your computer and use it in GitHub Desktop.
CUDA sample for curand_kernel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <cuda.h> | |
| #include <curand_kernel.h> | |
| __global__ void | |
| func(void){ | |
| int id = blockIdx.x * blockDim.x + threadIdx.x; | |
| curandState s; | |
| curand_init(0,id,0,&s); | |
| for(int i=0;i<4;i++){ | |
| printf("%d %f\n",id,curand_uniform_double(&s)); | |
| } | |
| } | |
| int | |
| main(void){ | |
| cudaSetDeviceFlags(cudaDeviceMapHost); | |
| int const n_thread = 2; | |
| int const n_block = 2; | |
| func<<<n_block,n_thread>>>(); | |
| printf("Version = %d\n",CUDA_VERSION); | |
| cudaThreadSynchronize(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment