1 #ifndef OCL_UTILITIES_H 2 #define OCL_UTILITIES_H 3 4 #if defined(__APPLE__) 5 #include <OpenCL/opencl.h> 6 #else 7 #include <CL/opencl.h> 8 #endif 9 10 /* Return the OpenCL error string for a given error number. 11 */ 12 const char *opencl_error_string(cl_int error); 13 14 /* Find a GPU or a CPU associated with the first available platform. 15 * If use_gpu is set, then this function first tries to look for a GPU 16 * in the first available platform. 17 * If this fails or if use_gpu is not set, then it tries to use the CPU. 18 */ 19 cl_device_id opencl_create_device(int use_gpu); 20 21 /* Create an OpenCL program from a string and compile it. 22 */ 23 cl_program opencl_build_program_from_string(cl_context ctx, cl_device_id dev, 24 const char *program_source, size_t program_size, 25 const char *opencl_options); 26 27 /* Create an OpenCL program from a source file and compile it. 28 */ 29 cl_program opencl_build_program_from_file(cl_context ctx, cl_device_id dev, 30 const char* filename, const char* opencl_options); 31 32 #endif 33