From d6cdea49eb509af852e6279922863cf63adb4a56 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Tue, 16 Dec 2014 23:41:36 +0000
Subject: [PATCH] Small fixes

---
 src/opencl.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/opencl.c b/src/opencl.c
index 2a543bc..9255d4d 100644
--- a/src/opencl.c
+++ b/src/opencl.c
@@ -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