From 0df9d25c46e39fa5f532c023261784fdcdd5d25d Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Thu, 11 Jun 2015 22:51:17 +0000
Subject: [PATCH] new cfg files for classification
---
src/cuda.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/cuda.c b/src/cuda.c
index 27153ea..1b914a5 100644
--- a/src/cuda.c
+++ b/src/cuda.c
@@ -1,9 +1,14 @@
+int gpu_index = 0;
+
+#ifdef GPU
+
#include "cuda.h"
#include "utils.h"
#include "blas.h"
+#include "assert.h"
#include <stdlib.h>
+#include <time.h>
-int gpu_index = 0;
void check_error(cudaError_t status)
{
@@ -12,6 +17,7 @@
const char *s = cudaGetErrorString(status);
char buffer[256];
printf("CUDA Error: %s\n", s);
+ assert(0);
snprintf(buffer, 256, "CUDA Error: %s", s);
error(buffer);
}
@@ -54,6 +60,19 @@
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));
@@ -96,4 +115,4 @@
check_error(status);
}
-
+#endif
--
Gitblit v1.10.0