1 //
2 // Copyright 2021 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // cl_stubs.cpp: Stubs for CL entry points.
7
8 #include "libGLESv2/cl_stubs_autogen.h"
9
10 #include "libGLESv2/proc_table_cl.h"
11
12 #include "libANGLE/CLBuffer.h"
13 #include "libANGLE/CLCommandQueue.h"
14 #include "libANGLE/CLContext.h"
15 #include "libANGLE/CLDevice.h"
16 #include "libANGLE/CLEvent.h"
17 #include "libANGLE/CLImage.h"
18 #include "libANGLE/CLKernel.h"
19 #include "libANGLE/CLMemory.h"
20 #include "libANGLE/CLPlatform.h"
21 #include "libANGLE/CLProgram.h"
22 #include "libANGLE/CLSampler.h"
23
24 #define WARN_NOT_SUPPORTED(command) \
25 do \
26 { \
27 static bool sWarned = false; \
28 if (!sWarned) \
29 { \
30 sWarned = true; \
31 WARN() << "OpenCL command " #command " is not (yet) supported"; \
32 } \
33 } while (0)
34
35 namespace cl
36 {
37
IcdGetPlatformIDsKHR(cl_uint num_entries,cl_platform_id * platforms,cl_uint * num_platforms)38 cl_int IcdGetPlatformIDsKHR(cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
39 {
40 return Platform::GetPlatformIDs(num_entries, platforms, num_platforms);
41 }
42
GetPlatformIDs(cl_uint num_entries,cl_platform_id * platforms,cl_uint * num_platforms)43 cl_int GetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
44 {
45 return Platform::GetPlatformIDs(num_entries, platforms, num_platforms);
46 }
47
GetPlatformInfo(cl_platform_id platform,PlatformInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)48 cl_int GetPlatformInfo(cl_platform_id platform,
49 PlatformInfo param_name,
50 size_t param_value_size,
51 void *param_value,
52 size_t *param_value_size_ret)
53 {
54 return Platform::CastOrDefault(platform)->getInfo(param_name, param_value_size, param_value,
55 param_value_size_ret);
56 }
57
GetDeviceIDs(cl_platform_id platform,DeviceType device_type,cl_uint num_entries,cl_device_id * devices,cl_uint * num_devices)58 cl_int GetDeviceIDs(cl_platform_id platform,
59 DeviceType device_type,
60 cl_uint num_entries,
61 cl_device_id *devices,
62 cl_uint *num_devices)
63 {
64 return Platform::CastOrDefault(platform)->getDeviceIDs(device_type, num_entries, devices,
65 num_devices);
66 }
67
GetDeviceInfo(cl_device_id device,DeviceInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)68 cl_int GetDeviceInfo(cl_device_id device,
69 DeviceInfo param_name,
70 size_t param_value_size,
71 void *param_value,
72 size_t *param_value_size_ret)
73 {
74 return device->cast<Device>().getInfo(param_name, param_value_size, param_value,
75 param_value_size_ret);
76 }
77
CreateSubDevices(cl_device_id in_device,const cl_device_partition_property * properties,cl_uint num_devices,cl_device_id * out_devices,cl_uint * num_devices_ret)78 cl_int CreateSubDevices(cl_device_id in_device,
79 const cl_device_partition_property *properties,
80 cl_uint num_devices,
81 cl_device_id *out_devices,
82 cl_uint *num_devices_ret)
83 {
84 return in_device->cast<Device>().createSubDevices(properties, num_devices, out_devices,
85 num_devices_ret);
86 }
87
RetainDevice(cl_device_id device)88 cl_int RetainDevice(cl_device_id device)
89 {
90 Device &dev = device->cast<Device>();
91 if (!dev.isRoot())
92 {
93 dev.retain();
94 }
95 return CL_SUCCESS;
96 }
97
ReleaseDevice(cl_device_id device)98 cl_int ReleaseDevice(cl_device_id device)
99 {
100 Device &dev = device->cast<Device>();
101 if (!dev.isRoot() && dev.release())
102 {
103 delete &dev;
104 }
105 return CL_SUCCESS;
106 }
107
SetDefaultDeviceCommandQueue(cl_context context,cl_device_id device,cl_command_queue command_queue)108 cl_int SetDefaultDeviceCommandQueue(cl_context context,
109 cl_device_id device,
110 cl_command_queue command_queue)
111 {
112 WARN_NOT_SUPPORTED(SetDefaultDeviceCommandQueue);
113 return 0;
114 }
115
GetDeviceAndHostTimer(cl_device_id device,cl_ulong * device_timestamp,cl_ulong * host_timestamp)116 cl_int GetDeviceAndHostTimer(cl_device_id device,
117 cl_ulong *device_timestamp,
118 cl_ulong *host_timestamp)
119 {
120 WARN_NOT_SUPPORTED(GetDeviceAndHostTimer);
121 return 0;
122 }
123
GetHostTimer(cl_device_id device,cl_ulong * host_timestamp)124 cl_int GetHostTimer(cl_device_id device, cl_ulong *host_timestamp)
125 {
126 WARN_NOT_SUPPORTED(GetHostTimer);
127 return 0;
128 }
129
CreateContext(const cl_context_properties * properties,cl_uint num_devices,const cl_device_id * devices,void (CL_CALLBACK * pfn_notify)(const char * errinfo,const void * private_info,size_t cb,void * user_data),void * user_data,cl_int & errorCode)130 cl_context CreateContext(const cl_context_properties *properties,
131 cl_uint num_devices,
132 const cl_device_id *devices,
133 void(CL_CALLBACK *pfn_notify)(const char *errinfo,
134 const void *private_info,
135 size_t cb,
136 void *user_data),
137 void *user_data,
138 cl_int &errorCode)
139 {
140 return Platform::CreateContext(properties, num_devices, devices, pfn_notify, user_data,
141 errorCode);
142 }
143
CreateContextFromType(const cl_context_properties * properties,DeviceType device_type,void (CL_CALLBACK * pfn_notify)(const char * errinfo,const void * private_info,size_t cb,void * user_data),void * user_data,cl_int & errorCode)144 cl_context CreateContextFromType(const cl_context_properties *properties,
145 DeviceType device_type,
146 void(CL_CALLBACK *pfn_notify)(const char *errinfo,
147 const void *private_info,
148 size_t cb,
149 void *user_data),
150 void *user_data,
151 cl_int &errorCode)
152 {
153 return Platform::CreateContextFromType(properties, device_type, pfn_notify, user_data,
154 errorCode);
155 }
156
RetainContext(cl_context context)157 cl_int RetainContext(cl_context context)
158 {
159 context->cast<Context>().retain();
160 return CL_SUCCESS;
161 }
162
ReleaseContext(cl_context context)163 cl_int ReleaseContext(cl_context context)
164 {
165 Context &ctx = context->cast<Context>();
166 if (ctx.release())
167 {
168 delete &ctx;
169 }
170 return CL_SUCCESS;
171 }
172
GetContextInfo(cl_context context,ContextInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)173 cl_int GetContextInfo(cl_context context,
174 ContextInfo param_name,
175 size_t param_value_size,
176 void *param_value,
177 size_t *param_value_size_ret)
178 {
179 return context->cast<Context>().getInfo(param_name, param_value_size, param_value,
180 param_value_size_ret);
181 }
182
SetContextDestructorCallback(cl_context context,void (CL_CALLBACK * pfn_notify)(cl_context context,void * user_data),void * user_data)183 cl_int SetContextDestructorCallback(cl_context context,
184 void(CL_CALLBACK *pfn_notify)(cl_context context,
185 void *user_data),
186 void *user_data)
187 {
188 WARN_NOT_SUPPORTED(SetContextDestructorCallback);
189 return 0;
190 }
191
CreateCommandQueueWithProperties(cl_context context,cl_device_id device,const cl_queue_properties * properties,cl_int & errorCode)192 cl_command_queue CreateCommandQueueWithProperties(cl_context context,
193 cl_device_id device,
194 const cl_queue_properties *properties,
195 cl_int &errorCode)
196 {
197 return context->cast<Context>().createCommandQueueWithProperties(device, properties, errorCode);
198 }
199
RetainCommandQueue(cl_command_queue command_queue)200 cl_int RetainCommandQueue(cl_command_queue command_queue)
201 {
202 command_queue->cast<CommandQueue>().retain();
203 return CL_SUCCESS;
204 }
205
ReleaseCommandQueue(cl_command_queue command_queue)206 cl_int ReleaseCommandQueue(cl_command_queue command_queue)
207 {
208 CommandQueue &queue = command_queue->cast<CommandQueue>();
209 if (queue.release())
210 {
211 delete &queue;
212 }
213 return CL_SUCCESS;
214 }
215
GetCommandQueueInfo(cl_command_queue command_queue,CommandQueueInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)216 cl_int GetCommandQueueInfo(cl_command_queue command_queue,
217 CommandQueueInfo param_name,
218 size_t param_value_size,
219 void *param_value,
220 size_t *param_value_size_ret)
221 {
222 return command_queue->cast<CommandQueue>().getInfo(param_name, param_value_size, param_value,
223 param_value_size_ret);
224 }
225
CreateBuffer(cl_context context,MemFlags flags,size_t size,void * host_ptr,cl_int & errorCode)226 cl_mem CreateBuffer(cl_context context,
227 MemFlags flags,
228 size_t size,
229 void *host_ptr,
230 cl_int &errorCode)
231 {
232 return context->cast<Context>().createBuffer(nullptr, flags, size, host_ptr, errorCode);
233 }
234
CreateBufferWithProperties(cl_context context,const cl_mem_properties * properties,MemFlags flags,size_t size,void * host_ptr,cl_int & errorCode)235 cl_mem CreateBufferWithProperties(cl_context context,
236 const cl_mem_properties *properties,
237 MemFlags flags,
238 size_t size,
239 void *host_ptr,
240 cl_int &errorCode)
241 {
242 return context->cast<Context>().createBuffer(properties, flags, size, host_ptr, errorCode);
243 }
244
CreateSubBuffer(cl_mem buffer,MemFlags flags,cl_buffer_create_type buffer_create_type,const void * buffer_create_info,cl_int & errorCode)245 cl_mem CreateSubBuffer(cl_mem buffer,
246 MemFlags flags,
247 cl_buffer_create_type buffer_create_type,
248 const void *buffer_create_info,
249 cl_int &errorCode)
250 {
251 return buffer->cast<Buffer>().createSubBuffer(flags, buffer_create_type, buffer_create_info,
252 errorCode);
253 }
254
CreateImage(cl_context context,MemFlags flags,const cl_image_format * image_format,const cl_image_desc * image_desc,void * host_ptr,cl_int & errorCode)255 cl_mem CreateImage(cl_context context,
256 MemFlags flags,
257 const cl_image_format *image_format,
258 const cl_image_desc *image_desc,
259 void *host_ptr,
260 cl_int &errorCode)
261 {
262 return context->cast<Context>().createImage(nullptr, flags, image_format, image_desc, host_ptr,
263 errorCode);
264 }
265
CreateImageWithProperties(cl_context context,const cl_mem_properties * properties,MemFlags flags,const cl_image_format * image_format,const cl_image_desc * image_desc,void * host_ptr,cl_int & errorCode)266 cl_mem CreateImageWithProperties(cl_context context,
267 const cl_mem_properties *properties,
268 MemFlags flags,
269 const cl_image_format *image_format,
270 const cl_image_desc *image_desc,
271 void *host_ptr,
272 cl_int &errorCode)
273 {
274 return context->cast<Context>().createImage(properties, flags, image_format, image_desc,
275 host_ptr, errorCode);
276 }
277
CreatePipe(cl_context context,MemFlags flags,cl_uint pipe_packet_size,cl_uint pipe_max_packets,const cl_pipe_properties * properties,cl_int & errorCode)278 cl_mem CreatePipe(cl_context context,
279 MemFlags flags,
280 cl_uint pipe_packet_size,
281 cl_uint pipe_max_packets,
282 const cl_pipe_properties *properties,
283 cl_int &errorCode)
284 {
285 WARN_NOT_SUPPORTED(CreatePipe);
286 return 0;
287 }
288
RetainMemObject(cl_mem memobj)289 cl_int RetainMemObject(cl_mem memobj)
290 {
291 memobj->cast<Memory>().retain();
292 return CL_SUCCESS;
293 }
294
ReleaseMemObject(cl_mem memobj)295 cl_int ReleaseMemObject(cl_mem memobj)
296 {
297 Memory &memory = memobj->cast<Memory>();
298 if (memory.release())
299 {
300 delete &memory;
301 }
302 return CL_SUCCESS;
303 }
304
GetSupportedImageFormats(cl_context context,MemFlags flags,MemObjectType image_type,cl_uint num_entries,cl_image_format * image_formats,cl_uint * num_image_formats)305 cl_int GetSupportedImageFormats(cl_context context,
306 MemFlags flags,
307 MemObjectType image_type,
308 cl_uint num_entries,
309 cl_image_format *image_formats,
310 cl_uint *num_image_formats)
311 {
312 return context->cast<Context>().getSupportedImageFormats(flags, image_type, num_entries,
313 image_formats, num_image_formats);
314 }
315
GetMemObjectInfo(cl_mem memobj,MemInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)316 cl_int GetMemObjectInfo(cl_mem memobj,
317 MemInfo param_name,
318 size_t param_value_size,
319 void *param_value,
320 size_t *param_value_size_ret)
321 {
322 return memobj->cast<Memory>().getInfo(param_name, param_value_size, param_value,
323 param_value_size_ret);
324 }
325
GetImageInfo(cl_mem image,ImageInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)326 cl_int GetImageInfo(cl_mem image,
327 ImageInfo param_name,
328 size_t param_value_size,
329 void *param_value,
330 size_t *param_value_size_ret)
331 {
332 return image->cast<Image>().getInfo(param_name, param_value_size, param_value,
333 param_value_size_ret);
334 }
335
GetPipeInfo(cl_mem pipe,PipeInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)336 cl_int GetPipeInfo(cl_mem pipe,
337 PipeInfo param_name,
338 size_t param_value_size,
339 void *param_value,
340 size_t *param_value_size_ret)
341 {
342 WARN_NOT_SUPPORTED(GetPipeInfo);
343 return 0;
344 }
345
SetMemObjectDestructorCallback(cl_mem memobj,void (CL_CALLBACK * pfn_notify)(cl_mem memobj,void * user_data),void * user_data)346 cl_int SetMemObjectDestructorCallback(cl_mem memobj,
347 void(CL_CALLBACK *pfn_notify)(cl_mem memobj, void *user_data),
348 void *user_data)
349 {
350 return memobj->cast<Memory>().setDestructorCallback(pfn_notify, user_data);
351 }
352
SVMAlloc(cl_context context,SVM_MemFlags flags,size_t size,cl_uint alignment)353 void *SVMAlloc(cl_context context, SVM_MemFlags flags, size_t size, cl_uint alignment)
354 {
355 WARN_NOT_SUPPORTED(SVMAlloc);
356 return 0;
357 }
358
SVMFree(cl_context context,void * svm_pointer)359 void SVMFree(cl_context context, void *svm_pointer)
360 {
361 WARN_NOT_SUPPORTED(SVMFree);
362 }
363
CreateSamplerWithProperties(cl_context context,const cl_sampler_properties * sampler_properties,cl_int & errorCode)364 cl_sampler CreateSamplerWithProperties(cl_context context,
365 const cl_sampler_properties *sampler_properties,
366 cl_int &errorCode)
367 {
368 return context->cast<Context>().createSamplerWithProperties(sampler_properties, errorCode);
369 }
370
RetainSampler(cl_sampler sampler)371 cl_int RetainSampler(cl_sampler sampler)
372 {
373 sampler->cast<Sampler>().retain();
374 return CL_SUCCESS;
375 }
376
ReleaseSampler(cl_sampler sampler)377 cl_int ReleaseSampler(cl_sampler sampler)
378 {
379 Sampler &smplr = sampler->cast<Sampler>();
380 if (smplr.release())
381 {
382 delete &smplr;
383 }
384 return CL_SUCCESS;
385 }
386
GetSamplerInfo(cl_sampler sampler,SamplerInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)387 cl_int GetSamplerInfo(cl_sampler sampler,
388 SamplerInfo param_name,
389 size_t param_value_size,
390 void *param_value,
391 size_t *param_value_size_ret)
392 {
393 return sampler->cast<Sampler>().getInfo(param_name, param_value_size, param_value,
394 param_value_size_ret);
395 }
396
CreateProgramWithSource(cl_context context,cl_uint count,const char ** strings,const size_t * lengths,cl_int & errorCode)397 cl_program CreateProgramWithSource(cl_context context,
398 cl_uint count,
399 const char **strings,
400 const size_t *lengths,
401 cl_int &errorCode)
402 {
403 return context->cast<Context>().createProgramWithSource(count, strings, lengths, errorCode);
404 }
405
CreateProgramWithBinary(cl_context context,cl_uint num_devices,const cl_device_id * device_list,const size_t * lengths,const unsigned char ** binaries,cl_int * binary_status,cl_int & errorCode)406 cl_program CreateProgramWithBinary(cl_context context,
407 cl_uint num_devices,
408 const cl_device_id *device_list,
409 const size_t *lengths,
410 const unsigned char **binaries,
411 cl_int *binary_status,
412 cl_int &errorCode)
413 {
414 return context->cast<Context>().createProgramWithBinary(num_devices, device_list, lengths,
415 binaries, binary_status, errorCode);
416 }
417
CreateProgramWithBuiltInKernels(cl_context context,cl_uint num_devices,const cl_device_id * device_list,const char * kernel_names,cl_int & errorCode)418 cl_program CreateProgramWithBuiltInKernels(cl_context context,
419 cl_uint num_devices,
420 const cl_device_id *device_list,
421 const char *kernel_names,
422 cl_int &errorCode)
423 {
424 return context->cast<Context>().createProgramWithBuiltInKernels(num_devices, device_list,
425 kernel_names, errorCode);
426 }
427
CreateProgramWithIL(cl_context context,const void * il,size_t length,cl_int & errorCode)428 cl_program CreateProgramWithIL(cl_context context, const void *il, size_t length, cl_int &errorCode)
429 {
430 return context->cast<Context>().createProgramWithIL(il, length, errorCode);
431 }
432
RetainProgram(cl_program program)433 cl_int RetainProgram(cl_program program)
434 {
435 program->cast<Program>().retain();
436 return CL_SUCCESS;
437 }
438
ReleaseProgram(cl_program program)439 cl_int ReleaseProgram(cl_program program)
440 {
441 Program &prog = program->cast<Program>();
442 if (prog.release())
443 {
444 delete &prog;
445 }
446 return CL_SUCCESS;
447 }
448
BuildProgram(cl_program program,cl_uint num_devices,const cl_device_id * device_list,const char * options,void (CL_CALLBACK * pfn_notify)(cl_program program,void * user_data),void * user_data)449 cl_int BuildProgram(cl_program program,
450 cl_uint num_devices,
451 const cl_device_id *device_list,
452 const char *options,
453 void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data),
454 void *user_data)
455 {
456 return program->cast<Program>().build(num_devices, device_list, options, pfn_notify, user_data);
457 }
458
CompileProgram(cl_program program,cl_uint num_devices,const cl_device_id * device_list,const char * options,cl_uint num_input_headers,const cl_program * input_headers,const char ** header_include_names,void (CL_CALLBACK * pfn_notify)(cl_program program,void * user_data),void * user_data)459 cl_int CompileProgram(cl_program program,
460 cl_uint num_devices,
461 const cl_device_id *device_list,
462 const char *options,
463 cl_uint num_input_headers,
464 const cl_program *input_headers,
465 const char **header_include_names,
466 void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data),
467 void *user_data)
468 {
469 return program->cast<Program>().compile(num_devices, device_list, options, num_input_headers,
470 input_headers, header_include_names, pfn_notify,
471 user_data);
472 }
473
LinkProgram(cl_context context,cl_uint num_devices,const cl_device_id * device_list,const char * options,cl_uint num_input_programs,const cl_program * input_programs,void (CL_CALLBACK * pfn_notify)(cl_program program,void * user_data),void * user_data,cl_int & errorCode)474 cl_program LinkProgram(cl_context context,
475 cl_uint num_devices,
476 const cl_device_id *device_list,
477 const char *options,
478 cl_uint num_input_programs,
479 const cl_program *input_programs,
480 void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data),
481 void *user_data,
482 cl_int &errorCode)
483 {
484 return context->cast<Context>().linkProgram(num_devices, device_list, options,
485 num_input_programs, input_programs, pfn_notify,
486 user_data, errorCode);
487 }
488
SetProgramReleaseCallback(cl_program program,void (CL_CALLBACK * pfn_notify)(cl_program program,void * user_data),void * user_data)489 cl_int SetProgramReleaseCallback(cl_program program,
490 void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data),
491 void *user_data)
492 {
493 WARN_NOT_SUPPORTED(SetProgramReleaseCallback);
494 return 0;
495 }
496
SetProgramSpecializationConstant(cl_program program,cl_uint spec_id,size_t spec_size,const void * spec_value)497 cl_int SetProgramSpecializationConstant(cl_program program,
498 cl_uint spec_id,
499 size_t spec_size,
500 const void *spec_value)
501 {
502 WARN_NOT_SUPPORTED(SetProgramSpecializationConstant);
503 return 0;
504 }
505
UnloadPlatformCompiler(cl_platform_id platform)506 cl_int UnloadPlatformCompiler(cl_platform_id platform)
507 {
508 return platform->cast<Platform>().unloadCompiler();
509 }
510
GetProgramInfo(cl_program program,ProgramInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)511 cl_int GetProgramInfo(cl_program program,
512 ProgramInfo param_name,
513 size_t param_value_size,
514 void *param_value,
515 size_t *param_value_size_ret)
516 {
517 return program->cast<Program>().getInfo(param_name, param_value_size, param_value,
518 param_value_size_ret);
519 }
520
GetProgramBuildInfo(cl_program program,cl_device_id device,ProgramBuildInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)521 cl_int GetProgramBuildInfo(cl_program program,
522 cl_device_id device,
523 ProgramBuildInfo param_name,
524 size_t param_value_size,
525 void *param_value,
526 size_t *param_value_size_ret)
527 {
528 return program->cast<Program>().getBuildInfo(device, param_name, param_value_size, param_value,
529 param_value_size_ret);
530 }
531
CreateKernel(cl_program program,const char * kernel_name,cl_int & errorCode)532 cl_kernel CreateKernel(cl_program program, const char *kernel_name, cl_int &errorCode)
533 {
534 return program->cast<Program>().createKernel(kernel_name, errorCode);
535 }
536
CreateKernelsInProgram(cl_program program,cl_uint num_kernels,cl_kernel * kernels,cl_uint * num_kernels_ret)537 cl_int CreateKernelsInProgram(cl_program program,
538 cl_uint num_kernels,
539 cl_kernel *kernels,
540 cl_uint *num_kernels_ret)
541 {
542 return program->cast<Program>().createKernels(num_kernels, kernels, num_kernels_ret);
543 }
544
CloneKernel(cl_kernel source_kernel,cl_int & errorCode)545 cl_kernel CloneKernel(cl_kernel source_kernel, cl_int &errorCode)
546 {
547 WARN_NOT_SUPPORTED(CloneKernel);
548 return 0;
549 }
550
RetainKernel(cl_kernel kernel)551 cl_int RetainKernel(cl_kernel kernel)
552 {
553 kernel->cast<Kernel>().retain();
554 return CL_SUCCESS;
555 }
556
ReleaseKernel(cl_kernel kernel)557 cl_int ReleaseKernel(cl_kernel kernel)
558 {
559 Kernel &krnl = kernel->cast<Kernel>();
560 if (krnl.release())
561 {
562 delete &krnl;
563 }
564 return CL_SUCCESS;
565 }
566
SetKernelArg(cl_kernel kernel,cl_uint arg_index,size_t arg_size,const void * arg_value)567 cl_int SetKernelArg(cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value)
568 {
569 return kernel->cast<Kernel>().setArg(arg_index, arg_size, arg_value);
570 }
571
SetKernelArgSVMPointer(cl_kernel kernel,cl_uint arg_index,const void * arg_value)572 cl_int SetKernelArgSVMPointer(cl_kernel kernel, cl_uint arg_index, const void *arg_value)
573 {
574 WARN_NOT_SUPPORTED(SetKernelArgSVMPointer);
575 return 0;
576 }
577
SetKernelExecInfo(cl_kernel kernel,KernelExecInfo param_name,size_t param_value_size,const void * param_value)578 cl_int SetKernelExecInfo(cl_kernel kernel,
579 KernelExecInfo param_name,
580 size_t param_value_size,
581 const void *param_value)
582 {
583 WARN_NOT_SUPPORTED(SetKernelExecInfo);
584 return 0;
585 }
586
GetKernelInfo(cl_kernel kernel,KernelInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)587 cl_int GetKernelInfo(cl_kernel kernel,
588 KernelInfo param_name,
589 size_t param_value_size,
590 void *param_value,
591 size_t *param_value_size_ret)
592 {
593 return kernel->cast<Kernel>().getInfo(param_name, param_value_size, param_value,
594 param_value_size_ret);
595 }
596
GetKernelArgInfo(cl_kernel kernel,cl_uint arg_index,KernelArgInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)597 cl_int GetKernelArgInfo(cl_kernel kernel,
598 cl_uint arg_index,
599 KernelArgInfo param_name,
600 size_t param_value_size,
601 void *param_value,
602 size_t *param_value_size_ret)
603 {
604 return kernel->cast<Kernel>().getArgInfo(arg_index, param_name, param_value_size, param_value,
605 param_value_size_ret);
606 }
607
GetKernelWorkGroupInfo(cl_kernel kernel,cl_device_id device,KernelWorkGroupInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)608 cl_int GetKernelWorkGroupInfo(cl_kernel kernel,
609 cl_device_id device,
610 KernelWorkGroupInfo param_name,
611 size_t param_value_size,
612 void *param_value,
613 size_t *param_value_size_ret)
614 {
615 return kernel->cast<Kernel>().getWorkGroupInfo(device, param_name, param_value_size,
616 param_value, param_value_size_ret);
617 }
618
GetKernelSubGroupInfo(cl_kernel kernel,cl_device_id device,KernelSubGroupInfo param_name,size_t input_value_size,const void * input_value,size_t param_value_size,void * param_value,size_t * param_value_size_ret)619 cl_int GetKernelSubGroupInfo(cl_kernel kernel,
620 cl_device_id device,
621 KernelSubGroupInfo param_name,
622 size_t input_value_size,
623 const void *input_value,
624 size_t param_value_size,
625 void *param_value,
626 size_t *param_value_size_ret)
627 {
628 WARN_NOT_SUPPORTED(GetKernelSubGroupInfo);
629 return 0;
630 }
631
WaitForEvents(cl_uint num_events,const cl_event * event_list)632 cl_int WaitForEvents(cl_uint num_events, const cl_event *event_list)
633 {
634 return (*event_list)->cast<Event>().getContext().waitForEvents(num_events, event_list);
635 }
636
GetEventInfo(cl_event event,EventInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)637 cl_int GetEventInfo(cl_event event,
638 EventInfo param_name,
639 size_t param_value_size,
640 void *param_value,
641 size_t *param_value_size_ret)
642 {
643 return event->cast<Event>().getInfo(param_name, param_value_size, param_value,
644 param_value_size_ret);
645 }
646
CreateUserEvent(cl_context context,cl_int & errorCode)647 cl_event CreateUserEvent(cl_context context, cl_int &errorCode)
648 {
649 return context->cast<Context>().createUserEvent(errorCode);
650 }
651
RetainEvent(cl_event event)652 cl_int RetainEvent(cl_event event)
653 {
654 event->cast<Event>().retain();
655 return CL_SUCCESS;
656 }
657
ReleaseEvent(cl_event event)658 cl_int ReleaseEvent(cl_event event)
659 {
660 Event &evt = event->cast<Event>();
661 if (evt.release())
662 {
663 delete &evt;
664 }
665 return CL_SUCCESS;
666 }
667
SetUserEventStatus(cl_event event,cl_int execution_status)668 cl_int SetUserEventStatus(cl_event event, cl_int execution_status)
669 {
670 return event->cast<Event>().setUserEventStatus(execution_status);
671 }
672
SetEventCallback(cl_event event,cl_int command_exec_callback_type,void (CL_CALLBACK * pfn_notify)(cl_event event,cl_int event_command_status,void * user_data),void * user_data)673 cl_int SetEventCallback(cl_event event,
674 cl_int command_exec_callback_type,
675 void(CL_CALLBACK *pfn_notify)(cl_event event,
676 cl_int event_command_status,
677 void *user_data),
678 void *user_data)
679 {
680 return event->cast<Event>().setCallback(command_exec_callback_type, pfn_notify, user_data);
681 }
682
GetEventProfilingInfo(cl_event event,ProfilingInfo param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)683 cl_int GetEventProfilingInfo(cl_event event,
684 ProfilingInfo param_name,
685 size_t param_value_size,
686 void *param_value,
687 size_t *param_value_size_ret)
688 {
689 return event->cast<Event>().getProfilingInfo(param_name, param_value_size, param_value,
690 param_value_size_ret);
691 }
692
Flush(cl_command_queue command_queue)693 cl_int Flush(cl_command_queue command_queue)
694 {
695 return command_queue->cast<CommandQueue>().flush();
696 }
697
Finish(cl_command_queue command_queue)698 cl_int Finish(cl_command_queue command_queue)
699 {
700 return command_queue->cast<CommandQueue>().finish();
701 }
702
EnqueueReadBuffer(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_read,size_t offset,size_t size,void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)703 cl_int EnqueueReadBuffer(cl_command_queue command_queue,
704 cl_mem buffer,
705 cl_bool blocking_read,
706 size_t offset,
707 size_t size,
708 void *ptr,
709 cl_uint num_events_in_wait_list,
710 const cl_event *event_wait_list,
711 cl_event *event)
712 {
713 return command_queue->cast<CommandQueue>().enqueueReadBuffer(
714 buffer, blocking_read, offset, size, ptr, num_events_in_wait_list, event_wait_list, event);
715 }
716
EnqueueReadBufferRect(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_read,const size_t * buffer_origin,const size_t * host_origin,const size_t * region,size_t buffer_row_pitch,size_t buffer_slice_pitch,size_t host_row_pitch,size_t host_slice_pitch,void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)717 cl_int EnqueueReadBufferRect(cl_command_queue command_queue,
718 cl_mem buffer,
719 cl_bool blocking_read,
720 const size_t *buffer_origin,
721 const size_t *host_origin,
722 const size_t *region,
723 size_t buffer_row_pitch,
724 size_t buffer_slice_pitch,
725 size_t host_row_pitch,
726 size_t host_slice_pitch,
727 void *ptr,
728 cl_uint num_events_in_wait_list,
729 const cl_event *event_wait_list,
730 cl_event *event)
731 {
732 return command_queue->cast<CommandQueue>().enqueueReadBufferRect(
733 buffer, blocking_read, buffer_origin, host_origin, region, buffer_row_pitch,
734 buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events_in_wait_list,
735 event_wait_list, event);
736 }
737
EnqueueWriteBuffer(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_write,size_t offset,size_t size,const void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)738 cl_int EnqueueWriteBuffer(cl_command_queue command_queue,
739 cl_mem buffer,
740 cl_bool blocking_write,
741 size_t offset,
742 size_t size,
743 const void *ptr,
744 cl_uint num_events_in_wait_list,
745 const cl_event *event_wait_list,
746 cl_event *event)
747 {
748 return command_queue->cast<CommandQueue>().enqueueWriteBuffer(
749 buffer, blocking_write, offset, size, ptr, num_events_in_wait_list, event_wait_list, event);
750 }
751
EnqueueWriteBufferRect(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_write,const size_t * buffer_origin,const size_t * host_origin,const size_t * region,size_t buffer_row_pitch,size_t buffer_slice_pitch,size_t host_row_pitch,size_t host_slice_pitch,const void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)752 cl_int EnqueueWriteBufferRect(cl_command_queue command_queue,
753 cl_mem buffer,
754 cl_bool blocking_write,
755 const size_t *buffer_origin,
756 const size_t *host_origin,
757 const size_t *region,
758 size_t buffer_row_pitch,
759 size_t buffer_slice_pitch,
760 size_t host_row_pitch,
761 size_t host_slice_pitch,
762 const void *ptr,
763 cl_uint num_events_in_wait_list,
764 const cl_event *event_wait_list,
765 cl_event *event)
766 {
767 return command_queue->cast<CommandQueue>().enqueueWriteBufferRect(
768 buffer, blocking_write, buffer_origin, host_origin, region, buffer_row_pitch,
769 buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events_in_wait_list,
770 event_wait_list, event);
771 }
772
EnqueueFillBuffer(cl_command_queue command_queue,cl_mem buffer,const void * pattern,size_t pattern_size,size_t offset,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)773 cl_int EnqueueFillBuffer(cl_command_queue command_queue,
774 cl_mem buffer,
775 const void *pattern,
776 size_t pattern_size,
777 size_t offset,
778 size_t size,
779 cl_uint num_events_in_wait_list,
780 const cl_event *event_wait_list,
781 cl_event *event)
782 {
783 return command_queue->cast<CommandQueue>().enqueueFillBuffer(
784 buffer, pattern, pattern_size, offset, size, num_events_in_wait_list, event_wait_list,
785 event);
786 }
787
EnqueueCopyBuffer(cl_command_queue command_queue,cl_mem src_buffer,cl_mem dst_buffer,size_t src_offset,size_t dst_offset,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)788 cl_int EnqueueCopyBuffer(cl_command_queue command_queue,
789 cl_mem src_buffer,
790 cl_mem dst_buffer,
791 size_t src_offset,
792 size_t dst_offset,
793 size_t size,
794 cl_uint num_events_in_wait_list,
795 const cl_event *event_wait_list,
796 cl_event *event)
797 {
798 return command_queue->cast<CommandQueue>().enqueueCopyBuffer(
799 src_buffer, dst_buffer, src_offset, dst_offset, size, num_events_in_wait_list,
800 event_wait_list, event);
801 }
802
EnqueueCopyBufferRect(cl_command_queue command_queue,cl_mem src_buffer,cl_mem dst_buffer,const size_t * src_origin,const size_t * dst_origin,const size_t * region,size_t src_row_pitch,size_t src_slice_pitch,size_t dst_row_pitch,size_t dst_slice_pitch,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)803 cl_int EnqueueCopyBufferRect(cl_command_queue command_queue,
804 cl_mem src_buffer,
805 cl_mem dst_buffer,
806 const size_t *src_origin,
807 const size_t *dst_origin,
808 const size_t *region,
809 size_t src_row_pitch,
810 size_t src_slice_pitch,
811 size_t dst_row_pitch,
812 size_t dst_slice_pitch,
813 cl_uint num_events_in_wait_list,
814 const cl_event *event_wait_list,
815 cl_event *event)
816 {
817 return command_queue->cast<CommandQueue>().enqueueCopyBufferRect(
818 src_buffer, dst_buffer, src_origin, dst_origin, region, src_row_pitch, src_slice_pitch,
819 dst_row_pitch, dst_slice_pitch, num_events_in_wait_list, event_wait_list, event);
820 }
821
EnqueueReadImage(cl_command_queue command_queue,cl_mem image,cl_bool blocking_read,const size_t * origin,const size_t * region,size_t row_pitch,size_t slice_pitch,void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)822 cl_int EnqueueReadImage(cl_command_queue command_queue,
823 cl_mem image,
824 cl_bool blocking_read,
825 const size_t *origin,
826 const size_t *region,
827 size_t row_pitch,
828 size_t slice_pitch,
829 void *ptr,
830 cl_uint num_events_in_wait_list,
831 const cl_event *event_wait_list,
832 cl_event *event)
833 {
834 return command_queue->cast<CommandQueue>().enqueueReadImage(
835 image, blocking_read, origin, region, row_pitch, slice_pitch, ptr, num_events_in_wait_list,
836 event_wait_list, event);
837 }
838
EnqueueWriteImage(cl_command_queue command_queue,cl_mem image,cl_bool blocking_write,const size_t * origin,const size_t * region,size_t input_row_pitch,size_t input_slice_pitch,const void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)839 cl_int EnqueueWriteImage(cl_command_queue command_queue,
840 cl_mem image,
841 cl_bool blocking_write,
842 const size_t *origin,
843 const size_t *region,
844 size_t input_row_pitch,
845 size_t input_slice_pitch,
846 const void *ptr,
847 cl_uint num_events_in_wait_list,
848 const cl_event *event_wait_list,
849 cl_event *event)
850 {
851 return command_queue->cast<CommandQueue>().enqueueWriteImage(
852 image, blocking_write, origin, region, input_row_pitch, input_slice_pitch, ptr,
853 num_events_in_wait_list, event_wait_list, event);
854 }
855
EnqueueFillImage(cl_command_queue command_queue,cl_mem image,const void * fill_color,const size_t * origin,const size_t * region,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)856 cl_int EnqueueFillImage(cl_command_queue command_queue,
857 cl_mem image,
858 const void *fill_color,
859 const size_t *origin,
860 const size_t *region,
861 cl_uint num_events_in_wait_list,
862 const cl_event *event_wait_list,
863 cl_event *event)
864 {
865 return command_queue->cast<CommandQueue>().enqueueFillImage(
866 image, fill_color, origin, region, num_events_in_wait_list, event_wait_list, event);
867 }
868
EnqueueCopyImage(cl_command_queue command_queue,cl_mem src_image,cl_mem dst_image,const size_t * src_origin,const size_t * dst_origin,const size_t * region,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)869 cl_int EnqueueCopyImage(cl_command_queue command_queue,
870 cl_mem src_image,
871 cl_mem dst_image,
872 const size_t *src_origin,
873 const size_t *dst_origin,
874 const size_t *region,
875 cl_uint num_events_in_wait_list,
876 const cl_event *event_wait_list,
877 cl_event *event)
878 {
879 return command_queue->cast<CommandQueue>().enqueueCopyImage(
880 src_image, dst_image, src_origin, dst_origin, region, num_events_in_wait_list,
881 event_wait_list, event);
882 }
883
EnqueueCopyImageToBuffer(cl_command_queue command_queue,cl_mem src_image,cl_mem dst_buffer,const size_t * src_origin,const size_t * region,size_t dst_offset,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)884 cl_int EnqueueCopyImageToBuffer(cl_command_queue command_queue,
885 cl_mem src_image,
886 cl_mem dst_buffer,
887 const size_t *src_origin,
888 const size_t *region,
889 size_t dst_offset,
890 cl_uint num_events_in_wait_list,
891 const cl_event *event_wait_list,
892 cl_event *event)
893 {
894 return command_queue->cast<CommandQueue>().enqueueCopyImageToBuffer(
895 src_image, dst_buffer, src_origin, region, dst_offset, num_events_in_wait_list,
896 event_wait_list, event);
897 }
898
EnqueueCopyBufferToImage(cl_command_queue command_queue,cl_mem src_buffer,cl_mem dst_image,size_t src_offset,const size_t * dst_origin,const size_t * region,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)899 cl_int EnqueueCopyBufferToImage(cl_command_queue command_queue,
900 cl_mem src_buffer,
901 cl_mem dst_image,
902 size_t src_offset,
903 const size_t *dst_origin,
904 const size_t *region,
905 cl_uint num_events_in_wait_list,
906 const cl_event *event_wait_list,
907 cl_event *event)
908 {
909 return command_queue->cast<CommandQueue>().enqueueCopyBufferToImage(
910 src_buffer, dst_image, src_offset, dst_origin, region, num_events_in_wait_list,
911 event_wait_list, event);
912 }
913
EnqueueMapBuffer(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_map,MapFlags map_flags,size_t offset,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event,cl_int & errorCode)914 void *EnqueueMapBuffer(cl_command_queue command_queue,
915 cl_mem buffer,
916 cl_bool blocking_map,
917 MapFlags map_flags,
918 size_t offset,
919 size_t size,
920 cl_uint num_events_in_wait_list,
921 const cl_event *event_wait_list,
922 cl_event *event,
923 cl_int &errorCode)
924 {
925 return command_queue->cast<CommandQueue>().enqueueMapBuffer(
926 buffer, blocking_map, map_flags, offset, size, num_events_in_wait_list, event_wait_list,
927 event, errorCode);
928 }
929
EnqueueMapImage(cl_command_queue command_queue,cl_mem image,cl_bool blocking_map,MapFlags map_flags,const size_t * origin,const size_t * region,size_t * image_row_pitch,size_t * image_slice_pitch,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event,cl_int & errorCode)930 void *EnqueueMapImage(cl_command_queue command_queue,
931 cl_mem image,
932 cl_bool blocking_map,
933 MapFlags map_flags,
934 const size_t *origin,
935 const size_t *region,
936 size_t *image_row_pitch,
937 size_t *image_slice_pitch,
938 cl_uint num_events_in_wait_list,
939 const cl_event *event_wait_list,
940 cl_event *event,
941 cl_int &errorCode)
942 {
943 return command_queue->cast<CommandQueue>().enqueueMapImage(
944 image, blocking_map, map_flags, origin, region, image_row_pitch, image_slice_pitch,
945 num_events_in_wait_list, event_wait_list, event, errorCode);
946 }
947
EnqueueUnmapMemObject(cl_command_queue command_queue,cl_mem memobj,void * mapped_ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)948 cl_int EnqueueUnmapMemObject(cl_command_queue command_queue,
949 cl_mem memobj,
950 void *mapped_ptr,
951 cl_uint num_events_in_wait_list,
952 const cl_event *event_wait_list,
953 cl_event *event)
954 {
955 return command_queue->cast<CommandQueue>().enqueueUnmapMemObject(
956 memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
957 }
958
EnqueueMigrateMemObjects(cl_command_queue command_queue,cl_uint num_mem_objects,const cl_mem * mem_objects,MemMigrationFlags flags,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)959 cl_int EnqueueMigrateMemObjects(cl_command_queue command_queue,
960 cl_uint num_mem_objects,
961 const cl_mem *mem_objects,
962 MemMigrationFlags flags,
963 cl_uint num_events_in_wait_list,
964 const cl_event *event_wait_list,
965 cl_event *event)
966 {
967 return command_queue->cast<CommandQueue>().enqueueMigrateMemObjects(
968 num_mem_objects, mem_objects, flags, num_events_in_wait_list, event_wait_list, event);
969 }
970
EnqueueNDRangeKernel(cl_command_queue command_queue,cl_kernel kernel,cl_uint work_dim,const size_t * global_work_offset,const size_t * global_work_size,const size_t * local_work_size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)971 cl_int EnqueueNDRangeKernel(cl_command_queue command_queue,
972 cl_kernel kernel,
973 cl_uint work_dim,
974 const size_t *global_work_offset,
975 const size_t *global_work_size,
976 const size_t *local_work_size,
977 cl_uint num_events_in_wait_list,
978 const cl_event *event_wait_list,
979 cl_event *event)
980 {
981 return command_queue->cast<CommandQueue>().enqueueNDRangeKernel(
982 kernel, work_dim, global_work_offset, global_work_size, local_work_size,
983 num_events_in_wait_list, event_wait_list, event);
984 }
985
EnqueueNativeKernel(cl_command_queue command_queue,void (CL_CALLBACK * user_func)(void *),void * args,size_t cb_args,cl_uint num_mem_objects,const cl_mem * mem_list,const void ** args_mem_loc,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)986 cl_int EnqueueNativeKernel(cl_command_queue command_queue,
987 void(CL_CALLBACK *user_func)(void *),
988 void *args,
989 size_t cb_args,
990 cl_uint num_mem_objects,
991 const cl_mem *mem_list,
992 const void **args_mem_loc,
993 cl_uint num_events_in_wait_list,
994 const cl_event *event_wait_list,
995 cl_event *event)
996 {
997 return command_queue->cast<CommandQueue>().enqueueNativeKernel(
998 user_func, args, cb_args, num_mem_objects, mem_list, args_mem_loc, num_events_in_wait_list,
999 event_wait_list, event);
1000 }
1001
EnqueueMarkerWithWaitList(cl_command_queue command_queue,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1002 cl_int EnqueueMarkerWithWaitList(cl_command_queue command_queue,
1003 cl_uint num_events_in_wait_list,
1004 const cl_event *event_wait_list,
1005 cl_event *event)
1006 {
1007 return command_queue->cast<CommandQueue>().enqueueMarkerWithWaitList(num_events_in_wait_list,
1008 event_wait_list, event);
1009 }
1010
EnqueueBarrierWithWaitList(cl_command_queue command_queue,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1011 cl_int EnqueueBarrierWithWaitList(cl_command_queue command_queue,
1012 cl_uint num_events_in_wait_list,
1013 const cl_event *event_wait_list,
1014 cl_event *event)
1015 {
1016 return command_queue->cast<CommandQueue>().enqueueBarrierWithWaitList(num_events_in_wait_list,
1017 event_wait_list, event);
1018 }
1019
EnqueueSVMFree(cl_command_queue command_queue,cl_uint num_svm_pointers,void * svm_pointers[],void (CL_CALLBACK * pfn_free_func)(cl_command_queue queue,cl_uint num_svm_pointers,void * svm_pointers[],void * user_data),void * user_data,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1020 cl_int EnqueueSVMFree(cl_command_queue command_queue,
1021 cl_uint num_svm_pointers,
1022 void *svm_pointers[],
1023 void(CL_CALLBACK *pfn_free_func)(cl_command_queue queue,
1024 cl_uint num_svm_pointers,
1025 void *svm_pointers[],
1026 void *user_data),
1027 void *user_data,
1028 cl_uint num_events_in_wait_list,
1029 const cl_event *event_wait_list,
1030 cl_event *event)
1031 {
1032 WARN_NOT_SUPPORTED(EnqueueSVMFree);
1033 return 0;
1034 }
1035
EnqueueSVMMemcpy(cl_command_queue command_queue,cl_bool blocking_copy,void * dst_ptr,const void * src_ptr,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1036 cl_int EnqueueSVMMemcpy(cl_command_queue command_queue,
1037 cl_bool blocking_copy,
1038 void *dst_ptr,
1039 const void *src_ptr,
1040 size_t size,
1041 cl_uint num_events_in_wait_list,
1042 const cl_event *event_wait_list,
1043 cl_event *event)
1044 {
1045 WARN_NOT_SUPPORTED(EnqueueSVMMemcpy);
1046 return 0;
1047 }
1048
EnqueueSVMMemFill(cl_command_queue command_queue,void * svm_ptr,const void * pattern,size_t pattern_size,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1049 cl_int EnqueueSVMMemFill(cl_command_queue command_queue,
1050 void *svm_ptr,
1051 const void *pattern,
1052 size_t pattern_size,
1053 size_t size,
1054 cl_uint num_events_in_wait_list,
1055 const cl_event *event_wait_list,
1056 cl_event *event)
1057 {
1058 WARN_NOT_SUPPORTED(EnqueueSVMMemFill);
1059 return 0;
1060 }
1061
EnqueueSVMMap(cl_command_queue command_queue,cl_bool blocking_map,MapFlags flags,void * svm_ptr,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1062 cl_int EnqueueSVMMap(cl_command_queue command_queue,
1063 cl_bool blocking_map,
1064 MapFlags flags,
1065 void *svm_ptr,
1066 size_t size,
1067 cl_uint num_events_in_wait_list,
1068 const cl_event *event_wait_list,
1069 cl_event *event)
1070 {
1071 WARN_NOT_SUPPORTED(EnqueueSVMMap);
1072 return 0;
1073 }
1074
EnqueueSVMUnmap(cl_command_queue command_queue,void * svm_ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1075 cl_int EnqueueSVMUnmap(cl_command_queue command_queue,
1076 void *svm_ptr,
1077 cl_uint num_events_in_wait_list,
1078 const cl_event *event_wait_list,
1079 cl_event *event)
1080 {
1081 WARN_NOT_SUPPORTED(EnqueueSVMUnmap);
1082 return 0;
1083 }
1084
EnqueueSVMMigrateMem(cl_command_queue command_queue,cl_uint num_svm_pointers,const void ** svm_pointers,const size_t * sizes,MemMigrationFlags flags,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1085 cl_int EnqueueSVMMigrateMem(cl_command_queue command_queue,
1086 cl_uint num_svm_pointers,
1087 const void **svm_pointers,
1088 const size_t *sizes,
1089 MemMigrationFlags flags,
1090 cl_uint num_events_in_wait_list,
1091 const cl_event *event_wait_list,
1092 cl_event *event)
1093 {
1094 WARN_NOT_SUPPORTED(EnqueueSVMMigrateMem);
1095 return 0;
1096 }
1097
GetExtensionFunctionAddressForPlatform(cl_platform_id platform,const char * func_name)1098 void *GetExtensionFunctionAddressForPlatform(cl_platform_id platform, const char *func_name)
1099 {
1100 return GetExtensionFunctionAddress(func_name);
1101 }
1102
SetCommandQueueProperty(cl_command_queue command_queue,CommandQueueProperties properties,cl_bool enable,cl_command_queue_properties * old_properties)1103 cl_int SetCommandQueueProperty(cl_command_queue command_queue,
1104 CommandQueueProperties properties,
1105 cl_bool enable,
1106 cl_command_queue_properties *old_properties)
1107 {
1108 return command_queue->cast<CommandQueue>().setProperty(properties, enable, old_properties);
1109 }
1110
CreateImage2D(cl_context context,MemFlags flags,const cl_image_format * image_format,size_t image_width,size_t image_height,size_t image_row_pitch,void * host_ptr,cl_int & errorCode)1111 cl_mem CreateImage2D(cl_context context,
1112 MemFlags flags,
1113 const cl_image_format *image_format,
1114 size_t image_width,
1115 size_t image_height,
1116 size_t image_row_pitch,
1117 void *host_ptr,
1118 cl_int &errorCode)
1119 {
1120 return context->cast<Context>().createImage2D(flags, image_format, image_width, image_height,
1121 image_row_pitch, host_ptr, errorCode);
1122 }
1123
CreateImage3D(cl_context context,MemFlags flags,const cl_image_format * image_format,size_t image_width,size_t image_height,size_t image_depth,size_t image_row_pitch,size_t image_slice_pitch,void * host_ptr,cl_int & errorCode)1124 cl_mem CreateImage3D(cl_context context,
1125 MemFlags flags,
1126 const cl_image_format *image_format,
1127 size_t image_width,
1128 size_t image_height,
1129 size_t image_depth,
1130 size_t image_row_pitch,
1131 size_t image_slice_pitch,
1132 void *host_ptr,
1133 cl_int &errorCode)
1134 {
1135 return context->cast<Context>().createImage3D(flags, image_format, image_width, image_height,
1136 image_depth, image_row_pitch, image_slice_pitch,
1137 host_ptr, errorCode);
1138 }
1139
EnqueueMarker(cl_command_queue command_queue,cl_event * event)1140 cl_int EnqueueMarker(cl_command_queue command_queue, cl_event *event)
1141 {
1142 return command_queue->cast<CommandQueue>().enqueueMarker(event);
1143 }
1144
EnqueueWaitForEvents(cl_command_queue command_queue,cl_uint num_events,const cl_event * event_list)1145 cl_int EnqueueWaitForEvents(cl_command_queue command_queue,
1146 cl_uint num_events,
1147 const cl_event *event_list)
1148 {
1149 return command_queue->cast<CommandQueue>().enqueueWaitForEvents(num_events, event_list);
1150 }
1151
EnqueueBarrier(cl_command_queue command_queue)1152 cl_int EnqueueBarrier(cl_command_queue command_queue)
1153 {
1154 return command_queue->cast<CommandQueue>().enqueueBarrier();
1155 }
1156
UnloadCompiler()1157 cl_int UnloadCompiler()
1158 {
1159 Platform *const platform = Platform::GetDefault();
1160 return platform != nullptr ? platform->unloadCompiler() : CL_SUCCESS;
1161 }
1162
GetExtensionFunctionAddress(const char * func_name)1163 void *GetExtensionFunctionAddress(const char *func_name)
1164 {
1165 if (func_name == nullptr)
1166 {
1167 return nullptr;
1168 }
1169 const ProcTable &procTable = GetProcTable();
1170 const auto it = procTable.find(func_name);
1171 return it != procTable.cend() ? it->second : nullptr;
1172 }
1173
CreateCommandQueue(cl_context context,cl_device_id device,CommandQueueProperties properties,cl_int & errorCode)1174 cl_command_queue CreateCommandQueue(cl_context context,
1175 cl_device_id device,
1176 CommandQueueProperties properties,
1177 cl_int &errorCode)
1178 {
1179 return context->cast<Context>().createCommandQueue(device, properties, errorCode);
1180 }
1181
CreateSampler(cl_context context,cl_bool normalized_coords,AddressingMode addressing_mode,FilterMode filter_mode,cl_int & errorCode)1182 cl_sampler CreateSampler(cl_context context,
1183 cl_bool normalized_coords,
1184 AddressingMode addressing_mode,
1185 FilterMode filter_mode,
1186 cl_int &errorCode)
1187 {
1188 return context->cast<Context>().createSampler(normalized_coords, addressing_mode, filter_mode,
1189 errorCode);
1190 }
1191
EnqueueTask(cl_command_queue command_queue,cl_kernel kernel,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1192 cl_int EnqueueTask(cl_command_queue command_queue,
1193 cl_kernel kernel,
1194 cl_uint num_events_in_wait_list,
1195 const cl_event *event_wait_list,
1196 cl_event *event)
1197 {
1198 return command_queue->cast<CommandQueue>().enqueueTask(kernel, num_events_in_wait_list,
1199 event_wait_list, event);
1200 }
1201
1202 } // namespace cl
1203