12 #include "libopencl.h" 15 #if defined(__APPLE__) || defined(__MACOSX) 16 static const char *default_so_paths[] = {
19 #elif defined(__ANDROID__) 20 static const char *default_so_paths[] = {
21 "/system/lib/libOpenCL.so",
22 "/system/vendor/lib/libOpenCL.so",
23 "/system/vendor/lib/egl/libGLES_mali.so",
24 "/system/vendor/lib/libPVROCL.so",
25 "/data/data/org.pocl.libs/files/lib/libpocl.so",
29 static const char *default_so_paths[] = {
32 #elif defined(__linux__) 33 static const char *default_so_paths[] = {
34 "/usr/lib/libOpenCL.so",
35 "/usr/local/lib/libOpenCL.so",
36 "/usr/local/lib/libpocl.so",
37 "/usr/lib64/libOpenCL.so",
38 "/usr/lib32/libOpenCL.so",
43 static void *so_handle = NULL;
46 static int access_file(
const char *filename)
49 return (stat(filename, &buffer) == 0);
52 int open_libopencl_so()
54 char *path = NULL, *str = NULL;
57 if((str=getenv(
"LIBOPENCL_SO_PATH")) && access_file(str)) {
60 else if((str=getenv(
"LIBOPENCL_SO_PATH_2")) && access_file(str)) {
63 else if((str=getenv(
"LIBOPENCL_SO_PATH_3")) && access_file(str)) {
66 else if((str=getenv(
"LIBOPENCL_SO_PATH_4")) && access_file(str)) {
72 for(i=0; i<(
sizeof(default_so_paths) /
sizeof(
char*)); i++)
74 if(access_file(default_so_paths[i]))
76 path = (
char *) default_so_paths[i];
84 so_handle = dlopen(path, RTLD_LAZY);
93 cl_int get_libopencl_path(
char** cl_path)
95 char *path = NULL, *str = NULL;
98 if((str=getenv(
"LIBOPENCL_SO_PATH")) && access_file(str)) {
101 else if((str=getenv(
"LIBOPENCL_SO_PATH_2")) && access_file(str)) {
104 else if((str=getenv(
"LIBOPENCL_SO_PATH_3")) && access_file(str)) {
107 else if((str=getenv(
"LIBOPENCL_SO_PATH_4")) && access_file(str)) {
113 for(i=0; i<(
sizeof(default_so_paths) /
sizeof(
char*)); i++)
115 if(access_file(default_so_paths[i]))
117 path = (
char *) default_so_paths[i];
125 *cl_path = strndup(path, strlen(path));
128 return CL_INVALID_PLATFORM;
131 void stubOpenclReset()
140 clGetPlatformIDs(cl_uint num_entries,
141 cl_platform_id * platforms,
142 cl_uint * num_platforms)
144 f_clGetPlatformIDs func;
149 func = (f_clGetPlatformIDs) dlsym(so_handle,
"clGetPlatformIDs");
151 return func(num_entries, platforms, num_platforms);
153 return CL_INVALID_PLATFORM;
159 clGetPlatformInfo(cl_platform_id platform,
160 cl_platform_info param_name,
161 size_t param_value_size,
163 size_t * param_value_size_ret)
165 f_clGetPlatformInfo func;
170 func = (f_clGetPlatformInfo) dlsym(so_handle,
"clGetPlatformInfo");
172 return func(platform, param_name, param_value_size, param_value, param_value_size_ret);
174 return CL_INVALID_PLATFORM;
180 clGetDeviceIDs(cl_platform_id platform,
181 cl_device_type device_type,
183 cl_device_id * devices,
184 cl_uint * num_devices)
186 f_clGetDeviceIDs func;
191 func = (f_clGetDeviceIDs) dlsym(so_handle,
"clGetDeviceIDs");
193 return func(platform, device_type, num_entries, devices, num_devices);
195 return CL_INVALID_PLATFORM;
200 clGetDeviceInfo(cl_device_id device,
201 cl_device_info param_name,
202 size_t param_value_size,
204 size_t * param_value_size_ret)
206 f_clGetDeviceInfo func;
211 func = (f_clGetDeviceInfo) dlsym(so_handle,
"clGetDeviceInfo");
213 return func(device, param_name, param_value_size, param_value, param_value_size_ret);
215 return CL_INVALID_PLATFORM;
220 clCreateSubDevices(cl_device_id in_device,
221 const cl_device_partition_property * properties,
223 cl_device_id * out_devices,
224 cl_uint * num_devices_ret)
226 f_clCreateSubDevices func;
231 func = (f_clCreateSubDevices) dlsym(so_handle,
"clCreateSubDevices");
233 return func(in_device, properties, num_devices, out_devices, num_devices_ret);
235 return CL_INVALID_PLATFORM;
240 clRetainDevice(cl_device_id device)
242 f_clRetainDevice func;
247 func = (f_clRetainDevice) dlsym(so_handle,
"clRetainDevice");
251 return CL_INVALID_PLATFORM;
256 clReleaseDevice(cl_device_id device)
258 f_clReleaseDevice func;
263 func = (f_clReleaseDevice) dlsym(so_handle,
"clReleaseDevice");
267 return CL_INVALID_PLATFORM;
273 clCreateContext(
const cl_context_properties * properties,
275 const cl_device_id * devices,
276 void (*pfn_notify)(
const char *,
const void *,
size_t,
void *),
278 cl_int * errcode_ret)
280 f_clCreateContext func;
285 func = (f_clCreateContext) dlsym(so_handle,
"clCreateContext");
287 return func(properties, num_devices, devices, pfn_notify, user_data, errcode_ret);
294 clCreateContextFromType(
const cl_context_properties * properties,
295 cl_device_type device_type,
296 void (*pfn_notify )(
const char *,
const void *,
size_t,
void *),
298 cl_int * errcode_ret)
300 f_clCreateContextFromType func;
305 func = (f_clCreateContextFromType) dlsym(so_handle,
"clCreateContextFromType");
307 return func(properties, device_type, pfn_notify, user_data, errcode_ret);
314 clRetainContext(cl_context context)
316 f_clRetainContext func;
321 func = (f_clRetainContext) dlsym(so_handle,
"clRetainContext");
323 return func(context);
325 return CL_INVALID_PLATFORM;
330 clReleaseContext(cl_context context)
332 f_clReleaseContext func;
337 func = (f_clReleaseContext) dlsym(so_handle,
"clReleaseContext");
339 return func(context);
341 return CL_INVALID_PLATFORM;
346 clGetContextInfo(cl_context context,
347 cl_context_info param_name,
348 size_t param_value_size,
350 size_t * param_value_size_ret)
352 f_clGetContextInfo func;
357 func = (f_clGetContextInfo) dlsym(so_handle,
"clGetContextInfo");
359 return func(context, param_name, param_value_size,
360 param_value, param_value_size_ret);
362 return CL_INVALID_PLATFORM;
368 clCreateCommandQueue(cl_context context,
370 cl_command_queue_properties properties,
371 cl_int * errcode_ret)
373 f_clCreateCommandQueue func;
378 func = (f_clCreateCommandQueue) dlsym(so_handle,
"clCreateCommandQueue");
380 return func(context, device, properties, errcode_ret);
387 clRetainCommandQueue(cl_command_queue command_queue)
389 f_clRetainCommandQueue func;
394 func = (f_clRetainCommandQueue) dlsym(so_handle,
"clRetainCommandQueue");
396 return func(command_queue);
398 return CL_INVALID_PLATFORM;
403 clReleaseCommandQueue(cl_command_queue command_queue)
405 f_clReleaseCommandQueue func;
410 func = (f_clReleaseCommandQueue) dlsym(so_handle,
"clReleaseCommandQueue");
412 return func(command_queue);
414 return CL_INVALID_PLATFORM;
419 clGetCommandQueueInfo(cl_command_queue command_queue,
420 cl_command_queue_info param_name,
421 size_t param_value_size,
423 size_t * param_value_size_ret)
425 f_clGetCommandQueueInfo func;
430 func = (f_clGetCommandQueueInfo) dlsym(so_handle,
"clGetCommandQueueInfo");
432 return func(command_queue, param_name, param_value_size,
433 param_value, param_value_size_ret);
435 return CL_INVALID_PLATFORM;
441 clCreateBuffer(cl_context context,
445 cl_int * errcode_ret)
447 f_clCreateBuffer func;
452 func = (f_clCreateBuffer) dlsym(so_handle,
"clCreateBuffer");
454 return func(context, flags, size, host_ptr, errcode_ret);
461 clCreateSubBuffer(cl_mem buffer,
463 cl_buffer_create_type buffer_create_type,
464 const void * buffer_create_info,
465 cl_int * errcode_ret)
467 f_clCreateSubBuffer func;
472 func = (f_clCreateSubBuffer) dlsym(so_handle,
"clCreateSubBuffer");
474 return func(buffer, flags, buffer_create_type,
475 buffer_create_info, errcode_ret);
482 clCreateImage(cl_context context,
487 cl_int * errcode_ret)
489 f_clCreateImage func;
494 func = (f_clCreateImage) dlsym(so_handle,
"clCreateImage");
496 return func(context, flags, image_format, image_desc,
497 host_ptr, errcode_ret);
504 clRetainMemObject(cl_mem memobj)
506 f_clRetainMemObject func;
511 func = (f_clRetainMemObject) dlsym(so_handle,
"clRetainMemObject");
515 return CL_INVALID_PLATFORM;
520 clReleaseMemObject(cl_mem memobj)
522 f_clReleaseMemObject func;
527 func = (f_clReleaseMemObject) dlsym(so_handle,
"clReleaseMemObject");
531 return CL_INVALID_PLATFORM;
536 clGetSupportedImageFormats(cl_context context,
538 cl_mem_object_type image_type,
541 cl_uint * num_image_formats)
543 f_clGetSupportedImageFormats func;
548 func = (f_clGetSupportedImageFormats) dlsym(so_handle,
"clGetSupportedImageFormats");
550 return func(context, flags, image_type, num_entries,
551 image_formats, num_image_formats);
553 return CL_INVALID_PLATFORM;
558 clGetMemObjectInfo(cl_mem memobj,
559 cl_mem_info param_name,
560 size_t param_value_size,
562 size_t * param_value_size_ret)
564 f_clGetMemObjectInfo func;
569 func = (f_clGetMemObjectInfo) dlsym(so_handle,
"clGetMemObjectInfo");
571 return func(memobj, param_name, param_value_size,
572 param_value, param_value_size_ret);
574 return CL_INVALID_PLATFORM;
579 clGetImageInfo(cl_mem image,
580 cl_image_info param_name,
581 size_t param_value_size,
583 size_t * param_value_size_ret)
585 f_clGetImageInfo func;
590 func = (f_clGetImageInfo) dlsym(so_handle,
"clGetImageInfo");
592 return func(image, param_name, param_value_size,
593 param_value, param_value_size_ret);
595 return CL_INVALID_PLATFORM;
600 clSetMemObjectDestructorCallback( cl_mem memobj,
601 void (*pfn_notify)( cl_mem memobj,
void* user_data),
604 f_clSetMemObjectDestructorCallback func;
609 func = (f_clSetMemObjectDestructorCallback) dlsym(so_handle,
"clSetMemObjectDestructorCallback");
611 return func(memobj, pfn_notify, user_data);
613 return CL_INVALID_PLATFORM;
618 clCreateSampler(cl_context context,
619 cl_bool normalized_coords,
620 cl_addressing_mode addressing_mode,
621 cl_filter_mode filter_mode,
622 cl_int * errcode_ret)
624 f_clCreateSampler func;
629 func = (f_clCreateSampler) dlsym(so_handle,
"clCreateSampler");
631 return func(context, normalized_coords, addressing_mode, filter_mode, errcode_ret);
638 clRetainSampler(cl_sampler sampler)
640 f_clRetainSampler func;
645 func = (f_clRetainSampler) dlsym(so_handle,
"clRetainSampler");
647 return func(sampler);
649 return CL_INVALID_PLATFORM;
654 clReleaseSampler(cl_sampler sampler)
656 f_clReleaseSampler func;
661 func = (f_clReleaseSampler) dlsym(so_handle,
"clReleaseSampler");
663 return func(sampler);
665 return CL_INVALID_PLATFORM;
670 clGetSamplerInfo(cl_sampler sampler,
671 cl_sampler_info param_name,
672 size_t param_value_size,
674 size_t * param_value_size_ret)
676 f_clGetSamplerInfo func;
681 func = (f_clGetSamplerInfo) dlsym(so_handle,
"clGetSamplerInfo");
683 return func(sampler, param_name, param_value_size, param_value, param_value_size_ret);
685 return CL_INVALID_PLATFORM;
691 clCreateProgramWithSource(cl_context context,
693 const char ** strings,
694 const size_t * lengths,
695 cl_int * errcode_ret)
697 f_clCreateProgramWithSource func;
702 func = (f_clCreateProgramWithSource) dlsym(so_handle,
"clCreateProgramWithSource");
704 return func(context, count, strings, lengths, errcode_ret);
713 clCreateProgramWithBinary(cl_context context,
715 const cl_device_id * device_list,
716 const size_t * lengths,
717 const unsigned char ** binaries,
718 cl_int * binary_status,
719 cl_int * errcode_ret)
721 f_clCreateProgramWithBinary func;
726 func = (f_clCreateProgramWithBinary) dlsym(so_handle,
"clCreateProgramWithBinary");
728 return func(context, num_devices, device_list, lengths, binaries, binary_status, errcode_ret);
735 clCreateProgramWithBuiltInKernels(cl_context context,
737 const cl_device_id * device_list,
738 const char * kernel_names,
739 cl_int * errcode_ret)
741 f_clCreateProgramWithBuiltInKernels func;
746 func = (f_clCreateProgramWithBuiltInKernels) dlsym(so_handle,
"clCreateProgramWithBuiltInKernels");
748 return func(context, num_devices, device_list, kernel_names, errcode_ret);
755 clRetainProgram(cl_program program)
757 f_clRetainProgram func;
762 func = (f_clRetainProgram) dlsym(so_handle,
"clRetainProgram");
764 return func(program);
766 return CL_INVALID_PLATFORM;
771 clReleaseProgram(cl_program program)
773 f_clReleaseProgram func;
778 func = (f_clReleaseProgram) dlsym(so_handle,
"clReleaseProgram");
780 return func(program);
782 return CL_INVALID_PLATFORM;
787 clBuildProgram(cl_program program,
789 const cl_device_id * device_list,
790 const char * options,
791 void (*pfn_notify)(cl_program program,
void * user_data),
794 f_clBuildProgram func;
799 func = (f_clBuildProgram) dlsym(so_handle,
"clBuildProgram");
801 return func(program, num_devices, device_list, options, pfn_notify, user_data);
803 return CL_INVALID_PLATFORM;
808 clCompileProgram(cl_program program,
810 const cl_device_id * device_list,
811 const char * options,
812 cl_uint num_input_headers,
813 const cl_program * input_headers,
814 const char ** header_include_names,
815 void (*pfn_notify)(cl_program program,
void * user_data),
818 f_clCompileProgram func;
823 func = (f_clCompileProgram) dlsym(so_handle,
"clCompileProgram");
825 return func(program, num_devices, device_list, options, num_input_headers, input_headers,
826 header_include_names, pfn_notify, user_data);
828 return CL_INVALID_PLATFORM;
833 clLinkProgram(cl_context context,
835 const cl_device_id * device_list,
836 const char * options,
837 cl_uint num_input_programs,
838 const cl_program * input_programs,
839 void (*pfn_notify)(cl_program program,
void * user_data),
841 cl_int * errcode_ret)
843 f_clLinkProgram func;
848 func = (f_clLinkProgram) dlsym(so_handle,
"clLinkProgram");
850 return func(context, num_devices, device_list, options, num_input_programs,
851 input_programs, pfn_notify, user_data, errcode_ret);
859 clUnloadPlatformCompiler(cl_platform_id platform)
861 f_clUnloadPlatformCompiler func;
866 func = (f_clUnloadPlatformCompiler) dlsym(so_handle,
"clUnloadPlatformCompiler");
868 return func(platform);
870 return CL_INVALID_PLATFORM;
875 clGetProgramInfo(cl_program program,
876 cl_program_info param_name,
877 size_t param_value_size,
879 size_t * param_value_size_ret)
881 f_clGetProgramInfo func;
886 func = (f_clGetProgramInfo) dlsym(so_handle,
"clGetProgramInfo");
888 return func(program, param_name, param_value_size,
889 param_value, param_value_size_ret);
891 return CL_INVALID_PLATFORM;
896 clGetProgramBuildInfo(cl_program program,
898 cl_program_build_info param_name,
899 size_t param_value_size,
901 size_t * param_value_size_ret)
903 f_clGetProgramBuildInfo func;
908 func = (f_clGetProgramBuildInfo) dlsym(so_handle,
"clGetProgramBuildInfo");
910 return func(program, device, param_name, param_value_size,
911 param_value, param_value_size_ret);
913 return CL_INVALID_PLATFORM;
919 clCreateKernel(cl_program program,
920 const char * kernel_name,
921 cl_int * errcode_ret)
923 f_clCreateKernel func;
928 func = (f_clCreateKernel) dlsym(so_handle,
"clCreateKernel");
930 return func(program, kernel_name, errcode_ret);
937 clCreateKernelsInProgram(cl_program program,
940 cl_uint * num_kernels_ret)
942 f_clCreateKernelsInProgram func;
947 func = (f_clCreateKernelsInProgram) dlsym(so_handle,
"clCreateKernelsInProgram");
949 return func(program, num_kernels, kernels, num_kernels_ret);
951 return CL_INVALID_PLATFORM;
956 clRetainKernel(cl_kernel kernel)
958 f_clRetainKernel func;
963 func = (f_clRetainKernel) dlsym(so_handle,
"clRetainKernel");
967 return CL_INVALID_PLATFORM;
972 clReleaseKernel(cl_kernel kernel)
974 f_clReleaseKernel func;
979 func = (f_clReleaseKernel) dlsym(so_handle,
"clReleaseKernel");
983 return CL_INVALID_PLATFORM;
988 clSetKernelArg(cl_kernel kernel,
991 const void * arg_value)
993 f_clSetKernelArg func;
998 func = (f_clSetKernelArg) dlsym(so_handle,
"clSetKernelArg");
1000 return func(kernel, arg_index, arg_size, arg_value);
1002 return CL_INVALID_PLATFORM;
1007 clGetKernelInfo(cl_kernel kernel,
1008 cl_kernel_info param_name,
1009 size_t param_value_size,
1011 size_t * param_value_size_ret)
1013 f_clGetKernelInfo func;
1016 open_libopencl_so();
1018 func = (f_clGetKernelInfo) dlsym(so_handle,
"clGetKernelInfo");
1020 return func(kernel, param_name, param_value_size, param_value, param_value_size_ret);
1022 return CL_INVALID_PLATFORM;
1027 clGetKernelArgInfo(cl_kernel kernel,
1029 cl_kernel_arg_info param_name,
1030 size_t param_value_size,
1032 size_t * param_value_size_ret)
1034 f_clGetKernelArgInfo func;
1037 open_libopencl_so();
1039 func = (f_clGetKernelArgInfo) dlsym(so_handle,
"clGetKernelArgInfo");
1041 return func(kernel, arg_indx, param_name, param_value_size,
1042 param_value, param_value_size_ret);
1044 return CL_INVALID_PLATFORM;
1049 clGetKernelWorkGroupInfo(cl_kernel kernel,
1050 cl_device_id device,
1051 cl_kernel_work_group_info param_name,
1052 size_t param_value_size,
1054 size_t * param_value_size_ret)
1056 f_clGetKernelWorkGroupInfo func;
1059 open_libopencl_so();
1061 func = (f_clGetKernelWorkGroupInfo) dlsym(so_handle,
"clGetKernelWorkGroupInfo");
1063 return func(kernel, device, param_name, param_value_size, param_value, param_value_size_ret);
1065 return CL_INVALID_PLATFORM;
1071 clWaitForEvents(cl_uint num_events,
1072 const cl_event * event_list)
1074 f_clWaitForEvents func;
1077 open_libopencl_so();
1079 func = (f_clWaitForEvents) dlsym(so_handle,
"clWaitForEvents");
1081 return func(num_events, event_list);
1083 return CL_INVALID_PLATFORM;
1089 clGetEventInfo(cl_event event,
1090 cl_event_info param_name,
1091 size_t param_value_size,
1093 size_t * param_value_size_ret)
1095 f_clGetEventInfo func;
1098 open_libopencl_so();
1100 func = (f_clGetEventInfo) dlsym(so_handle,
"clGetEventInfo");
1102 return func(event, param_name, param_value_size, param_value, param_value_size_ret);
1104 return CL_INVALID_PLATFORM;
1109 clCreateUserEvent(cl_context context,
1110 cl_int * errcode_ret)
1112 f_clCreateUserEvent func;
1115 open_libopencl_so();
1117 func = (f_clCreateUserEvent) dlsym(so_handle,
"clCreateUserEvent");
1119 return func(context, errcode_ret);
1126 clRetainEvent(cl_event event)
1128 f_clRetainEvent func;
1131 open_libopencl_so();
1133 func = (f_clRetainEvent) dlsym(so_handle,
"clRetainEvent");
1137 return CL_INVALID_PLATFORM;
1142 clReleaseEvent(cl_event event)
1144 f_clReleaseEvent func;
1147 open_libopencl_so();
1149 func = (f_clReleaseEvent) dlsym(so_handle,
"clReleaseEvent");
1153 return CL_INVALID_PLATFORM;
1158 clSetUserEventStatus(cl_event event,
1159 cl_int execution_status)
1161 f_clSetUserEventStatus func;
1164 open_libopencl_so();
1166 func = (f_clSetUserEventStatus) dlsym(so_handle,
"clSetUserEventStatus");
1168 return func(event, execution_status);
1170 return CL_INVALID_PLATFORM;
1175 clSetEventCallback( cl_event event,
1176 cl_int command_exec_callback_type,
1177 void (*pfn_notify)(cl_event, cl_int,
void *),
1180 f_clSetEventCallback func;
1183 open_libopencl_so();
1185 func = (f_clSetEventCallback) dlsym(so_handle,
"clSetEventCallback");
1187 return func(event, command_exec_callback_type, pfn_notify, user_data);
1189 return CL_INVALID_PLATFORM;
1194 clGetEventProfilingInfo(cl_event event,
1195 cl_profiling_info param_name,
1196 size_t param_value_size,
1198 size_t * param_value_size_ret)
1200 f_clGetEventProfilingInfo func;
1203 open_libopencl_so();
1205 func = (f_clGetEventProfilingInfo) dlsym(so_handle,
"clGetEventProfilingInfo");
1207 return func(event, param_name, param_value_size, param_value, param_value_size_ret);
1209 return CL_INVALID_PLATFORM;
1214 clFlush(cl_command_queue command_queue)
1219 open_libopencl_so();
1221 func = (f_clFlush) dlsym(so_handle,
"clFlush");
1223 return func(command_queue);
1225 return CL_INVALID_PLATFORM;
1230 clFinish(cl_command_queue command_queue)
1235 open_libopencl_so();
1237 func = (f_clFinish) dlsym(so_handle,
"clFinish");
1239 return func(command_queue);
1241 return CL_INVALID_PLATFORM;
1247 clEnqueueReadBuffer(cl_command_queue command_queue,
1249 cl_bool blocking_read,
1253 cl_uint num_events_in_wait_list,
1254 const cl_event * event_wait_list,
1257 f_clEnqueueReadBuffer func;
1260 open_libopencl_so();
1262 func = (f_clEnqueueReadBuffer) dlsym(so_handle,
"clEnqueueReadBuffer");
1264 return func(command_queue, buffer, blocking_read, offset, size, ptr,
1265 num_events_in_wait_list, event_wait_list, event);
1267 return CL_INVALID_PLATFORM;
1272 clEnqueueReadBufferRect(cl_command_queue command_queue,
1274 cl_bool blocking_read,
1275 const size_t * buffer_offset,
1276 const size_t * host_offset,
1277 const size_t * region,
1278 size_t buffer_row_pitch,
1279 size_t buffer_slice_pitch,
1280 size_t host_row_pitch,
1281 size_t host_slice_pitch,
1283 cl_uint num_events_in_wait_list,
1284 const cl_event * event_wait_list,
1287 f_clEnqueueReadBufferRect func;
1290 open_libopencl_so();
1292 func = (f_clEnqueueReadBufferRect) dlsym(so_handle,
"clEnqueueReadBufferRect");
1294 return func(command_queue, buffer, blocking_read, buffer_offset, host_offset, region,
1295 buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr,
1296 num_events_in_wait_list, event_wait_list, event);
1298 return CL_INVALID_PLATFORM;
1303 clEnqueueWriteBuffer(cl_command_queue command_queue,
1305 cl_bool blocking_write,
1309 cl_uint num_events_in_wait_list,
1310 const cl_event * event_wait_list,
1313 f_clEnqueueWriteBuffer func;
1316 open_libopencl_so();
1318 func = (f_clEnqueueWriteBuffer) dlsym(so_handle,
"clEnqueueWriteBuffer");
1320 return func(command_queue, buffer, blocking_write, offset, size, ptr,
1321 num_events_in_wait_list, event_wait_list, event);
1323 return CL_INVALID_PLATFORM;
1329 clEnqueueWriteBufferRect(cl_command_queue command_queue,
1331 cl_bool blocking_write,
1332 const size_t * buffer_offset,
1333 const size_t * host_offset,
1334 const size_t * region,
1335 size_t buffer_row_pitch,
1336 size_t buffer_slice_pitch,
1337 size_t host_row_pitch,
1338 size_t host_slice_pitch,
1340 cl_uint num_events_in_wait_list,
1341 const cl_event * event_wait_list,
1344 f_clEnqueueWriteBufferRect func;
1347 open_libopencl_so();
1349 func = (f_clEnqueueWriteBufferRect) dlsym(so_handle,
"clEnqueueWriteBufferRect");
1351 return func(command_queue, buffer, blocking_write, buffer_offset, host_offset, region,
1352 buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch,
1353 ptr, num_events_in_wait_list, event_wait_list, event);
1355 return CL_INVALID_PLATFORM;
1361 clEnqueueFillBuffer(cl_command_queue command_queue,
1363 const void * pattern,
1364 size_t pattern_size,
1367 cl_uint num_events_in_wait_list,
1368 const cl_event * event_wait_list,
1371 f_clEnqueueFillBuffer func;
1374 open_libopencl_so();
1376 func = (f_clEnqueueFillBuffer) dlsym(so_handle,
"clEnqueueFillBuffer");
1378 return func(command_queue, buffer, pattern, pattern_size, offset, size,
1379 num_events_in_wait_list, event_wait_list, event);
1381 return CL_INVALID_PLATFORM;
1386 clEnqueueCopyBuffer(cl_command_queue command_queue,
1392 cl_uint num_events_in_wait_list,
1393 const cl_event * event_wait_list,
1396 f_clEnqueueCopyBuffer func;
1399 open_libopencl_so();
1401 func = (f_clEnqueueCopyBuffer) dlsym(so_handle,
"clEnqueueCopyBuffer");
1403 return func(command_queue, src_buffer, dst_buffer, src_offset, dst_offset, size,
1404 num_events_in_wait_list, event_wait_list, event);
1406 return CL_INVALID_PLATFORM;
1413 clEnqueueCopyBufferRect(cl_command_queue command_queue,
1416 const size_t * src_origin,
1417 const size_t * dst_origin,
1418 const size_t * region,
1419 size_t src_row_pitch,
1420 size_t src_slice_pitch,
1421 size_t dst_row_pitch,
1422 size_t dst_slice_pitch,
1423 cl_uint num_events_in_wait_list,
1424 const cl_event * event_wait_list,
1427 f_clEnqueueCopyBufferRect func;
1430 open_libopencl_so();
1432 func = (f_clEnqueueCopyBufferRect) dlsym(so_handle,
"clEnqueueCopyBufferRect");
1434 return func(command_queue, src_buffer, dst_buffer, src_origin, dst_origin, region, src_row_pitch,
1435 src_slice_pitch, dst_row_pitch, dst_slice_pitch, num_events_in_wait_list, event_wait_list, event);
1437 return CL_INVALID_PLATFORM;
1442 clEnqueueReadImage(cl_command_queue command_queue,
1444 cl_bool blocking_read,
1445 const size_t * origin,
1446 const size_t * region,
1450 cl_uint num_events_in_wait_list,
1451 const cl_event * event_wait_list,
1454 f_clEnqueueReadImage func;
1457 open_libopencl_so();
1459 func = (f_clEnqueueReadImage) dlsym(so_handle,
"clEnqueueReadImage");
1461 return func(command_queue, image, blocking_read, origin, region, row_pitch, slice_pitch,
1462 ptr, num_events_in_wait_list, event_wait_list, event);
1464 return CL_INVALID_PLATFORM;
1469 clEnqueueWriteImage(cl_command_queue command_queue,
1471 cl_bool blocking_write,
1472 const size_t * origin,
1473 const size_t * region,
1474 size_t input_row_pitch,
1475 size_t input_slice_pitch,
1477 cl_uint num_events_in_wait_list,
1478 const cl_event * event_wait_list,
1481 f_clEnqueueWriteImage func;
1484 open_libopencl_so();
1486 func = (f_clEnqueueWriteImage) dlsym(so_handle,
"clEnqueueWriteImage");
1488 return func(command_queue, image, blocking_write, origin, region, input_row_pitch, input_slice_pitch, ptr,
1489 num_events_in_wait_list, event_wait_list, event);
1491 return CL_INVALID_PLATFORM;
1497 clEnqueueFillImage(cl_command_queue command_queue,
1499 const void * fill_color,
1500 const size_t * origin,
1501 const size_t * region,
1502 cl_uint num_events_in_wait_list,
1503 const cl_event * event_wait_list,
1506 f_clEnqueueFillImage func;
1509 open_libopencl_so();
1511 func = (f_clEnqueueFillImage) dlsym(so_handle,
"clEnqueueFillImage");
1513 return func(command_queue, image, fill_color, origin, region, num_events_in_wait_list, event_wait_list, event);
1515 return CL_INVALID_PLATFORM;
1520 clEnqueueCopyImage(cl_command_queue command_queue,
1523 const size_t * src_origin,
1524 const size_t * dst_origin,
1525 const size_t * region,
1526 cl_uint num_events_in_wait_list,
1527 const cl_event * event_wait_list,
1530 f_clEnqueueCopyImage func;
1533 open_libopencl_so();
1535 func = (f_clEnqueueCopyImage) dlsym(so_handle,
"clEnqueueCopyImage");
1537 return func(command_queue, src_image, dst_image, src_origin, dst_origin, region,
1538 num_events_in_wait_list, event_wait_list, event);
1540 return CL_INVALID_PLATFORM;
1545 clEnqueueCopyImageToBuffer(cl_command_queue command_queue,
1548 const size_t * src_origin,
1549 const size_t * region,
1551 cl_uint num_events_in_wait_list,
1552 const cl_event * event_wait_list,
1555 f_clEnqueueCopyImageToBuffer func;
1558 open_libopencl_so();
1560 func = (f_clEnqueueCopyImageToBuffer) dlsym(so_handle,
"clEnqueueCopyImageToBuffer");
1562 return func(command_queue, src_image, dst_buffer, src_origin, region, dst_offset,
1563 num_events_in_wait_list, event_wait_list, event);
1565 return CL_INVALID_PLATFORM;
1571 clEnqueueCopyBufferToImage(cl_command_queue command_queue,
1575 const size_t * dst_origin,
1576 const size_t * region,
1577 cl_uint num_events_in_wait_list,
1578 const cl_event * event_wait_list,
1581 f_clEnqueueCopyBufferToImage func;
1584 open_libopencl_so();
1586 func = (f_clEnqueueCopyBufferToImage) dlsym(so_handle,
"clEnqueueCopyBufferToImage");
1588 return func(command_queue, src_buffer, dst_image, src_offset, dst_origin, region,
1589 num_events_in_wait_list, event_wait_list, event);
1591 return CL_INVALID_PLATFORM;
1596 clEnqueueMapBuffer(cl_command_queue command_queue,
1598 cl_bool blocking_map,
1599 cl_map_flags map_flags,
1602 cl_uint num_events_in_wait_list,
1603 const cl_event * event_wait_list,
1605 cl_int * errcode_ret)
1607 f_clEnqueueMapBuffer func;
1610 open_libopencl_so();
1612 func = (f_clEnqueueMapBuffer) dlsym(so_handle,
"clEnqueueMapBuffer");
1614 return func(command_queue, buffer, blocking_map, map_flags, offset, size,
1615 num_events_in_wait_list, event_wait_list, event, errcode_ret);
1622 clEnqueueMapImage(cl_command_queue command_queue,
1624 cl_bool blocking_map,
1625 cl_map_flags map_flags,
1626 const size_t * origin,
1627 const size_t * region,
1628 size_t * image_row_pitch,
1629 size_t * image_slice_pitch,
1630 cl_uint num_events_in_wait_list,
1631 const cl_event * event_wait_list,
1633 cl_int * errcode_ret)
1635 f_clEnqueueMapImage func;
1638 open_libopencl_so();
1640 func = (f_clEnqueueMapImage) dlsym(so_handle,
"clEnqueueMapImage");
1642 return func(command_queue, image, blocking_map, map_flags, origin, region, image_row_pitch,
1643 image_slice_pitch, num_events_in_wait_list, event_wait_list, event, errcode_ret);
1650 clEnqueueUnmapMemObject(cl_command_queue command_queue,
1653 cl_uint num_events_in_wait_list,
1654 const cl_event * event_wait_list,
1657 f_clEnqueueUnmapMemObject func;
1660 open_libopencl_so();
1662 func = (f_clEnqueueUnmapMemObject) dlsym(so_handle,
"clEnqueueUnmapMemObject");
1664 return func(command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
1666 return CL_INVALID_PLATFORM;
1671 clEnqueueMigrateMemObjects(cl_command_queue command_queue,
1672 cl_uint num_mem_objects,
1673 const cl_mem * mem_objects,
1674 cl_mem_migration_flags flags,
1675 cl_uint num_events_in_wait_list,
1676 const cl_event * event_wait_list,
1679 f_clEnqueueMigrateMemObjects func;
1682 open_libopencl_so();
1684 func = (f_clEnqueueMigrateMemObjects) dlsym(so_handle,
"clEnqueueMigrateMemObjects");
1686 return func(command_queue, num_mem_objects, mem_objects, flags, num_events_in_wait_list, event_wait_list, event);
1688 return CL_INVALID_PLATFORM;
1693 clEnqueueNDRangeKernel(cl_command_queue command_queue,
1696 const size_t * global_work_offset,
1697 const size_t * global_work_size,
1698 const size_t * local_work_size,
1699 cl_uint num_events_in_wait_list,
1700 const cl_event * event_wait_list,
1703 f_clEnqueueNDRangeKernel func;
1706 open_libopencl_so();
1708 func = (f_clEnqueueNDRangeKernel) dlsym(so_handle,
"clEnqueueNDRangeKernel");
1710 return func(command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size,
1711 num_events_in_wait_list, event_wait_list, event);
1713 return CL_INVALID_PLATFORM;
1718 clEnqueueTask(cl_command_queue command_queue,
1720 cl_uint num_events_in_wait_list,
1721 const cl_event * event_wait_list,
1724 f_clEnqueueTask func;
1727 open_libopencl_so();
1729 func = (f_clEnqueueTask) dlsym(so_handle,
"clEnqueueTask");
1731 return func(command_queue, kernel, num_events_in_wait_list, event_wait_list, event);
1733 return CL_INVALID_PLATFORM;
1738 clEnqueueNativeKernel(cl_command_queue command_queue,
1739 void (*user_func)(
void *),
1742 cl_uint num_mem_objects,
1743 const cl_mem * mem_list,
1744 const void ** args_mem_loc,
1745 cl_uint num_events_in_wait_list,
1746 const cl_event * event_wait_list,
1749 f_clEnqueueNativeKernel func;
1752 open_libopencl_so();
1754 func = (f_clEnqueueNativeKernel) dlsym(so_handle,
"clEnqueueNativeKernel");
1756 return func(command_queue, user_func, args, cb_args, num_mem_objects, mem_list,
1757 args_mem_loc, num_events_in_wait_list, event_wait_list, event);
1759 return CL_INVALID_PLATFORM;
1764 clEnqueueMarkerWithWaitList(cl_command_queue command_queue,
1765 cl_uint num_events_in_wait_list,
1766 const cl_event * event_wait_list,
1769 f_clEnqueueMarkerWithWaitList func;
1772 open_libopencl_so();
1774 func = (f_clEnqueueMarkerWithWaitList) dlsym(so_handle,
"clEnqueueMarkerWithWaitList");
1776 return func(command_queue, num_events_in_wait_list, event_wait_list, event);
1778 return CL_INVALID_PLATFORM;
1783 clEnqueueBarrierWithWaitList(cl_command_queue command_queue,
1784 cl_uint num_events_in_wait_list,
1785 const cl_event * event_wait_list,
1788 f_clEnqueueBarrierWithWaitList func;
1791 open_libopencl_so();
1793 func = (f_clEnqueueBarrierWithWaitList) dlsym(so_handle,
"clEnqueueBarrierWithWaitList");
1795 return func(command_queue, num_events_in_wait_list, event_wait_list, event);
1797 return CL_INVALID_PLATFORM;
1802 clGetExtensionFunctionAddressForPlatform(cl_platform_id platform,
1803 const char * func_name)
1805 f_clGetExtensionFunctionAddressForPlatform func;
1808 open_libopencl_so();
1810 func = (f_clGetExtensionFunctionAddressForPlatform) dlsym(so_handle,
"clGetExtensionFunctionAddressForPlatform");
1812 return func(platform, func_name);
1820 clCreateImage2D(cl_context context,
1824 size_t image_height,
1825 size_t image_row_pitch,
1827 cl_int * errcode_ret)
1829 f_clCreateImage2D func;
1832 open_libopencl_so();
1834 func = (f_clCreateImage2D) dlsym(so_handle,
"clCreateImage2D");
1836 return func(context, flags, image_format, image_width, image_height,
1837 image_row_pitch, host_ptr, errcode_ret);
1844 clCreateImage3D(cl_context context,
1848 size_t image_height,
1850 size_t image_row_pitch,
1851 size_t image_slice_pitch,
1853 cl_int * errcode_ret)
1855 f_clCreateImage3D func;
1858 open_libopencl_so();
1860 func = (f_clCreateImage3D) dlsym(so_handle,
"clCreateImage3D");
1862 return func(context, flags, image_format, image_width, image_height, image_depth,
1863 image_row_pitch, image_slice_pitch, host_ptr, errcode_ret);
1870 clEnqueueMarker(cl_command_queue command_queue,
1873 f_clEnqueueMarker func;
1876 open_libopencl_so();
1878 func = (f_clEnqueueMarker) dlsym(so_handle,
"clEnqueueMarker");
1880 return func(command_queue, event);
1882 return CL_INVALID_PLATFORM;
1887 clEnqueueWaitForEvents(cl_command_queue command_queue,
1889 const cl_event * event_list)
1891 f_clEnqueueWaitForEvents func;
1894 open_libopencl_so();
1896 func = (f_clEnqueueWaitForEvents) dlsym(so_handle,
"clEnqueueWaitForEvents");
1898 return func(command_queue, num_events, event_list);
1900 return CL_INVALID_PLATFORM;
1905 clEnqueueBarrier(cl_command_queue command_queue)
1907 f_clEnqueueBarrier func;
1910 open_libopencl_so();
1912 func = (f_clEnqueueBarrier) dlsym(so_handle,
"clEnqueueBarrier");
1914 return func(command_queue);
1916 return CL_INVALID_PLATFORM;
1921 clUnloadCompiler(
void)
1923 f_clUnloadCompiler func;
1926 open_libopencl_so();
1928 func = (f_clUnloadCompiler) dlsym(so_handle,
"clUnloadCompiler");
1932 return CL_INVALID_PLATFORM;
1937 clGetExtensionFunctionAddress(
const char * func_name)
1939 f_clGetExtensionFunctionAddress func;
1942 open_libopencl_so();
1944 func = (f_clGetExtensionFunctionAddress) dlsym(so_handle,
"clGetExtensionFunctionAddress");
1946 return func(func_name);
1954 clCreateFromGLBuffer(cl_context context,
1959 f_clCreateFromGLBuffer func;
1962 open_libopencl_so();
1964 func = (f_clCreateFromGLBuffer) dlsym(so_handle,
"clCreateFromGLBuffer");
1966 return func(context, flags, bufobj, errcode_ret);
1973 clCreateFromGLTexture(cl_context context,
1978 cl_int * errcode_ret)
1980 f_clCreateFromGLTexture func;
1983 open_libopencl_so();
1985 func = (f_clCreateFromGLTexture) dlsym(so_handle,
"clCreateFromGLTexture");
1987 return func(context, flags, target, miplevel, texture, errcode_ret);
1994 clCreateFromGLRenderbuffer(cl_context context,
1996 cl_GLuint renderbuffer,
1997 cl_int * errcode_ret)
1999 f_clCreateFromGLRenderbuffer func;
2002 open_libopencl_so();
2004 func = (f_clCreateFromGLRenderbuffer) dlsym(so_handle,
"clCreateFromGLRenderbuffer");
2006 return func(context, flags, renderbuffer, errcode_ret);
2013 clGetGLObjectInfo(cl_mem memobj,
2014 cl_gl_object_type * gl_object_type,
2015 cl_GLuint * gl_object_name)
2017 f_clGetGLObjectInfo func;
2020 open_libopencl_so();
2022 func = (f_clGetGLObjectInfo) dlsym(so_handle,
"clGetGLObjectInfo");
2024 return func(memobj, gl_object_type, gl_object_name);
2026 return CL_INVALID_PLATFORM;
2031 clGetGLTextureInfo(cl_mem memobj,
2032 cl_gl_texture_info param_name,
2033 size_t param_value_size,
2035 size_t * param_value_size_ret)
2037 f_clGetGLTextureInfo func;
2040 open_libopencl_so();
2042 func = (f_clGetGLTextureInfo) dlsym(so_handle,
"clGetGLTextureInfo");
2044 return func(memobj, param_name, param_value_size, param_value, param_value_size_ret);
2046 return CL_INVALID_PLATFORM;
2051 clEnqueueAcquireGLObjects(cl_command_queue command_queue,
2052 cl_uint num_objects,
2053 const cl_mem * mem_objects,
2054 cl_uint num_events_in_wait_list,
2055 const cl_event * event_wait_list,
2058 f_clEnqueueAcquireGLObjects func;
2061 open_libopencl_so();
2063 func = (f_clEnqueueAcquireGLObjects) dlsym(so_handle,
"clEnqueueAcquireGLObjects");
2065 return func(command_queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, event);
2067 return CL_INVALID_PLATFORM;
2072 clEnqueueReleaseGLObjects(cl_command_queue command_queue,
2073 cl_uint num_objects,
2074 const cl_mem * mem_objects,
2075 cl_uint num_events_in_wait_list,
2076 const cl_event * event_wait_list,
2079 f_clEnqueueReleaseGLObjects func;
2082 open_libopencl_so();
2084 func = (f_clEnqueueReleaseGLObjects) dlsym(so_handle,
"clEnqueueReleaseGLObjects");
2086 return func(command_queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, event);
2088 return CL_INVALID_PLATFORM;
2094 clCreateFromGLTexture2D(cl_context context,
2099 cl_int * errcode_ret)
2101 f_clCreateFromGLTexture2D func;
2104 open_libopencl_so();
2106 func = (f_clCreateFromGLTexture2D) dlsym(so_handle,
"clCreateFromGLTexture2D");
2108 return func(context, flags, target, miplevel, texture, errcode_ret);
2115 clCreateFromGLTexture3D(cl_context context,
2120 cl_int * errcode_ret)
2122 f_clCreateFromGLTexture3D func;
2125 open_libopencl_so();
2127 func = (f_clCreateFromGLTexture3D) dlsym(so_handle,
"clCreateFromGLTexture3D");
2129 return func(context, flags, target, miplevel, texture, errcode_ret);
2136 clGetGLContextInfoKHR(
const cl_context_properties * properties,
2137 cl_gl_context_info param_name,
2138 size_t param_value_size,
2140 size_t * param_value_size_ret)
2142 f_clGetGLContextInfoKHR func;
2145 open_libopencl_so();
2147 func = (f_clGetGLContextInfoKHR) dlsym(so_handle,
"clGetGLContextInfoKHR");
2149 return func(properties, param_name, param_value_size, param_value, param_value_size_ret);
2151 return CL_INVALID_PLATFORM;