Caffe2 - C++ API
A deep learning, cross platform ML framework
libopencl.h
1 #ifndef LIBOPENCL_STUB_H
2 #define LIBOPENCL_STUB_H
3 
4 #include <stdlib.h>
5 #include <sys/stat.h>
6 #include <dlfcn.h>
7 #include <CL/cl.h>
8 #include <CL/cl_gl.h>
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 typedef void (*f_pfn_notify)(const char *, const void *, size_t, void *);
15 
16 typedef cl_int (*f_clGetPlatformIDs) (cl_uint, cl_platform_id *, cl_uint *);
17 
18 typedef cl_int (*f_clGetPlatformInfo) (cl_platform_id, cl_platform_info, size_t, void *, size_t *);
19 
20 typedef cl_int (*f_clGetDeviceIDs) (cl_platform_id, cl_device_type, cl_uint, cl_device_id *, cl_uint *);
21 
22 typedef cl_int (*f_clGetDeviceInfo) (cl_device_id, cl_device_info, size_t, void *, size_t *);
23 
24 typedef cl_int (*f_clCreateSubDevices) (cl_device_id, const cl_device_partition_property *,
25  cl_uint, cl_device_id *, cl_uint *);
26 
27 typedef cl_int (*f_clRetainDevice) (cl_device_id);
28 
29 typedef cl_int (*f_clReleaseDevice) (cl_device_id);
30 
31 typedef cl_context (*f_clCreateContext) (const cl_context_properties *, cl_uint, const cl_device_id *,
32  f_pfn_notify, void *, cl_int *);
33 
34 typedef cl_context (*f_clCreateContextFromType) (const cl_context_properties *, cl_device_type,
35  f_pfn_notify, void *, cl_int *);
36 
37 typedef cl_int (*f_clRetainContext) (cl_context);
38 
39 typedef cl_int (*f_clReleaseContext) (cl_context);
40 
41 typedef cl_int (*f_clGetContextInfo) (cl_context, cl_context_info, size_t, void *, size_t *);
42 
43 typedef cl_command_queue (*f_clCreateCommandQueue) (cl_context, cl_device_id, cl_command_queue_properties, cl_int *);
44 
45 typedef cl_int (*f_clRetainCommandQueue) (cl_command_queue);
46 
47 typedef cl_int (*f_clReleaseCommandQueue) (cl_command_queue);
48 
49 typedef cl_int (*f_clGetCommandQueueInfo) (cl_command_queue, cl_command_queue_info, size_t, void *, size_t *);
50 
51 typedef cl_mem (*f_clCreateBuffer) (cl_context, cl_mem_flags, size_t, void *, cl_int *);
52 
53 typedef cl_mem (*f_clCreateSubBuffer) (cl_mem, cl_mem_flags, cl_buffer_create_type, const void *, cl_int *);
54 
55 typedef cl_mem (*f_clCreateImage) (cl_context, cl_mem_flags, const cl_image_format *, const cl_image_desc *, void *, cl_int *);
56 
57 typedef cl_int (*f_clRetainMemObject) (cl_mem);
58 
59 typedef cl_int (*f_clReleaseMemObject) (cl_mem);
60 
61 typedef cl_int (*f_clGetMemObjectInfo) (cl_mem, cl_mem_info, size_t, void *, size_t *);
62 
63 typedef cl_int (*f_clGetImageInfo) (cl_mem, cl_image_info, size_t, void *, size_t *);
64 
65 typedef cl_int (*f_clSetMemObjectDestructorCallback) (cl_mem, void (*pfn_notify)( cl_mem memobj, void* user_data), void *);
66 
67 typedef cl_int (*f_clGetSupportedImageFormats) (cl_context, cl_mem_flags, cl_mem_object_type, cl_uint, cl_image_format *, cl_uint *);
68 
69 typedef cl_sampler (*f_clCreateSampler) (cl_context, cl_bool, cl_addressing_mode, cl_filter_mode, cl_int *);
70 
71 typedef cl_int (*f_clRetainSampler) (cl_sampler);
72 
73 typedef cl_int (*f_clReleaseSampler) (cl_sampler);
74 
75 typedef cl_int (*f_clGetSamplerInfo) (cl_sampler, cl_sampler_info, size_t, void *, size_t *);
76 
77 typedef cl_program (*f_clCreateProgramWithSource) (cl_context, cl_uint, const char **, const size_t *, cl_int *);
78 
79 typedef cl_program (*f_clCreateProgramWithBinary) (cl_context, cl_uint, const cl_device_id *,
80  const size_t *, const unsigned char **, cl_int *, cl_int *);
81 
82 typedef cl_program (*f_clCreateProgramWithBuiltInKernels) (cl_context, cl_uint, const cl_device_id *, const char *, cl_int *);
83 
84 typedef cl_int (*f_clRetainProgram) (cl_program);
85 
86 typedef cl_int (*f_clReleaseProgram) (cl_program);
87 
88 typedef cl_int (*f_clBuildProgram) (cl_program, cl_uint, const cl_device_id *, const char *,
89  void (*pfn_notify)(cl_program program, void * user_data), void *);
90 
91 typedef cl_int (*f_clCompileProgram) (cl_program, cl_uint, const cl_device_id *, const char *, cl_uint, const cl_program *,
92  const char **, void (*pfn_notify)(cl_program program, void * user_data), void *);
93 
94 typedef cl_program (*f_clLinkProgram) (cl_context, cl_uint, const cl_device_id *, const char *, cl_uint, const cl_program *,
95  void (*pfn_notify)(cl_program program, void * user_data), void *, cl_int *);
96 
97 typedef cl_int (*f_clUnloadPlatformCompiler)(cl_platform_id);
98 
99 typedef cl_int (*f_clGetProgramInfo) (cl_program, cl_program_info, size_t, void *, size_t *);
100 
101 typedef cl_int (*f_clGetProgramBuildInfo) (cl_program, cl_device_id, cl_program_build_info, size_t, void *, size_t *);
102 
103 typedef cl_kernel (*f_clCreateKernel) (cl_program, const char *, cl_int *);
104 
105 typedef cl_int (*f_clCreateKernelsInProgram) (cl_program, cl_uint, cl_kernel *, cl_uint *);
106 
107 typedef cl_int (*f_clRetainKernel) (cl_kernel);
108 
109 typedef cl_int (*f_clReleaseKernel) (cl_kernel);
110 
111 typedef cl_int (*f_clSetKernelArg) (cl_kernel, cl_uint, size_t,const void *);
112 
113 typedef cl_int (*f_clGetKernelInfo) (cl_kernel, cl_kernel_info, size_t, void *, size_t *);
114 
115 typedef cl_int (*f_clGetKernelArgInfo) (cl_kernel, cl_uint, cl_kernel_arg_info, size_t, void *, size_t *);
116 
117 typedef cl_int (*f_clGetKernelWorkGroupInfo) (cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, void *, size_t *);
118 
119 typedef cl_int (*f_clWaitForEvents) (cl_uint, const cl_event *);
120 
121 typedef cl_int (*f_clGetEventInfo) (cl_event, cl_event_info, size_t, void *, size_t *);
122 
123 typedef cl_event (*f_clCreateUserEvent) (cl_context, cl_int *);
124 
125 typedef cl_int (*f_clRetainEvent) (cl_event);
126 
127 typedef cl_int (*f_clReleaseEvent) (cl_event);
128 
129 typedef cl_int (*f_clSetUserEventStatus) (cl_event, cl_int);
130 
131 typedef cl_int (*f_clSetEventCallback) (cl_event, cl_int, void (*pfn_notify)(cl_event, cl_int, void *), void *);
132 
133 typedef cl_int (*f_clGetEventProfilingInfo) (cl_event, cl_profiling_info, size_t, void *, size_t *);
134 
135 typedef cl_int (*f_clFlush) (cl_command_queue);
136 
137 typedef cl_int (*f_clFinish) (cl_command_queue);
138 
139 typedef cl_int (*f_clEnqueueReadBuffer) (cl_command_queue, cl_mem, cl_bool, size_t, size_t, void *, cl_uint, const cl_event *, cl_event *);
140 
141 typedef cl_int (*f_clEnqueueReadBufferRect) (cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *, const size_t *,
142  size_t, size_t, size_t, size_t, void *, cl_uint, const cl_event *, cl_event *);
143 
144 typedef cl_int (*f_clEnqueueWriteBuffer) (cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
145 
146 typedef cl_int (*f_clEnqueueWriteBufferRect) (cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *, const size_t *,
147  size_t, size_t, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
148 
149 typedef cl_int (*f_clEnqueueFillBuffer) (cl_command_queue, cl_mem, const void *, size_t, size_t, size_t, cl_uint, const cl_event *, cl_event *);
150 
151 typedef cl_int (*f_clEnqueueCopyBuffer) (cl_command_queue, cl_mem, cl_mem, size_t, size_t, size_t, cl_uint, const cl_event *, cl_event *);
152 
153 typedef cl_int (*f_clEnqueueCopyBufferRect) (cl_command_queue, cl_mem, cl_mem, const size_t *, const size_t *, const size_t *,
154  size_t, size_t, size_t, size_t, cl_uint, const cl_event *, cl_event *);
155 
156 typedef cl_int (*f_clEnqueueReadImage) (cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *,
157  size_t, size_t, void *, cl_uint, const cl_event *, cl_event *);
158 
159 typedef cl_int (*f_clEnqueueWriteImage) (cl_command_queue, cl_mem, cl_bool, const size_t *, const size_t *,
160  size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
161 
162 typedef cl_int (*f_clEnqueueFillImage) (cl_command_queue, cl_mem, const void *, const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *);
163 
164 typedef cl_int (*f_clEnqueueCopyImage) (cl_command_queue, cl_mem, cl_mem, const size_t *, const size_t *, const size_t *,
165  cl_uint, const cl_event *, cl_event *);
166 
167 typedef cl_int (*f_clEnqueueCopyImageToBuffer) (cl_command_queue, cl_mem, cl_mem, const size_t *, const size_t *, size_t, cl_uint, const cl_event *, cl_event *);
168 
169 typedef cl_int (*f_clEnqueueCopyBufferToImage) (cl_command_queue, cl_mem, cl_mem, size_t, const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *);
170 
171 typedef void * (*f_clEnqueueMapBuffer) (cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t,
172  size_t, cl_uint, const cl_event *, cl_event *, cl_int *);
173 
174 typedef void * (*f_clEnqueueMapImage) (cl_command_queue, cl_mem, cl_bool, cl_map_flags, const size_t *, const size_t *,
175  size_t *, size_t *, cl_uint, const cl_event *, cl_event *, cl_int *);
176 
177 typedef cl_int (*f_clEnqueueUnmapMemObject) (cl_command_queue, cl_mem, void *, cl_uint, const cl_event *, cl_event *);
178 
179 typedef cl_int (*f_clEnqueueMigrateMemObjects)(cl_command_queue, cl_uint, const cl_mem *, cl_mem_migration_flags,
180  cl_uint, const cl_event *, cl_event *);
181 
182 typedef cl_int (*f_clEnqueueNDRangeKernel)(cl_command_queue, cl_kernel, cl_uint, const size_t *, const size_t *,
183  const size_t *, cl_uint, const cl_event *, cl_event *);
184 
185 typedef cl_int (*f_clEnqueueTask)(cl_command_queue, cl_kernel, cl_uint, const cl_event *, cl_event *);
186 
187 typedef cl_int (*f_clEnqueueNativeKernel)(cl_command_queue, void (*user_func)(void *), void *, size_t,
188  cl_uint, const cl_mem *, const void **, cl_uint, const cl_event *, cl_event *);
189 
190 typedef cl_int (*f_clEnqueueMarkerWithWaitList)(cl_command_queue, cl_uint, const cl_event *, cl_event *);
191 
192 typedef cl_int (*f_clEnqueueBarrierWithWaitList)(cl_command_queue, cl_uint, const cl_event *, cl_event *);
193 
194 typedef void * (*f_clGetExtensionFunctionAddressForPlatform)(cl_platform_id, const char *);
195 
196 typedef cl_mem (*f_clCreateImage2D)(cl_context, cl_mem_flags,const cl_image_format *, size_t, size_t,
197  size_t, void *, cl_int *);
198 
199 typedef cl_mem (*f_clCreateImage3D)(cl_context, cl_mem_flags, const cl_image_format *, size_t,
200  size_t, size_t, size_t, size_t, void *, cl_int *);
201 
202 typedef cl_int (*f_clEnqueueMarker)(cl_command_queue, cl_event *);
203 
204 typedef cl_int(*f_clEnqueueWaitForEvents)(cl_command_queue, cl_uint, const cl_event *);
205 
206 typedef cl_int (*f_clEnqueueBarrier)(cl_command_queue);
207 
208 typedef cl_int (*f_clUnloadCompiler)(void);
209 
210 typedef void * (*f_clGetExtensionFunctionAddress)(const char *);
211 
212 typedef cl_mem (*f_clCreateFromGLBuffer) (cl_context, cl_mem_flags, cl_GLuint, int *);
213 
214 typedef cl_mem (*f_clCreateFromGLTexture) (cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int *);
215 
216 typedef cl_mem (*f_clCreateFromGLRenderbuffer) (cl_context, cl_mem_flags, cl_GLuint, cl_int *);
217 
218 typedef cl_int (*f_clGetGLObjectInfo) (cl_mem memobj, cl_gl_object_type *, cl_GLuint *);
219 
220 typedef cl_int (*f_clGetGLTextureInfo) (cl_mem, cl_gl_texture_info, size_t, void *, size_t *);
221 
222 typedef cl_int (*f_clEnqueueAcquireGLObjects) (cl_command_queue, cl_uint, const cl_mem *, cl_uint,
223  const cl_event *, cl_event *);
224 
225 typedef cl_int (*f_clEnqueueReleaseGLObjects) (cl_command_queue, cl_uint, const cl_mem *, cl_uint,
226  const cl_event *, cl_event *);
227 
228 typedef cl_mem (*f_clCreateFromGLTexture2D) (cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int *);
229 
230 typedef cl_mem (*f_clCreateFromGLTexture3D) (cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int *);
231 
232 //typedef cl_uint cl_gl_context_info;
233 typedef cl_int (*f_clGetGLContextInfoKHR) (const cl_context_properties *, cl_gl_context_info, size_t,
234  void *, size_t *);
235 
236 // Additional api to reset currently opened opencl shared-object
237 // Subsequent calls will use newly set environment variables
238 void stubOpenclReset();
239 
240 // Helper function to get the path to libOpenCL.so
241 int open_libopencl_so();
242 cl_int get_libopencl_path(char** cl_path);
243 
244 #ifdef __cplusplus
245 }
246 #endif
247 
248 #endif // LIBOPENCL_STUB_H