| | |
| | | #ifdef GPU |
| | | #include "opencl.h" |
| | | #include <stdio.h> |
| | | #include <stdlib.h> |
| | |
| | | { |
| | | if (info.error != CL_SUCCESS) { |
| | | printf("\n Error number %d", info.error); |
| | | exit(1); |
| | | } |
| | | } |
| | | |
| | |
| | | clGetProgramBuildInfo( prog, info.device, CL_PROGRAM_BUILD_LOG, 4096, build_c, 0); |
| | | fprintf(stderr, "Build Log for %s program:\n%s\n", filename, build_c); |
| | | } |
| | | check_error(info); |
| | | return prog; |
| | | } |
| | | |
| | |
| | | return kernel; |
| | | } |
| | | |
| | | void cl_read_array(cl_mem mem, float *x, int n) |
| | | { |
| | | cl_setup(); |
| | | clEnqueueReadBuffer(cl.queue, mem, CL_TRUE, 0, sizeof(float)*n,x,0,0,0); |
| | | check_error(cl); |
| | | } |
| | | |
| | | void cl_write_array(cl_mem mem, float *x, int n) |
| | | { |
| | | cl_setup(); |
| | | clEnqueueWriteBuffer(cl.queue, mem, CL_TRUE, 0,sizeof(float)*n,x,0,0,0); |
| | | check_error(cl); |
| | | } |
| | | |
| | | #endif |