Small fixes

This commit is contained in:
Joseph Redmon 2014-12-16 15:41:36 -08:00
parent 884045091b
commit d6cdea49eb
2 changed files with 4 additions and 1 deletions

View File

@ -562,7 +562,7 @@ void del_arg(int argc, char **argv, int index)
int find_arg(int argc, char* argv[], char *arg) int find_arg(int argc, char* argv[], char *arg)
{ {
int i; int i;
for(i = 0; i < argc-1; ++i) if(0==strcmp(argv[i], arg)) { for(i = 0; i < argc; ++i) if(0==strcmp(argv[i], arg)) {
del_arg(argc, argv, i); del_arg(argc, argv, i);
return 1; return 1;
} }

View File

@ -159,6 +159,7 @@ cl_kernel get_kernel(char *filename, char *kernelname, char *options)
void cl_read_array(cl_mem mem, float *x, int n) 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); cl.error = clEnqueueReadBuffer(cl.queue, mem, CL_TRUE, 0, sizeof(float)*n,x,0,0,0);
check_error(cl); check_error(cl);
} }
@ -175,6 +176,7 @@ float cl_checksum(cl_mem mem, int n)
void cl_write_array(cl_mem mem, float *x, int n) 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); cl.error = clEnqueueWriteBuffer(cl.queue, mem, CL_TRUE, 0,sizeof(float)*n,x,0,0,0);
check_error(cl); check_error(cl);
} }
@ -209,6 +211,7 @@ cl_mem cl_make_array(float *x, int n)
cl_mem cl_make_int_array(int *x, int n) cl_mem cl_make_int_array(int *x, int n)
{ {
if(gpu_index < 0) return 0;
cl_mem mem = clCreateBuffer(cl.context, cl_mem mem = clCreateBuffer(cl.context,
CL_MEM_READ_WRITE|CL_MEM_COPY_HOST_PTR, CL_MEM_READ_WRITE|CL_MEM_COPY_HOST_PTR,
sizeof(int)*n, x, &cl.error); sizeof(int)*n, x, &cl.error);