1 /* Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_LITE_DELEGATES_GPU_CL_OPENCL_WRAPPER_H_ 17 #define TENSORFLOW_LITE_DELEGATES_GPU_CL_OPENCL_WRAPPER_H_ 18 19 #include <CL/cl.h> 20 #include <CL/cl_egl.h> 21 #include <CL/cl_ext.h> 22 #include <CL/cl_gl.h> 23 #include <CL/cl_platform.h> 24 #include "tensorflow/lite/delegates/gpu/common/status.h" 25 26 namespace tflite { 27 namespace gpu { 28 namespace cl { 29 30 absl::Status LoadOpenCL(); 31 32 typedef cl_int(CL_API_CALL *PFN_clGetPlatformIDs)( 33 cl_uint /* num_entries */, cl_platform_id * /* platforms */, 34 cl_uint * /* num_platforms */) CL_API_SUFFIX__VERSION_1_0; 35 typedef cl_int(CL_API_CALL *PFN_clGetPlatformInfo)( 36 cl_platform_id /* platform */, cl_platform_info /* param_name */, 37 size_t /* param_value_size */, void * /* param_value */, 38 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 39 typedef cl_int(CL_API_CALL *PFN_clGetDeviceIDs)( 40 cl_platform_id /* platform */, cl_device_type /* device_type */, 41 cl_uint /* num_entries */, cl_device_id * /* devices */, 42 cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0; 43 typedef cl_int(CL_API_CALL *PFN_clGetDeviceInfo)( 44 cl_device_id /* device */, cl_device_info /* param_name */, 45 size_t /* param_value_size */, void * /* param_value */, 46 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 47 typedef cl_int(CL_API_CALL *PFN_clCreateSubDevices)( 48 cl_device_id /* in_device */, 49 const cl_device_partition_property * /* properties */, 50 cl_uint /* num_devices */, cl_device_id * /* out_devices */, 51 cl_uint * /* num_devices_ret */) CL_API_SUFFIX__VERSION_1_2; 52 typedef cl_int(CL_API_CALL *PFN_clRetainDevice)(cl_device_id /* device */) 53 CL_API_SUFFIX__VERSION_1_2; 54 typedef cl_int(CL_API_CALL *PFN_clReleaseDevice)(cl_device_id /* device */) 55 CL_API_SUFFIX__VERSION_1_2; 56 typedef cl_context(CL_API_CALL *PFN_clCreateContext)( 57 const cl_context_properties * /* properties */, cl_uint /* num_devices */, 58 const cl_device_id * /* devices */, 59 void(CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, 60 void *), 61 void * /* user_data */, 62 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; 63 typedef cl_context(CL_API_CALL *PFN_clCreateContextFromType)( 64 const cl_context_properties * /* properties */, 65 cl_device_type /* device_type */, 66 void(CL_CALLBACK * /* pfn_notify*/)(const char *, const void *, size_t, 67 void *), 68 void * /* user_data */, 69 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; 70 typedef cl_int(CL_API_CALL *PFN_clRetainContext)(cl_context /* context */) 71 CL_API_SUFFIX__VERSION_1_0; 72 typedef cl_int(CL_API_CALL *PFN_clReleaseContext)(cl_context /* context */) 73 CL_API_SUFFIX__VERSION_1_0; 74 typedef cl_int(CL_API_CALL *PFN_clGetContextInfo)( 75 cl_context /* context */, cl_context_info /* param_name */, 76 size_t /* param_value_size */, void * /* param_value */, 77 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 78 typedef cl_command_queue(CL_API_CALL *PFN_clCreateCommandQueueWithProperties)( 79 cl_context /* context */, cl_device_id /* device */, 80 const cl_queue_properties * /* properties */, 81 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; 82 typedef cl_int(CL_API_CALL *PFN_clRetainCommandQueue)( 83 cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; 84 typedef cl_int(CL_API_CALL *PFN_clReleaseCommandQueue)( 85 cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; 86 typedef cl_int(CL_API_CALL *PFN_clGetCommandQueueInfo)( 87 cl_command_queue /* command_queue */, 88 cl_command_queue_info /* param_name */, size_t /* param_value_size */, 89 void * /* param_value */, 90 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 91 typedef cl_mem(CL_API_CALL *PFN_clCreateBuffer)( 92 cl_context /* context */, cl_mem_flags /* flags */, size_t /* size */, 93 void * /* host_ptr */, 94 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; 95 typedef cl_mem(CL_API_CALL *PFN_clCreateSubBuffer)( 96 cl_mem /* buffer */, cl_mem_flags /* flags */, 97 cl_buffer_create_type /* buffer_create_type */, 98 const void * /* buffer_create_info */, 99 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; 100 typedef cl_mem(CL_API_CALL *PFN_clCreateImage)( 101 cl_context /* context */, cl_mem_flags /* flags */, 102 const cl_image_format * /* image_format */, 103 const cl_image_desc * /* image_desc */, void * /* host_ptr */, 104 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2; 105 typedef cl_mem(CL_API_CALL *PFN_clCreatePipe)( 106 cl_context /* context */, cl_mem_flags /* flags */, 107 cl_uint /* pipe_packet_size */, cl_uint /* pipe_max_packets */, 108 const cl_pipe_properties * /* properties */, 109 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; 110 typedef cl_int(CL_API_CALL *PFN_clRetainMemObject)(cl_mem /* memobj */) 111 CL_API_SUFFIX__VERSION_1_0; 112 typedef cl_int(CL_API_CALL *PFN_clReleaseMemObject)(cl_mem /* memobj */) 113 CL_API_SUFFIX__VERSION_1_0; 114 typedef cl_int(CL_API_CALL *PFN_clGetSupportedImageFormats)( 115 cl_context /* context */, cl_mem_flags /* flags */, 116 cl_mem_object_type /* image_type */, cl_uint /* num_entries */, 117 cl_image_format * /* image_formats */, 118 cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0; 119 typedef cl_int(CL_API_CALL *PFN_clGetMemObjectInfo)( 120 cl_mem /* memobj */, cl_mem_info /* param_name */, 121 size_t /* param_value_size */, void * /* param_value */, 122 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 123 typedef cl_int(CL_API_CALL *PFN_clGetImageInfo)( 124 cl_mem /* image */, cl_image_info /* param_name */, 125 size_t /* param_value_size */, void * /* param_value */, 126 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 127 typedef cl_int(CL_API_CALL *PFN_clGetPipeInfo)( 128 cl_mem /* pipe */, cl_pipe_info /* param_name */, 129 size_t /* param_value_size */, void * /* param_value */, 130 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_2_0; 131 typedef cl_int(CL_API_CALL *PFN_clSetMemObjectDestructorCallback)( 132 cl_mem /* memobj */, 133 void(CL_CALLBACK * /*pfn_notify*/)(cl_mem /* memobj */, 134 void * /*user_data*/), 135 void * /*user_data */) CL_API_SUFFIX__VERSION_1_1; 136 typedef void *(CL_API_CALL *PFN_clSVMAlloc)( 137 cl_context /* context */, cl_svm_mem_flags /* flags */, size_t /* size */, 138 cl_uint /* alignment */)CL_API_SUFFIX__VERSION_2_0; 139 typedef void(CL_API_CALL *PFN_clSVMFree)(cl_context /* context */, 140 void * /* svm_pointer */) 141 CL_API_SUFFIX__VERSION_2_0; 142 typedef cl_sampler(CL_API_CALL *PFN_clCreateSamplerWithProperties)( 143 cl_context /* context */, 144 const cl_sampler_properties * /* normalized_coords */, 145 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; 146 typedef cl_int(CL_API_CALL *PFN_clRetainSampler)(cl_sampler /* sampler */) 147 CL_API_SUFFIX__VERSION_1_0; 148 typedef cl_int(CL_API_CALL *PFN_clReleaseSampler)(cl_sampler /* sampler */) 149 CL_API_SUFFIX__VERSION_1_0; 150 typedef cl_int(CL_API_CALL *PFN_clGetSamplerInfo)( 151 cl_sampler /* sampler */, cl_sampler_info /* param_name */, 152 size_t /* param_value_size */, void * /* param_value */, 153 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 154 typedef cl_program(CL_API_CALL *PFN_clCreateProgramWithSource)( 155 cl_context /* context */, cl_uint /* count */, const char ** /* strings */, 156 const size_t * /* lengths */, 157 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; 158 typedef cl_program(CL_API_CALL *PFN_clCreateProgramWithBinary)( 159 cl_context /* context */, cl_uint /* num_devices */, 160 const cl_device_id * /* device_list */, const size_t * /* lengths */, 161 const unsigned char ** /* binaries */, cl_int * /* binary_status */, 162 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; 163 typedef cl_program(CL_API_CALL *PFN_clCreateProgramWithBuiltInKernels)( 164 cl_context /* context */, cl_uint /* num_devices */, 165 const cl_device_id * /* device_list */, const char * /* kernel_names */, 166 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2; 167 typedef cl_int(CL_API_CALL *PFN_clRetainProgram)(cl_program /* program */) 168 CL_API_SUFFIX__VERSION_1_0; 169 typedef cl_int(CL_API_CALL *PFN_clReleaseProgram)(cl_program /* program */) 170 CL_API_SUFFIX__VERSION_1_0; 171 typedef cl_int(CL_API_CALL *PFN_clBuildProgram)( 172 cl_program /* program */, cl_uint /* num_devices */, 173 const cl_device_id * /* device_list */, const char * /* options */, 174 void(CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, 175 void * /* user_data */), 176 void * /* user_data */) CL_API_SUFFIX__VERSION_1_0; 177 typedef cl_int(CL_API_CALL *PFN_clCompileProgram)( 178 cl_program /* program */, cl_uint /* num_devices */, 179 const cl_device_id * /* device_list */, const char * /* options */, 180 cl_uint /* num_input_headers */, const cl_program * /* input_headers */, 181 const char ** /* header_include_names */, 182 void(CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, 183 void * /* user_data */), 184 void * /* user_data */) CL_API_SUFFIX__VERSION_1_2; 185 typedef cl_program(CL_API_CALL *PFN_clLinkProgram)( 186 cl_context /* context */, cl_uint /* num_devices */, 187 const cl_device_id * /* device_list */, const char * /* options */, 188 cl_uint /* num_input_programs */, const cl_program * /* input_programs */, 189 void(CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, 190 void * /* user_data */), 191 void * /* user_data */, 192 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2; 193 typedef cl_int(CL_API_CALL *PFN_clUnloadPlatformCompiler)( 194 cl_platform_id /* platform */) CL_API_SUFFIX__VERSION_1_2; 195 typedef cl_int(CL_API_CALL *PFN_clGetProgramInfo)( 196 cl_program /* program */, cl_program_info /* param_name */, 197 size_t /* param_value_size */, void * /* param_value */, 198 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 199 typedef cl_int(CL_API_CALL *PFN_clGetProgramBuildInfo)( 200 cl_program /* program */, cl_device_id /* device */, 201 cl_program_build_info /* param_name */, size_t /* param_value_size */, 202 void * /* param_value */, 203 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 204 typedef cl_kernel(CL_API_CALL *PFN_clCreateKernel)( 205 cl_program /* program */, const char * /* kernel_name */, 206 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; 207 typedef cl_int(CL_API_CALL *PFN_clCreateKernelsInProgram)( 208 cl_program /* program */, cl_uint /* num_kernels */, 209 cl_kernel * /* kernels */, 210 cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0; 211 typedef cl_int(CL_API_CALL *PFN_clRetainKernel)(cl_kernel /* kernel */) 212 CL_API_SUFFIX__VERSION_1_0; 213 typedef cl_int(CL_API_CALL *PFN_clReleaseKernel)(cl_kernel /* kernel */) 214 CL_API_SUFFIX__VERSION_1_0; 215 typedef cl_int(CL_API_CALL *PFN_clSetKernelArg)( 216 cl_kernel /* kernel */, cl_uint /* arg_index */, size_t /* arg_size */, 217 const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0; 218 typedef cl_int(CL_API_CALL *PFN_clSetKernelArgSVMPointer)( 219 cl_kernel /* kernel */, cl_uint /* arg_index */, 220 const void * /* arg_value */) CL_API_SUFFIX__VERSION_2_0; 221 typedef cl_int(CL_API_CALL *PFN_clSetKernelExecInfo)( 222 cl_kernel /* kernel */, cl_kernel_exec_info /* param_name */, 223 size_t /* param_value_size */, 224 const void * /* param_value */) CL_API_SUFFIX__VERSION_2_0; 225 typedef cl_int(CL_API_CALL *PFN_clGetKernelInfo)( 226 cl_kernel /* kernel */, cl_kernel_info /* param_name */, 227 size_t /* param_value_size */, void * /* param_value */, 228 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 229 typedef cl_int(CL_API_CALL *PFN_clGetKernelArgInfo)( 230 cl_kernel /* kernel */, cl_uint /* arg_indx */, 231 cl_kernel_arg_info /* param_name */, size_t /* param_value_size */, 232 void * /* param_value */, 233 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_2; 234 typedef cl_int(CL_API_CALL *PFN_clGetKernelWorkGroupInfo)( 235 cl_kernel /* kernel */, cl_device_id /* device */, 236 cl_kernel_work_group_info /* param_name */, size_t /* param_value_size */, 237 void * /* param_value */, 238 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 239 typedef cl_int(CL_API_CALL *PFN_clWaitForEvents)( 240 cl_uint /* num_events */, 241 const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0; 242 typedef cl_int(CL_API_CALL *PFN_clGetEventInfo)( 243 cl_event /* event */, cl_event_info /* param_name */, 244 size_t /* param_value_size */, void * /* param_value */, 245 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 246 typedef cl_event(CL_API_CALL *PFN_clCreateUserEvent)(cl_context /* context */, 247 cl_int * /* errcode_ret */) 248 CL_API_SUFFIX__VERSION_1_1; 249 typedef cl_int(CL_API_CALL *PFN_clRetainEvent)(cl_event /* event */) 250 CL_API_SUFFIX__VERSION_1_0; 251 typedef cl_int(CL_API_CALL *PFN_clReleaseEvent)(cl_event /* event */) 252 CL_API_SUFFIX__VERSION_1_0; 253 typedef cl_int(CL_API_CALL *PFN_clSetUserEventStatus)( 254 cl_event /* event */, 255 cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1; 256 typedef cl_int(CL_API_CALL *PFN_clSetEventCallback)( 257 cl_event /* event */, cl_int /* command_exec_callback_type */, 258 void(CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *), 259 void * /* user_data */) CL_API_SUFFIX__VERSION_1_1; 260 typedef cl_int(CL_API_CALL *PFN_clGetEventProfilingInfo)( 261 cl_event /* event */, cl_profiling_info /* param_name */, 262 size_t /* param_value_size */, void * /* param_value */, 263 size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; 264 typedef cl_int(CL_API_CALL *PFN_clFlush)(cl_command_queue /* command_queue */) 265 CL_API_SUFFIX__VERSION_1_0; 266 typedef cl_int(CL_API_CALL *PFN_clFinish)(cl_command_queue /* command_queue */) 267 CL_API_SUFFIX__VERSION_1_0; 268 typedef cl_int(CL_API_CALL *PFN_clEnqueueReadBuffer)( 269 cl_command_queue /* command_queue */, cl_mem /* buffer */, 270 cl_bool /* blocking_read */, size_t /* offset */, size_t /* size */, 271 void * /* ptr */, cl_uint /* num_events_in_wait_list */, 272 const cl_event * /* event_wait_list */, 273 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 274 typedef cl_int(CL_API_CALL *PFN_clEnqueueReadBufferRect)( 275 cl_command_queue /* command_queue */, cl_mem /* buffer */, 276 cl_bool /* blocking_read */, const size_t * /* buffer_offset */, 277 const size_t * /* host_offset */, const size_t * /* region */, 278 size_t /* buffer_row_pitch */, size_t /* buffer_slice_pitch */, 279 size_t /* host_row_pitch */, size_t /* host_slice_pitch */, 280 void * /* ptr */, cl_uint /* num_events_in_wait_list */, 281 const cl_event * /* event_wait_list */, 282 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; 283 typedef cl_int(CL_API_CALL *PFN_clEnqueueWriteBuffer)( 284 cl_command_queue /* command_queue */, cl_mem /* buffer */, 285 cl_bool /* blocking_write */, size_t /* offset */, size_t /* size */, 286 const void * /* ptr */, cl_uint /* num_events_in_wait_list */, 287 const cl_event * /* event_wait_list */, 288 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 289 typedef cl_int(CL_API_CALL *PFN_clEnqueueWriteBufferRect)( 290 cl_command_queue /* command_queue */, cl_mem /* buffer */, 291 cl_bool /* blocking_write */, const size_t * /* buffer_offset */, 292 const size_t * /* host_offset */, const size_t * /* region */, 293 size_t /* buffer_row_pitch */, size_t /* buffer_slice_pitch */, 294 size_t /* host_row_pitch */, size_t /* host_slice_pitch */, 295 const void * /* ptr */, cl_uint /* num_events_in_wait_list */, 296 const cl_event * /* event_wait_list */, 297 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; 298 typedef cl_int(CL_API_CALL *PFN_clEnqueueFillBuffer)( 299 cl_command_queue /* command_queue */, cl_mem /* buffer */, 300 const void * /* pattern */, size_t /* pattern_size */, size_t /* offset */, 301 size_t /* size */, cl_uint /* num_events_in_wait_list */, 302 const cl_event * /* event_wait_list */, 303 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; 304 typedef cl_int(CL_API_CALL *PFN_clEnqueueCopyBuffer)( 305 cl_command_queue /* command_queue */, cl_mem /* src_buffer */, 306 cl_mem /* dst_buffer */, size_t /* src_offset */, size_t /* dst_offset */, 307 size_t /* size */, cl_uint /* num_events_in_wait_list */, 308 const cl_event * /* event_wait_list */, 309 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 310 typedef cl_int(CL_API_CALL *PFN_clEnqueueCopyBufferRect)( 311 cl_command_queue /* command_queue */, cl_mem /* src_buffer */, 312 cl_mem /* dst_buffer */, const size_t * /* src_origin */, 313 const size_t * /* dst_origin */, const size_t * /* region */, 314 size_t /* src_row_pitch */, size_t /* src_slice_pitch */, 315 size_t /* dst_row_pitch */, size_t /* dst_slice_pitch */, 316 cl_uint /* num_events_in_wait_list */, 317 const cl_event * /* event_wait_list */, 318 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; 319 typedef cl_int(CL_API_CALL *PFN_clEnqueueReadImage)( 320 cl_command_queue /* command_queue */, cl_mem /* image */, 321 cl_bool /* blocking_read */, const size_t * /* origin[3] */, 322 const size_t * /* region[3] */, size_t /* row_pitch */, 323 size_t /* slice_pitch */, void * /* ptr */, 324 cl_uint /* num_events_in_wait_list */, 325 const cl_event * /* event_wait_list */, 326 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 327 typedef cl_int(CL_API_CALL *PFN_clEnqueueWriteImage)( 328 cl_command_queue /* command_queue */, cl_mem /* image */, 329 cl_bool /* blocking_write */, const size_t * /* origin[3] */, 330 const size_t * /* region[3] */, size_t /* input_row_pitch */, 331 size_t /* input_slice_pitch */, const void * /* ptr */, 332 cl_uint /* num_events_in_wait_list */, 333 const cl_event * /* event_wait_list */, 334 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 335 typedef cl_int(CL_API_CALL *PFN_clEnqueueFillImage)( 336 cl_command_queue /* command_queue */, cl_mem /* image */, 337 const void * /* fill_color */, const size_t * /* origin[3] */, 338 const size_t * /* region[3] */, cl_uint /* num_events_in_wait_list */, 339 const cl_event * /* event_wait_list */, 340 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; 341 typedef cl_int(CL_API_CALL *PFN_clEnqueueCopyImage)( 342 cl_command_queue /* command_queue */, cl_mem /* src_image */, 343 cl_mem /* dst_image */, const size_t * /* src_origin[3] */, 344 const size_t * /* dst_origin[3] */, const size_t * /* region[3] */, 345 cl_uint /* num_events_in_wait_list */, 346 const cl_event * /* event_wait_list */, 347 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 348 typedef cl_int(CL_API_CALL *PFN_clEnqueueCopyImageToBuffer)( 349 cl_command_queue /* command_queue */, cl_mem /* src_image */, 350 cl_mem /* dst_buffer */, const size_t * /* src_origin[3] */, 351 const size_t * /* region[3] */, size_t /* dst_offset */, 352 cl_uint /* num_events_in_wait_list */, 353 const cl_event * /* event_wait_list */, 354 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 355 typedef cl_int(CL_API_CALL *PFN_clEnqueueCopyBufferToImage)( 356 cl_command_queue /* command_queue */, cl_mem /* src_buffer */, 357 cl_mem /* dst_image */, size_t /* src_offset */, 358 const size_t * /* dst_origin[3] */, const size_t * /* region[3] */, 359 cl_uint /* num_events_in_wait_list */, 360 const cl_event * /* event_wait_list */, 361 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 362 typedef void *(CL_API_CALL *PFN_clEnqueueMapBuffer)( 363 cl_command_queue /* command_queue */, cl_mem /* buffer */, 364 cl_bool /* blocking_map */, cl_map_flags /* map_flags */, 365 size_t /* offset */, size_t /* size */, 366 cl_uint /* num_events_in_wait_list */, 367 const cl_event * /* event_wait_list */, cl_event * /* event */, 368 cl_int * /* errcode_ret */)CL_API_SUFFIX__VERSION_1_0; 369 typedef void *(CL_API_CALL *PFN_clEnqueueMapImage)( 370 cl_command_queue /* command_queue */, cl_mem /* image */, 371 cl_bool /* blocking_map */, cl_map_flags /* map_flags */, 372 const size_t * /* origin[3] */, const size_t * /* region[3] */, 373 size_t * /* image_row_pitch */, size_t * /* image_slice_pitch */, 374 cl_uint /* num_events_in_wait_list */, 375 const cl_event * /* event_wait_list */, cl_event * /* event */, 376 cl_int * /* errcode_ret */)CL_API_SUFFIX__VERSION_1_0; 377 typedef cl_int(CL_API_CALL *PFN_clEnqueueUnmapMemObject)( 378 cl_command_queue /* command_queue */, cl_mem /* memobj */, 379 void * /* mapped_ptr */, cl_uint /* num_events_in_wait_list */, 380 const cl_event * /* event_wait_list */, 381 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 382 typedef cl_int(CL_API_CALL *PFN_clEnqueueMigrateMemObjects)( 383 cl_command_queue /* command_queue */, cl_uint /* num_mem_objects */, 384 const cl_mem * /* mem_objects */, cl_mem_migration_flags /* flags */, 385 cl_uint /* num_events_in_wait_list */, 386 const cl_event * /* event_wait_list */, 387 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; 388 typedef cl_int(CL_API_CALL *PFN_clEnqueueNDRangeKernel)( 389 cl_command_queue /* command_queue */, cl_kernel /* kernel */, 390 cl_uint /* work_dim */, const size_t * /* global_work_offset */, 391 const size_t * /* global_work_size */, const size_t * /* local_work_size */, 392 cl_uint /* num_events_in_wait_list */, 393 const cl_event * /* event_wait_list */, 394 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 395 typedef cl_int(CL_API_CALL *PFN_clEnqueueNativeKernel)( 396 cl_command_queue /* command_queue */, 397 void(CL_CALLBACK * /*user_func*/)(void *), void * /* args */, 398 size_t /* cb_args */, cl_uint /* num_mem_objects */, 399 const cl_mem * /* mem_list */, const void ** /* args_mem_loc */, 400 cl_uint /* num_events_in_wait_list */, 401 const cl_event * /* event_wait_list */, 402 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 403 typedef cl_int(CL_API_CALL *PFN_clEnqueueMarkerWithWaitList)( 404 cl_command_queue /* command_queue */, cl_uint /* num_events_in_wait_list */, 405 const cl_event * /* event_wait_list */, 406 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; 407 typedef cl_int(CL_API_CALL *PFN_clEnqueueBarrierWithWaitList)( 408 cl_command_queue /* command_queue */, cl_uint /* num_events_in_wait_list */, 409 const cl_event * /* event_wait_list */, 410 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; 411 typedef cl_int(CL_API_CALL *PFN_clEnqueueSVMFree)( 412 cl_command_queue /* command_queue */, cl_uint /* num_svm_pointers */, 413 void *[] /* svm_pointers[] */, 414 void(CL_CALLBACK * /*pfn_free_func*/)(cl_command_queue /* queue */, 415 cl_uint /* num_svm_pointers */, 416 void *[] /* svm_pointers[] */, 417 void * /* user_data */), 418 void * /* user_data */, cl_uint /* num_events_in_wait_list */, 419 const cl_event * /* event_wait_list */, 420 cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; 421 typedef cl_int(CL_API_CALL *PFN_clEnqueueSVMMemcpy)( 422 cl_command_queue /* command_queue */, cl_bool /* blocking_copy */, 423 void * /* dst_ptr */, const void * /* src_ptr */, size_t /* size */, 424 cl_uint /* num_events_in_wait_list */, 425 const cl_event * /* event_wait_list */, 426 cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; 427 typedef cl_int(CL_API_CALL *PFN_clEnqueueSVMMemFill)( 428 cl_command_queue /* command_queue */, void * /* svm_ptr */, 429 const void * /* pattern */, size_t /* pattern_size */, size_t /* size */, 430 cl_uint /* num_events_in_wait_list */, 431 const cl_event * /* event_wait_list */, 432 cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; 433 typedef cl_int(CL_API_CALL *PFN_clEnqueueSVMMap)( 434 cl_command_queue /* command_queue */, cl_bool /* blocking_map */, 435 cl_map_flags /* flags */, void * /* svm_ptr */, size_t /* size */, 436 cl_uint /* num_events_in_wait_list */, 437 const cl_event * /* event_wait_list */, 438 cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; 439 typedef cl_int(CL_API_CALL *PFN_clEnqueueSVMUnmap)( 440 cl_command_queue /* command_queue */, void * /* svm_ptr */, 441 cl_uint /* num_events_in_wait_list */, 442 const cl_event * /* event_wait_list */, 443 cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; 444 typedef void *(CL_API_CALL *PFN_clGetExtensionFunctionAddressForPlatform)( 445 cl_platform_id /* platform */, 446 const char * /* func_name */)CL_API_SUFFIX__VERSION_1_2; 447 typedef cl_mem(CL_API_CALL *PFN_clCreateImage2D)( 448 cl_context /* context */, cl_mem_flags /* flags */, 449 const cl_image_format * /* image_format */, size_t /* image_width */, 450 size_t /* image_height */, size_t /* image_row_pitch */, 451 void * /* host_ptr */, cl_int * /* errcode_ret */); 452 typedef cl_mem(CL_API_CALL *PFN_clCreateImage3D)( 453 cl_context /* context */, cl_mem_flags /* flags */, 454 const cl_image_format * /* image_format */, size_t /* image_width */, 455 size_t /* image_height */, size_t /* image_depth */, 456 size_t /* image_row_pitch */, size_t /* image_slice_pitch */, 457 void * /* host_ptr */, cl_int * /* errcode_ret */); 458 typedef cl_int(CL_API_CALL *PFN_clEnqueueMarker)( 459 cl_command_queue /* command_queue */, cl_event * /* event */); 460 typedef cl_int(CL_API_CALL *PFN_clEnqueueWaitForEvents)( 461 cl_command_queue /* command_queue */, cl_uint /* num_events */, 462 const cl_event * /* event_list */); 463 typedef cl_int(CL_API_CALL *PFN_clEnqueueBarrier)( 464 cl_command_queue /* command_queue */); 465 typedef cl_int(CL_API_CALL *PFN_clUnloadCompiler)(); 466 typedef void *(CL_API_CALL *PFN_clGetExtensionFunctionAddress)( 467 const char * /* func_name */); 468 typedef cl_command_queue(CL_API_CALL *PFN_clCreateCommandQueue)( 469 cl_context /* context */, cl_device_id /* device */, 470 cl_command_queue_properties /* properties */, cl_int * /* errcode_ret */); 471 typedef cl_sampler(CL_API_CALL *PFN_clCreateSampler)( 472 cl_context /* context */, cl_bool /* normalized_coords */, 473 cl_addressing_mode /* addressing_mode */, cl_filter_mode /* filter_mode */, 474 cl_int * /* errcode_ret */); 475 typedef cl_int(CL_API_CALL *PFN_clEnqueueTask)( 476 cl_command_queue /* command_queue */, cl_kernel /* kernel */, 477 cl_uint /* num_events_in_wait_list */, 478 const cl_event * /* event_wait_list */, cl_event * /* event */); 479 480 // OpenGL sharing 481 typedef cl_mem(CL_API_CALL *PFN_clCreateFromGLBuffer)(cl_context, cl_mem_flags, 482 cl_GLuint, int *); 483 typedef cl_mem(CL_API_CALL *PFN_clCreateFromGLTexture)( 484 cl_context /* context */, cl_mem_flags /* flags */, cl_GLenum /* target */, 485 cl_GLint /* miplevel */, cl_GLuint /* texture */, 486 cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2; 487 typedef cl_int(CL_API_CALL *PFN_clEnqueueAcquireGLObjects)( 488 cl_command_queue /* command_queue */, cl_uint /* num_objects */, 489 const cl_mem * /* mem_objects */, cl_uint /* num_events_in_wait_list */, 490 const cl_event * /* event_wait_list */, cl_event * /* event */); 491 typedef cl_int(CL_API_CALL *PFN_clEnqueueReleaseGLObjects)( 492 cl_command_queue /* command_queue */, cl_uint /* num_objects */, 493 const cl_mem * /* mem_objects */, cl_uint /* num_events_in_wait_list */, 494 const cl_event * /* event_wait_list */, 495 cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; 496 497 // cl_khr_egl_event extension 498 499 // CLeglDisplayKHR is an opaque handle to an EGLDisplay 500 typedef void *CLeglDisplayKHR; 501 502 // CLeglSyncKHR is an opaque handle to an EGLSync object 503 typedef void *CLeglSyncKHR; 504 505 typedef cl_event(CL_API_CALL *PFN_clCreateEventFromEGLSyncKHR)( 506 cl_context /* context */, CLeglSyncKHR /* sync */, 507 CLeglDisplayKHR /* display */, cl_int * /* errcode_ret */); 508 509 // EGL sharing 510 typedef cl_mem(CL_API_CALL *PFN_clCreateFromEGLImageKHR)( 511 cl_context /*context*/, CLeglDisplayKHR /*display*/, 512 CLeglImageKHR /*image*/, cl_mem_flags /*flags*/, 513 const cl_egl_image_properties_khr * /*properties*/, 514 cl_int * /*errcode_ret*/); 515 typedef cl_int(CL_API_CALL *PFN_clEnqueueAcquireEGLObjectsKHR)( 516 cl_command_queue /*command_queue*/, cl_uint /*num_objects*/, 517 const cl_mem * /*mem_objects*/, cl_uint /*num_events_in_wait_list*/, 518 const cl_event * /*event_wait_list*/, cl_event * /*event*/); 519 typedef cl_int(CL_API_CALL *PFN_clEnqueueReleaseEGLObjectsKHR)( 520 cl_command_queue /*command_queue*/, cl_uint /*num_objects*/, 521 const cl_mem * /*mem_objects*/, cl_uint /*num_events_in_wait_list*/, 522 const cl_event * /*event_wait_list*/, cl_event * /*event*/); 523 524 extern PFN_clGetPlatformIDs clGetPlatformIDs; 525 extern PFN_clGetPlatformInfo clGetPlatformInfo; 526 extern PFN_clGetDeviceIDs clGetDeviceIDs; 527 extern PFN_clGetDeviceInfo clGetDeviceInfo; 528 extern PFN_clCreateSubDevices clCreateSubDevices; 529 extern PFN_clRetainDevice clRetainDevice; 530 extern PFN_clReleaseDevice clReleaseDevice; 531 extern PFN_clCreateContext clCreateContext; 532 extern PFN_clCreateContextFromType clCreateContextFromType; 533 extern PFN_clRetainContext clRetainContext; 534 extern PFN_clReleaseContext clReleaseContext; 535 extern PFN_clGetContextInfo clGetContextInfo; 536 extern PFN_clCreateCommandQueueWithProperties 537 clCreateCommandQueueWithProperties; 538 extern PFN_clRetainCommandQueue clRetainCommandQueue; 539 extern PFN_clReleaseCommandQueue clReleaseCommandQueue; 540 extern PFN_clGetCommandQueueInfo clGetCommandQueueInfo; 541 extern PFN_clCreateBuffer clCreateBuffer; 542 extern PFN_clCreateSubBuffer clCreateSubBuffer; 543 extern PFN_clCreateImage clCreateImage; 544 extern PFN_clCreatePipe clCreatePipe; 545 extern PFN_clRetainMemObject clRetainMemObject; 546 extern PFN_clReleaseMemObject clReleaseMemObject; 547 extern PFN_clGetSupportedImageFormats clGetSupportedImageFormats; 548 extern PFN_clGetMemObjectInfo clGetMemObjectInfo; 549 extern PFN_clGetImageInfo clGetImageInfo; 550 extern PFN_clGetPipeInfo clGetPipeInfo; 551 extern PFN_clSetMemObjectDestructorCallback clSetMemObjectDestructorCallback; 552 extern PFN_clSVMAlloc clSVMAlloc; 553 extern PFN_clSVMFree clSVMFree; 554 extern PFN_clCreateSamplerWithProperties clCreateSamplerWithProperties; 555 extern PFN_clRetainSampler clRetainSampler; 556 extern PFN_clReleaseSampler clReleaseSampler; 557 extern PFN_clGetSamplerInfo clGetSamplerInfo; 558 extern PFN_clCreateProgramWithSource clCreateProgramWithSource; 559 extern PFN_clCreateProgramWithBinary clCreateProgramWithBinary; 560 extern PFN_clCreateProgramWithBuiltInKernels clCreateProgramWithBuiltInKernels; 561 extern PFN_clRetainProgram clRetainProgram; 562 extern PFN_clReleaseProgram clReleaseProgram; 563 extern PFN_clBuildProgram clBuildProgram; 564 extern PFN_clCompileProgram clCompileProgram; 565 extern PFN_clLinkProgram clLinkProgram; 566 extern PFN_clUnloadPlatformCompiler clUnloadPlatformCompiler; 567 extern PFN_clGetProgramInfo clGetProgramInfo; 568 extern PFN_clGetProgramBuildInfo clGetProgramBuildInfo; 569 extern PFN_clCreateKernel clCreateKernel; 570 extern PFN_clCreateKernelsInProgram clCreateKernelsInProgram; 571 extern PFN_clRetainKernel clRetainKernel; 572 extern PFN_clReleaseKernel clReleaseKernel; 573 extern PFN_clSetKernelArg clSetKernelArg; 574 extern PFN_clSetKernelArgSVMPointer clSetKernelArgSVMPointer; 575 extern PFN_clSetKernelExecInfo clSetKernelExecInfo; 576 extern PFN_clGetKernelInfo clGetKernelInfo; 577 extern PFN_clGetKernelArgInfo clGetKernelArgInfo; 578 extern PFN_clGetKernelWorkGroupInfo clGetKernelWorkGroupInfo; 579 extern PFN_clWaitForEvents clWaitForEvents; 580 extern PFN_clGetEventInfo clGetEventInfo; 581 extern PFN_clCreateUserEvent clCreateUserEvent; 582 extern PFN_clRetainEvent clRetainEvent; 583 extern PFN_clReleaseEvent clReleaseEvent; 584 extern PFN_clSetUserEventStatus clSetUserEventStatus; 585 extern PFN_clSetEventCallback clSetEventCallback; 586 extern PFN_clGetEventProfilingInfo clGetEventProfilingInfo; 587 extern PFN_clFlush clFlush; 588 extern PFN_clFinish clFinish; 589 extern PFN_clEnqueueReadBuffer clEnqueueReadBuffer; 590 extern PFN_clEnqueueReadBufferRect clEnqueueReadBufferRect; 591 extern PFN_clEnqueueWriteBuffer clEnqueueWriteBuffer; 592 extern PFN_clEnqueueWriteBufferRect clEnqueueWriteBufferRect; 593 extern PFN_clEnqueueFillBuffer clEnqueueFillBuffer; 594 extern PFN_clEnqueueCopyBuffer clEnqueueCopyBuffer; 595 extern PFN_clEnqueueCopyBufferRect clEnqueueCopyBufferRect; 596 extern PFN_clEnqueueReadImage clEnqueueReadImage; 597 extern PFN_clEnqueueWriteImage clEnqueueWriteImage; 598 extern PFN_clEnqueueFillImage clEnqueueFillImage; 599 extern PFN_clEnqueueCopyImage clEnqueueCopyImage; 600 extern PFN_clEnqueueCopyImageToBuffer clEnqueueCopyImageToBuffer; 601 extern PFN_clEnqueueCopyBufferToImage clEnqueueCopyBufferToImage; 602 extern PFN_clEnqueueMapBuffer clEnqueueMapBuffer; 603 extern PFN_clEnqueueMapImage clEnqueueMapImage; 604 extern PFN_clEnqueueUnmapMemObject clEnqueueUnmapMemObject; 605 extern PFN_clEnqueueMigrateMemObjects clEnqueueMigrateMemObjects; 606 extern PFN_clEnqueueNDRangeKernel clEnqueueNDRangeKernel; 607 extern PFN_clEnqueueNativeKernel clEnqueueNativeKernel; 608 extern PFN_clEnqueueMarkerWithWaitList clEnqueueMarkerWithWaitList; 609 extern PFN_clEnqueueBarrierWithWaitList clEnqueueBarrierWithWaitList; 610 extern PFN_clEnqueueSVMFree clEnqueueSVMFree; 611 extern PFN_clEnqueueSVMMemcpy clEnqueueSVMMemcpy; 612 extern PFN_clEnqueueSVMMemFill clEnqueueSVMMemFill; 613 extern PFN_clEnqueueSVMMap clEnqueueSVMMap; 614 extern PFN_clEnqueueSVMUnmap clEnqueueSVMUnmap; 615 extern PFN_clGetExtensionFunctionAddressForPlatform 616 clGetExtensionFunctionAddressForPlatform; 617 extern PFN_clCreateImage2D clCreateImage2D; 618 extern PFN_clCreateImage3D clCreateImage3D; 619 extern PFN_clEnqueueMarker clEnqueueMarker; 620 extern PFN_clEnqueueWaitForEvents clEnqueueWaitForEvents; 621 extern PFN_clEnqueueBarrier clEnqueueBarrier; 622 extern PFN_clUnloadCompiler clUnloadCompiler; 623 extern PFN_clGetExtensionFunctionAddress clGetExtensionFunctionAddress; 624 extern PFN_clCreateCommandQueue clCreateCommandQueue; 625 extern PFN_clCreateSampler clCreateSampler; 626 extern PFN_clEnqueueTask clEnqueueTask; 627 628 // OpenGL sharing 629 extern PFN_clCreateFromGLBuffer clCreateFromGLBuffer; 630 extern PFN_clCreateFromGLTexture clCreateFromGLTexture; 631 extern PFN_clEnqueueAcquireGLObjects clEnqueueAcquireGLObjects; 632 extern PFN_clEnqueueReleaseGLObjects clEnqueueReleaseGLObjects; 633 634 // cl_khr_egl_event extension 635 extern PFN_clCreateEventFromEGLSyncKHR clCreateEventFromEGLSyncKHR; 636 637 // EGL sharing 638 extern PFN_clCreateFromEGLImageKHR clCreateFromEGLImageKHR; 639 extern PFN_clEnqueueAcquireEGLObjectsKHR clEnqueueAcquireEGLObjectsKHR; 640 extern PFN_clEnqueueReleaseEGLObjectsKHR clEnqueueReleaseEGLObjectsKHR; 641 642 // For convenient image creation 643 // It uses clCreateImage if it available (clCreateImage available since cl 1.2) 644 // otherwise it will use legacy clCreateImage2D 645 cl_mem CreateImage2DLegacy(cl_context context, cl_mem_flags flags, 646 const cl_image_format *image_format, 647 const cl_image_desc *image_desc, void *host_ptr, 648 cl_int *errcode_ret); 649 650 // It uses clCreateImage if it available (clCreateImage available since cl 1.2) 651 // otherwise it will use legacy clCreateImage3D 652 cl_mem CreateImage3DLegacy(cl_context context, cl_mem_flags flags, 653 const cl_image_format *image_format, 654 const cl_image_desc *image_desc, void *host_ptr, 655 cl_int *errcode_ret); 656 657 } // namespace cl 658 } // namespace gpu 659 } // namespace tflite 660 661 #endif // TENSORFLOW_LITE_DELEGATES_GPU_CL_OPENCL_WRAPPER_H_ 662