From 08b757a0bf76efe8c76b453063a1bb19315bcaa6 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Wed, 14 Jan 2015 20:18:57 +0000
Subject: [PATCH] Stable, needs to be way faster
---
src/opencl.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/opencl.c b/src/opencl.c
index 2a543bc..cff4d0e 100644
--- a/src/opencl.c
+++ b/src/opencl.c
@@ -18,7 +18,7 @@
void check_error(cl_info info)
{
- // clFinish(cl.queue);
+ clFinish(cl.queue);
if (info.error != CL_SUCCESS) {
printf("\n Error number %d", info.error);
abort();
@@ -144,7 +144,7 @@
void cl_setup()
{
if(!cl.initialized){
- printf("initializing\n");
+ fprintf(stderr, "Initializing OpenCL\n");
cl = cl_init(gpu_index);
}
}
@@ -159,6 +159,7 @@
void cl_read_array(cl_mem mem, float *x, int n)
{
+ if(gpu_index < 0) return;
cl.error = clEnqueueReadBuffer(cl.queue, mem, CL_TRUE, 0, sizeof(float)*n,x,0,0,0);
check_error(cl);
}
@@ -175,6 +176,7 @@
void cl_write_array(cl_mem mem, float *x, int n)
{
+ if(gpu_index < 0) return;
cl.error = clEnqueueWriteBuffer(cl.queue, mem, CL_TRUE, 0,sizeof(float)*n,x,0,0,0);
check_error(cl);
}
@@ -209,6 +211,7 @@
cl_mem cl_make_int_array(int *x, int n)
{
+ if(gpu_index < 0) return 0;
cl_mem mem = clCreateBuffer(cl.context,
CL_MEM_READ_WRITE|CL_MEM_COPY_HOST_PTR,
sizeof(int)*n, x, &cl.error);
--
Gitblit v1.10.0