| | |
| | | #include "blas.h" |
| | | #include "assert.h" |
| | | #include <stdlib.h> |
| | | #include <time.h> |
| | | |
| | | |
| | | void check_error(cudaError_t status) |
| | |
| | | return x_gpu; |
| | | } |
| | | |
| | | void cuda_random(float *x_gpu, int n) |
| | | { |
| | | static curandGenerator_t gen; |
| | | static int init = 0; |
| | | if(!init){ |
| | | curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT); |
| | | curandSetPseudoRandomGeneratorSeed(gen, time(0)); |
| | | init = 1; |
| | | } |
| | | curandGenerateUniform(gen, x_gpu, n); |
| | | check_error(cudaPeekAtLastError()); |
| | | } |
| | | |
| | | float cuda_compare(float *x_gpu, float *x, int n, char *s) |
| | | { |
| | | float *tmp = calloc(n, sizeof(float)); |