xref: /aosp_15_r20/external/OpenCL-ICD-Loader/test/driver_stub/cl.c (revision 1cddb830dba8aa7c1cc1039338e56b3b9fa24952)
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 
5 #ifndef CL_USE_DEPRECATED_OPENCL_1_0_APIS
6 #define CL_USE_DEPRECATED_OPENCL_1_0_APIS
7 #endif
8 
9 #ifndef CL_USE_DEPRECATED_OPENCL_1_1_APIS
10 #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
11 #endif
12 
13 // Need to rename all CL API functions to prevent ICD loader functions calling
14 // themselves via the dispatch table. Include this before cl headers.
15 #include "rename_api.h"
16 
17 #include <CL/cl.h>
18 #include <platform/icd_test_log.h>
19 #include "icd_structs.h"
20 
21 #define CL_PLATFORM_ICD_SUFFIX_KHR                  0x0920
22 CL_API_ENTRY cl_int CL_API_CALL
23 clIcdGetPlatformIDsKHR(cl_uint, cl_platform_id *, cl_uint *);
24 
25 struct _cl_platform_id
26 {
27     CLIicdDispatchTable* dispatch;
28     const char *profile;
29     const char *version;
30     const char *name;
31     const char *vendor;
32     const char *extensions;
33     const char *suffix;
34 };
35 
36 struct _cl_device_id
37 {
38     CLIicdDispatchTable* dispatch;
39 };
40 
41 struct _cl_context
42 {
43     CLIicdDispatchTable* dispatch;
44 };
45 
46 struct _cl_command_queue
47 {
48     CLIicdDispatchTable* dispatch;
49 };
50 
51 struct _cl_mem
52 {
53     CLIicdDispatchTable* dispatch;
54 };
55 
56 struct _cl_program
57 {
58     CLIicdDispatchTable* dispatch;
59 };
60 
61 struct _cl_kernel
62 {
63     CLIicdDispatchTable* dispatch;
64 };
65 
66 struct _cl_event
67 {
68     CLIicdDispatchTable* dispatch;
69 };
70 
71 struct _cl_sampler
72 {
73     CLIicdDispatchTable* dispatch;
74 };
75 
76 static CLIicdDispatchTable* dispatchTable = NULL;
77 static cl_platform_id platform = NULL;
78 static cl_bool initialized = CL_FALSE;
79 
80 CL_API_ENTRY cl_int CL_API_CALL
clGetPlatformIDs(cl_uint num_entries,cl_platform_id * platforms,cl_uint * num_platforms)81 clGetPlatformIDs(cl_uint           num_entries ,
82                  cl_platform_id *  platforms ,
83                  cl_uint *         num_platforms) CL_API_SUFFIX__VERSION_1_0
84 {
85     cl_int return_value = CL_OUT_OF_RESOURCES;
86     test_icd_stub_log("clGetPlatformIDs(%u, %p, %p)\n",
87                       num_entries,
88                       platforms,
89                       num_platforms);
90     return_value = clIcdGetPlatformIDsKHR(num_entries, platforms, num_platforms);
91     test_icd_stub_log("Value returned: %d\n", return_value);
92     return return_value;
93 }
94 
95 CL_API_ENTRY cl_int CL_API_CALL
clGetPlatformInfo(cl_platform_id platform,cl_platform_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)96 clGetPlatformInfo(cl_platform_id    platform,
97                   cl_platform_info  param_name,
98                   size_t            param_value_size,
99                   void *            param_value,
100                   size_t *          param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
101 {
102     cl_int ret = CL_SUCCESS;
103     const char *returnString = NULL;
104     size_t returnStringLength = 0;
105     /*test_icd_stub_log("clGetPlatformInfo(%p, %u, %u, %p, %p)\n",
106                       platform,
107                       param_name,
108                       param_value_size,
109                       param_value,
110                       param_value_size_ret);*/
111 
112     // validate the arguments
113     if (param_value_size == 0 && param_value != NULL) {
114         ret = CL_INVALID_VALUE;
115         goto done;
116     }
117     // select the string to return
118     switch(param_name) {
119         case CL_PLATFORM_PROFILE:
120             returnString = platform->profile;
121             break;
122         case CL_PLATFORM_VERSION:
123             returnString = platform->version;
124             break;
125         case CL_PLATFORM_NAME:
126             returnString = platform->name;
127             break;
128         case CL_PLATFORM_VENDOR:
129             returnString = platform->vendor;
130             break;
131         case CL_PLATFORM_EXTENSIONS:
132             returnString = platform->extensions;
133             break;
134         case CL_PLATFORM_ICD_SUFFIX_KHR:
135             returnString = platform->suffix;
136             break;
137         default:
138             ret = CL_INVALID_VALUE;
139             goto done;
140     }
141 
142     // make sure the buffer passed in is big enough for the result
143     returnStringLength = strlen(returnString)+1;
144     if (param_value_size && param_value_size < returnStringLength) {
145         ret = CL_INVALID_VALUE;
146         goto done;
147     }
148 
149     // pass the data back to the user
150     if (param_value) {
151         memcpy(param_value, returnString, returnStringLength);
152     }
153     if (param_value_size_ret) {
154         *param_value_size_ret = returnStringLength;
155     }
156 
157 done:
158     /*test_icd_stub_log("Value returned: %d\n",
159                       return_value);*/
160     return ret;
161 }
162 
163 
164 /* Device APIs */
165 CL_API_ENTRY cl_int CL_API_CALL
clGetDeviceIDs(cl_platform_id platform,cl_device_type device_type,cl_uint num_entries,cl_device_id * devices,cl_uint * num_devices)166 clGetDeviceIDs(cl_platform_id   platform,
167                cl_device_type   device_type,
168                cl_uint          num_entries,
169                cl_device_id *   devices,
170                cl_uint *        num_devices) CL_API_SUFFIX__VERSION_1_0
171 {
172     cl_int ret = CL_SUCCESS;
173 
174     if ((num_entries > 1) && devices != NULL) {
175         ret = CL_INVALID_VALUE;
176         goto done;
177     }
178 
179     if (devices != NULL) {
180         cl_device_id obj = (cl_device_id) malloc(sizeof(*obj));
181         obj->dispatch = dispatchTable;
182         devices[0] = obj;
183     }
184     if (num_devices) {
185         *num_devices = 1;
186     }
187 
188 done:
189     test_icd_stub_log("clGetDeviceIDs(%p, %x, %u, %p, %p)\n",
190                       platform,
191                       device_type,
192                       num_entries,
193                       devices,
194                       num_devices);
195     test_icd_stub_log("Value returned: %d\n", ret);
196     return ret;
197 }
198 
199 
200 
201 CL_API_ENTRY cl_int CL_API_CALL
clGetDeviceInfo(cl_device_id device,cl_device_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)202 clGetDeviceInfo(cl_device_id    device,
203                 cl_device_info  param_name,
204                 size_t          param_value_size,
205                 void *          param_value,
206                 size_t *        param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
207 {
208     cl_int return_value = CL_OUT_OF_RESOURCES;
209     test_icd_stub_log("clGetDeviceInfo(%p, %u, %u, %p, %p)\n",
210                       device,
211                       param_name,
212                       param_value_size,
213                       param_value,
214                       param_value_size_ret);
215 
216     test_icd_stub_log("Value returned: %d\n", return_value);
217     return return_value;
218 }
219 
220 CL_API_ENTRY cl_int CL_API_CALL
clCreateSubDevices(cl_device_id in_device,const cl_device_partition_property * properties,cl_uint num_entries,cl_device_id * out_devices,cl_uint * num_devices)221 clCreateSubDevices(cl_device_id in_device,
222                    const cl_device_partition_property *properties,
223                    cl_uint num_entries,
224                    cl_device_id *out_devices,
225                    cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_2
226 {
227 
228     cl_int return_value = CL_OUT_OF_RESOURCES;
229 
230     test_icd_stub_log("clCreateSubDevices(%p, %p, %u, %p, %p)\n",
231                       in_device,
232                       properties,
233                       num_entries,
234                       out_devices,
235                       num_devices);
236     test_icd_stub_log("Value returned: %d\n", return_value);
237     return return_value;
238 }
239 
240 
241 CL_API_ENTRY cl_int CL_API_CALL
clRetainDevice(cl_device_id device)242 clRetainDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2
243 {
244     cl_int return_value = CL_OUT_OF_RESOURCES;
245     test_icd_stub_log("clRetainDevice(%p)\n", device);
246     test_icd_stub_log("Value returned: %d\n", return_value);
247     return return_value;
248 }
249 
250 
251 CL_API_ENTRY cl_int CL_API_CALL
clReleaseDevice(cl_device_id device)252 clReleaseDevice(cl_device_id device) CL_API_SUFFIX__VERSION_1_2
253 
254 {
255     cl_int return_value = CL_OUT_OF_RESOURCES;
256     test_icd_stub_log("clReleaseDevice(%p)\n", device);
257     test_icd_stub_log("Value returned: %d\n", return_value);
258     return return_value;
259 }
260 
261 
262 /* Context APIs  */
263 CL_API_ENTRY cl_context CL_API_CALL
clCreateContext(const cl_context_properties * properties,cl_uint num_devices,const cl_device_id * devices,void (CL_CALLBACK * pfn_notify)(const char *,const void *,size_t,void *),void * user_data,cl_int * errcode_ret)264 clCreateContext(const cl_context_properties * properties,
265                 cl_uint                       num_devices ,
266                 const cl_device_id *          devices,
267                 void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *),
268                 void *                        user_data,
269                 cl_int *                      errcode_ret) CL_API_SUFFIX__VERSION_1_0
270 {
271     cl_context obj = (cl_context) malloc(sizeof(struct _cl_context));
272     obj->dispatch = dispatchTable;
273     test_icd_stub_log("clCreateContext(%p, %u, %p, %p, %p, %p)\n",
274                       properties,
275                       num_devices,
276                       devices,
277                       pfn_notify,
278                       user_data,
279                       errcode_ret);
280     pfn_notify(NULL, NULL, 0, NULL);
281     test_icd_stub_log("createcontext_callback(%p, %p, %u, %p)\n",
282                       NULL,
283                       NULL,
284                       0,
285                       NULL);
286 
287     test_icd_stub_log("Value returned: %p\n", obj);
288     return obj;
289 }
290 
291 
292 CL_API_ENTRY cl_context CL_API_CALL
clCreateContextFromType(const cl_context_properties * properties,cl_device_type device_type,void (CL_CALLBACK * pfn_notify)(const char *,const void *,size_t,void *),void * user_data,cl_int * errcode_ret)293 clCreateContextFromType(const cl_context_properties * properties,
294                         cl_device_type                device_type,
295                         void (CL_CALLBACK *     pfn_notify)(const char *, const void *, size_t, void *),
296                         void *                        user_data,
297                         cl_int *                      errcode_ret) CL_API_SUFFIX__VERSION_1_0
298 {
299     cl_context obj = (cl_context) malloc(sizeof(struct _cl_context));
300     obj->dispatch = dispatchTable;
301     test_icd_stub_log("clCreateContextFromType(%p, %x, %p, %p, %p)\n",
302                       properties,
303                       device_type,
304                       pfn_notify,
305                       user_data,
306                       errcode_ret);
307     pfn_notify(NULL, NULL, 0, NULL);
308 
309     test_icd_stub_log ("createcontext_callback(%p, %p, %u, %p)\n",
310                        NULL,
311                        NULL,
312                        0,
313                        NULL);
314 
315     test_icd_stub_log("Value returned: %p\n",
316 		              obj);
317     return obj;
318 }
319 
320 CL_API_ENTRY cl_int CL_API_CALL
clRetainContext(cl_context context)321 clRetainContext(cl_context context) CL_API_SUFFIX__VERSION_1_0
322 {
323     cl_int return_value = CL_OUT_OF_RESOURCES;
324     test_icd_stub_log("clRetainContext(%p)\n", context);
325     test_icd_stub_log("Value returned: %d\n", return_value);
326     return return_value;
327 }
328 
329 CL_API_ENTRY cl_int CL_API_CALL
clReleaseContext(cl_context context)330 clReleaseContext(cl_context context) CL_API_SUFFIX__VERSION_1_0
331 {
332     cl_int return_value = CL_OUT_OF_RESOURCES;
333     test_icd_stub_log("clReleaseContext(%p)\n", context);
334     free(context);
335     test_icd_stub_log("Value returned: %d\n", return_value);
336     return return_value;
337 }
338 
339 CL_API_ENTRY cl_int CL_API_CALL
clGetContextInfo(cl_context context,cl_context_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)340 clGetContextInfo(cl_context         context,
341                  cl_context_info    param_name,
342                  size_t             param_value_size,
343                  void *             param_value,
344                  size_t *           param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
345 {
346     cl_int return_value = CL_OUT_OF_RESOURCES;
347     test_icd_stub_log("clGetContextInfo(%p, %u, %u, %p, %p)\n",
348                       context,
349                       param_name,
350                       param_value_size,
351                       param_value,
352                       param_value_size_ret);
353 
354     test_icd_stub_log("Value returned: %d\n", return_value);
355     return return_value;
356 }
357 
358 CL_API_ENTRY cl_int CL_API_CALL
clSetContextDestructorCallback(cl_context context,void (CL_CALLBACK * pfn_notify)(cl_context context,void * user_data),void * user_data)359 clSetContextDestructorCallback(cl_context         context,
360                                void (CL_CALLBACK* pfn_notify)(cl_context context,
361                                                               void* user_data),
362                                void*              user_data) CL_API_SUFFIX__VERSION_3_0
363 {
364     cl_int return_value = CL_OUT_OF_RESOURCES;
365     test_icd_stub_log("clSetContextDestructorCallback(%p, %p, %p)\n",
366                       context,
367                       pfn_notify,
368                       user_data);
369     pfn_notify(context, user_data);
370     test_icd_stub_log("setcontextdestructor_callback(%p, %p)\n",
371                context,
372                user_data);
373 
374     test_icd_stub_log("Value returned: %d\n", return_value);
375     return return_value;
376 }
377 
378 /* Command Queue APIs */
379 CL_API_ENTRY cl_command_queue CL_API_CALL
clCreateCommandQueue(cl_context context,cl_device_id device,cl_command_queue_properties properties,cl_int * errcode_ret)380 clCreateCommandQueue(cl_context                     context,
381                      cl_device_id                   device,
382                      cl_command_queue_properties    properties,
383                      cl_int *                       errcode_ret) CL_API_SUFFIX__VERSION_1_0
384 {
385     cl_command_queue obj = (cl_command_queue) malloc(sizeof(struct _cl_command_queue));
386     obj->dispatch = dispatchTable;
387     test_icd_stub_log("clCreateCommandQueue(%p, %p, %x, %p)\n",
388                       context,
389                       device,
390                       properties,
391                       errcode_ret);
392 
393     test_icd_stub_log("Value returned: %p\n", obj);
394     return obj;
395 }
396 
397 CL_API_ENTRY cl_int CL_API_CALL
clSetCommandQueueProperty(cl_command_queue command_queue,cl_command_queue_properties properties,cl_bool enable,cl_command_queue_properties * old_properties)398 clSetCommandQueueProperty(cl_command_queue               command_queue ,
399                             cl_command_queue_properties    properties ,
400                             cl_bool                        enable ,
401                             cl_command_queue_properties *  old_properties) CL_API_SUFFIX__VERSION_1_0_DEPRECATED
402 {
403     cl_int return_value = CL_OUT_OF_RESOURCES;
404     test_icd_stub_log("clSetCommandQueueProperty(%p, %p, %u, %p)\n",
405                       command_queue,
406                       properties,
407                       enable,
408                       old_properties);
409 
410     test_icd_stub_log("Value returned: %d\n", return_value);
411     return return_value;
412 }
413 
414 CL_API_ENTRY cl_int CL_API_CALL
clRetainCommandQueue(cl_command_queue command_queue)415 clRetainCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0
416 {
417     cl_int return_value = CL_OUT_OF_RESOURCES;
418     test_icd_stub_log("clRetainCommandQueue(%p)\n", command_queue);
419     test_icd_stub_log("Value returned: %d\n", return_value);
420     return return_value;
421 }
422 
423 CL_API_ENTRY cl_int CL_API_CALL
clReleaseCommandQueue(cl_command_queue command_queue)424 clReleaseCommandQueue(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0
425 {
426     cl_int return_value = CL_OUT_OF_RESOURCES;
427     test_icd_stub_log("clReleaseCommandQueue(%p)\n", command_queue);
428     free(command_queue);
429     test_icd_stub_log("Value returned: %d\n", return_value);
430     return return_value;
431 }
432 
433 CL_API_ENTRY cl_int CL_API_CALL
clGetCommandQueueInfo(cl_command_queue command_queue,cl_command_queue_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)434 clGetCommandQueueInfo(cl_command_queue       command_queue ,
435                       cl_command_queue_info  param_name ,
436                       size_t                 param_value_size ,
437                       void *                 param_value ,
438                       size_t *               param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
439 {
440     cl_int return_value = CL_OUT_OF_RESOURCES;
441     test_icd_stub_log("clGetCommandQueueInfo(%p, %u, %u, %p, %p)\n",
442                       command_queue,
443                       param_name,
444                       param_value_size,
445                       param_value,
446                       param_value_size_ret);
447 
448     test_icd_stub_log("Value returned: %d\n", return_value);
449     return return_value;
450 }
451 
452 
453 
454 /* Memory Object APIs */
455 CL_API_ENTRY cl_mem CL_API_CALL
clCreateBuffer(cl_context context,cl_mem_flags flags,size_t size,void * host_ptr,cl_int * errcode_ret)456 clCreateBuffer(cl_context    context ,
457                cl_mem_flags  flags ,
458                size_t        size ,
459                void *        host_ptr ,
460                cl_int *      errcode_ret) CL_API_SUFFIX__VERSION_1_0
461 {
462     cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem));
463     obj->dispatch = dispatchTable;
464     test_icd_stub_log("clCreateBuffer(%p, %x, %u, %p, %p)\n",
465                       context,
466                       flags,
467                       size,
468                       host_ptr,
469                       errcode_ret);
470 
471     test_icd_stub_log("Value returned: %p\n", obj);
472     return obj;
473 }
474 
475 CL_API_ENTRY cl_mem CL_API_CALL
clCreateSubBuffer(cl_mem buffer,cl_mem_flags flags,cl_buffer_create_type buffer_create_type,const void * buffer_create_info,cl_int * errcode_ret)476 clCreateSubBuffer(cl_mem                    buffer ,
477                   cl_mem_flags              flags ,
478                   cl_buffer_create_type     buffer_create_type ,
479                   const void *              buffer_create_info ,
480                   cl_int *                  errcode_ret) CL_API_SUFFIX__VERSION_1_1
481 {
482     cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem));
483     obj->dispatch = dispatchTable;
484     test_icd_stub_log("clCreateSubBuffer(%p, %x, %u, %p, %p)\n",
485                       buffer,
486                       flags,
487                       buffer_create_type,
488                       buffer_create_info,
489                       errcode_ret);
490 
491     test_icd_stub_log("Value returned: %p\n", obj);
492     return obj;
493 }
494 
495 CL_API_ENTRY cl_mem CL_API_CALL
clCreateImage(cl_context context,cl_mem_flags flags,const cl_image_format * image_format,const cl_image_desc * image_desc,void * host_ptr,cl_int * errcode_ret)496 clCreateImage(cl_context              context,
497                             cl_mem_flags            flags,
498                             const cl_image_format * image_format,
499                             const cl_image_desc *   image_desc,
500                             void *                  host_ptr,
501                             cl_int *                errcode_ret) CL_API_SUFFIX__VERSION_1_2
502 {
503     cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem));
504     obj->dispatch = dispatchTable;
505     test_icd_stub_log("clCreateImage(%p, %x, %p, %p, %p, %p)\n",
506                       context,
507                       flags,
508                       image_format,
509                       image_desc,
510                       host_ptr,
511                       errcode_ret);
512 
513     test_icd_stub_log("Value returned: %p\n", obj);
514     return obj;
515 }
516 
517 
518 CL_API_ENTRY cl_mem CL_API_CALL
clCreateImage2D(cl_context context,cl_mem_flags 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 * errcode_ret)519 clCreateImage2D(cl_context              context ,
520                 cl_mem_flags            flags ,
521                 const cl_image_format * image_format ,
522                 size_t                  image_width ,
523                 size_t                  image_height ,
524                 size_t                  image_row_pitch ,
525                 void *                  host_ptr ,
526                 cl_int *                errcode_ret) CL_API_SUFFIX__VERSION_1_0
527 {
528     cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem));
529     obj->dispatch = dispatchTable;
530     test_icd_stub_log("clCreateImage2D(%p, %x, %p, %u, %u, %u, %p, %p)\n",
531                       context,
532                       flags,
533                       image_format,
534                       image_width,
535                       image_height,
536                       image_row_pitch,
537                       host_ptr,
538 		      errcode_ret);
539 
540     test_icd_stub_log("Value returned: %p\n", obj);
541     return obj;
542 }
543 
544 CL_API_ENTRY cl_mem CL_API_CALL
clCreateImage3D(cl_context context,cl_mem_flags 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 * errcode_ret)545 clCreateImage3D(cl_context              context,
546                 cl_mem_flags            flags,
547                 const cl_image_format * image_format,
548                 size_t                  image_width,
549                 size_t                  image_height ,
550                 size_t                  image_depth ,
551                 size_t                  image_row_pitch ,
552                 size_t                  image_slice_pitch ,
553                 void *                  host_ptr ,
554                 cl_int *                errcode_ret) CL_API_SUFFIX__VERSION_1_0
555 {
556     cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem));
557     obj->dispatch = dispatchTable;
558     test_icd_stub_log("clCreateImage3D(%p, %x, %p, %u, %u, %u, %u, %u, %p, %p)\n",
559                       context,
560                       flags,
561                       image_format,
562                       image_width,
563                       image_height,
564                       image_depth,
565                       image_row_pitch,
566                       image_slice_pitch,
567                       host_ptr,
568                       errcode_ret);
569 
570     test_icd_stub_log("Value returned: %p\n", obj);
571     return obj;
572 }
573 
574 CL_API_ENTRY cl_mem CL_API_CALL
clCreateBufferWithProperties(cl_context context,const cl_mem_properties * properties,cl_mem_flags flags,size_t size,void * host_ptr,cl_int * errcode_ret)575 clCreateBufferWithProperties(cl_context                context ,
576                              const cl_mem_properties * properties,
577                              cl_mem_flags              flags ,
578                              size_t                    size ,
579                              void *                    host_ptr ,
580                              cl_int *                  errcode_ret) CL_API_SUFFIX__VERSION_3_0
581 {
582     cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem));
583     obj->dispatch = dispatchTable;
584     test_icd_stub_log("clCreateBufferWithProperties(%p, %p, %x, %u, %p, %p)\n",
585                       context,
586                       properties,
587                       flags,
588                       size,
589                       host_ptr,
590                       errcode_ret);
591 
592     test_icd_stub_log("Value returned: %p\n", obj);
593     return obj;
594 }
595 
596 CL_API_ENTRY cl_mem CL_API_CALL
clCreateImageWithProperties(cl_context context,const cl_mem_properties * properties,cl_mem_flags flags,const cl_image_format * image_format,const cl_image_desc * image_desc,void * host_ptr,cl_int * errcode_ret)597 clCreateImageWithProperties(cl_context                context,
598                             const cl_mem_properties * properties,
599                             cl_mem_flags              flags,
600                             const cl_image_format *   image_format,
601                             const cl_image_desc *     image_desc,
602                             void *                    host_ptr,
603                             cl_int *                  errcode_ret) CL_API_SUFFIX__VERSION_3_0
604 {
605     cl_mem obj = (cl_mem) malloc(sizeof(struct _cl_mem));
606     obj->dispatch = dispatchTable;
607     test_icd_stub_log("clCreateImageWithProperties(%p, %p, %x, %p, %p, %p, %p)\n",
608                       context,
609                       properties,
610                       flags,
611                       image_format,
612                       image_desc,
613                       host_ptr,
614                       errcode_ret);
615 
616     test_icd_stub_log("Value returned: %p\n", obj);
617     return obj;
618 }
619 
620 CL_API_ENTRY cl_int CL_API_CALL
clRetainMemObject(cl_mem memobj)621 clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0
622 {
623     cl_int return_value = CL_OUT_OF_RESOURCES;
624     test_icd_stub_log("clRetainMemObject(%p)\n", memobj);
625     test_icd_stub_log("Value returned: %d\n", return_value);
626     return return_value;
627 }
628 
629 CL_API_ENTRY cl_int CL_API_CALL
clReleaseMemObject(cl_mem memobj)630 clReleaseMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0
631 {
632     cl_int return_value = CL_OUT_OF_RESOURCES;
633     test_icd_stub_log("clReleaseMemObject(%p)\n", memobj);
634     free(memobj);
635     test_icd_stub_log("Value returned: %d\n", return_value);
636     return return_value;
637 }
638 
639 CL_API_ENTRY cl_int CL_API_CALL
clGetSupportedImageFormats(cl_context context,cl_mem_flags flags,cl_mem_object_type image_type,cl_uint num_entries,cl_image_format * image_formats,cl_uint * num_image_formats)640 clGetSupportedImageFormats(cl_context           context,
641                            cl_mem_flags         flags,
642                            cl_mem_object_type   image_type ,
643                            cl_uint              num_entries ,
644                            cl_image_format *    image_formats ,
645                            cl_uint *            num_image_formats) CL_API_SUFFIX__VERSION_1_0
646 {
647     cl_int return_value = CL_OUT_OF_RESOURCES;
648     test_icd_stub_log("clGetSupportedImageFormats(%p, %x, %u, %u, %p, %p)\n",
649                       context,
650                       flags,
651                       image_type,
652                       num_entries,
653                       image_formats,
654                       num_image_formats);
655 
656     test_icd_stub_log("Value returned: %d\n", return_value);
657     return return_value;
658 }
659 
660 CL_API_ENTRY cl_int CL_API_CALL
clGetMemObjectInfo(cl_mem memobj,cl_mem_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)661 clGetMemObjectInfo(cl_mem            memobj ,
662                    cl_mem_info       param_name ,
663                    size_t            param_value_size ,
664                    void *            param_value ,
665                    size_t *          param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
666 {
667     cl_int return_value = CL_OUT_OF_RESOURCES;
668     test_icd_stub_log("clGetMemObjectInfo(%p, %u, %u, %p, %p)\n",
669                       memobj,
670                       param_name,
671                       param_value_size,
672                       param_value,
673                       param_value_size_ret);
674 
675     test_icd_stub_log("Value returned: %d\n", return_value);
676     return return_value;
677 }
678 
679 CL_API_ENTRY cl_int CL_API_CALL
clGetImageInfo(cl_mem image,cl_image_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)680 clGetImageInfo(cl_mem            image ,
681                cl_image_info     param_name ,
682                size_t            param_value_size ,
683                void *            param_value ,
684                size_t *          param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
685 {
686     cl_int return_value = CL_OUT_OF_RESOURCES;
687     test_icd_stub_log("clGetImageInfo(%p, %u, %u, %p, %p)\n",
688                       image,
689                       param_name,
690                       param_value_size,
691                       param_value,
692                       param_value_size_ret);
693 
694     test_icd_stub_log("Value returned: %d\n", return_value);
695     return return_value;
696 }
697 
698 CL_API_ENTRY cl_int CL_API_CALL
clSetMemObjectDestructorCallback(cl_mem memobj,void (CL_CALLBACK * pfn_notify)(cl_mem memobj,void * user_data),void * user_data)699 clSetMemObjectDestructorCallback(cl_mem  memobj ,
700                                     void (CL_CALLBACK * pfn_notify)(cl_mem  memobj , void* user_data),
701                                     void * user_data)             CL_API_SUFFIX__VERSION_1_1
702 {
703     cl_int return_value = CL_OUT_OF_RESOURCES;
704     test_icd_stub_log("clSetMemObjectDestructorCallback(%p, %p, %p)\n",
705                       memobj,
706                       pfn_notify,
707                       user_data);
708     pfn_notify(memobj, user_data);
709     test_icd_stub_log("setmemobjectdestructor_callback(%p, %p)\n",
710                memobj,
711                user_data);
712 
713     test_icd_stub_log("Value returned: %d\n", return_value);
714     return return_value;
715 }
716 
717 /* Sampler APIs  */
718 CL_API_ENTRY cl_sampler CL_API_CALL
clCreateSampler(cl_context context,cl_bool normalized_coords,cl_addressing_mode addressing_mode,cl_filter_mode filter_mode,cl_int * errcode_ret)719 clCreateSampler(cl_context           context ,
720                 cl_bool              normalized_coords ,
721                 cl_addressing_mode   addressing_mode ,
722                 cl_filter_mode       filter_mode ,
723                 cl_int *             errcode_ret) CL_API_SUFFIX__VERSION_1_0
724 {
725     cl_sampler obj = (cl_sampler) malloc(sizeof(struct _cl_sampler));
726     obj->dispatch = dispatchTable;
727     test_icd_stub_log("clCreateSampler(%p, %u, %u, %u, %p)\n",
728                       context,
729                       normalized_coords,
730                       addressing_mode,
731                       filter_mode,
732                       errcode_ret);
733 
734     test_icd_stub_log("Value returned: %p\n", obj);
735     return obj;
736 }
737 
738 CL_API_ENTRY cl_int CL_API_CALL
clRetainSampler(cl_sampler sampler)739 clRetainSampler(cl_sampler  sampler) CL_API_SUFFIX__VERSION_1_0
740 {
741     cl_int return_value = CL_OUT_OF_RESOURCES;
742     test_icd_stub_log("clRetainSampler(%p)\n", sampler);
743     test_icd_stub_log("Value returned: %d\n", return_value);
744     return return_value;
745 }
746 
747 CL_API_ENTRY cl_int CL_API_CALL
clReleaseSampler(cl_sampler sampler)748 clReleaseSampler(cl_sampler  sampler) CL_API_SUFFIX__VERSION_1_0
749 {
750     cl_int return_value = CL_OUT_OF_RESOURCES;
751     test_icd_stub_log("clReleaseSampler(%p)\n", sampler);
752     free(sampler);
753     test_icd_stub_log("Value returned: %d\n", return_value);
754     return return_value;
755 }
756 
757 CL_API_ENTRY cl_int CL_API_CALL
clGetSamplerInfo(cl_sampler sampler,cl_sampler_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)758 clGetSamplerInfo(cl_sampler          sampler ,
759                  cl_sampler_info     param_name ,
760                  size_t              param_value_size ,
761                  void *              param_value ,
762                  size_t *            param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
763 {
764     cl_int return_value = CL_OUT_OF_RESOURCES;
765     test_icd_stub_log("clGetSamplerInfo(%p, %u, %u, %p, %p)\n",
766                       sampler,
767                       param_name,
768                       param_value_size,
769                       param_value,
770                       param_value_size_ret);
771 
772     test_icd_stub_log("Value returned: %d\n", return_value);
773     return return_value;
774 }
775 
776 /* Program Object APIs  */
777 CL_API_ENTRY cl_program CL_API_CALL
clCreateProgramWithSource(cl_context context,cl_uint count,const char ** strings,const size_t * lengths,cl_int * errcode_ret)778 clCreateProgramWithSource(cl_context         context ,
779                           cl_uint            count ,
780                           const char **      strings ,
781                           const size_t *     lengths ,
782                           cl_int *           errcode_ret) CL_API_SUFFIX__VERSION_1_0
783 {
784     cl_program obj = (cl_program) malloc(sizeof(struct _cl_program));
785     obj->dispatch = dispatchTable;
786     test_icd_stub_log("clCreateProgramWithSource(%p, %u, %p, %p, %p)\n",
787                       context,
788                       count,
789                       strings,
790                       lengths,
791                       errcode_ret);
792 
793     test_icd_stub_log("Value returned: %p\n", obj);
794     return obj;
795 }
796 
797 CL_API_ENTRY cl_program CL_API_CALL
clCreateProgramWithBinary(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 * errcode_ret)798 clCreateProgramWithBinary(cl_context                      context ,
799                           cl_uint                         num_devices ,
800                           const cl_device_id *            device_list ,
801                           const size_t *                  lengths ,
802                           const unsigned char **          binaries ,
803                           cl_int *                        binary_status ,
804                           cl_int *                        errcode_ret) CL_API_SUFFIX__VERSION_1_0
805 {
806     cl_program obj = (cl_program) malloc(sizeof(struct _cl_program));
807     obj->dispatch = dispatchTable;
808     test_icd_stub_log("clCreateProgramWithBinary(%p, %u, %p, %p, %p, %p, %p)\n",
809                       context,
810                       num_devices,
811                       device_list,
812                       lengths,
813                       binaries,
814                       binary_status,
815                       errcode_ret);
816 
817     test_icd_stub_log("Value returned: %p\n", obj);
818     return obj;
819 }
820 
821 CL_API_ENTRY cl_program CL_API_CALL
clCreateProgramWithBuiltInKernels(cl_context context,cl_uint num_devices,const cl_device_id * device_list,const char * kernel_names,cl_int * errcode_ret)822 clCreateProgramWithBuiltInKernels(cl_context             context ,
823                                   cl_uint                num_devices ,
824                                   const cl_device_id *   device_list ,
825                                   const char *           kernel_names ,
826                                   cl_int *               errcode_ret) CL_API_SUFFIX__VERSION_1_2
827 {
828     cl_program obj = (cl_program) malloc(sizeof(struct _cl_program));
829     obj->dispatch = dispatchTable;
830     test_icd_stub_log("clCreateProgramWithBuiltInKernels(%p, %u, %p, %p, %p)\n",
831                       context,
832                       num_devices,
833                       device_list,
834                       kernel_names,
835                       errcode_ret);
836 
837     test_icd_stub_log("Value returned: %p\n", obj);
838     return obj;
839 }
840 
841 
842 CL_API_ENTRY cl_int CL_API_CALL
clRetainProgram(cl_program program)843 clRetainProgram(cl_program  program) CL_API_SUFFIX__VERSION_1_0
844 {
845     cl_int return_value = CL_OUT_OF_RESOURCES;
846     test_icd_stub_log("clRetainProgram(%p)\n",
847                       program);
848 
849     test_icd_stub_log("Value returned: %d\n", return_value);
850     return return_value;
851 }
852 
853 CL_API_ENTRY cl_int CL_API_CALL
clReleaseProgram(cl_program program)854 clReleaseProgram(cl_program  program) CL_API_SUFFIX__VERSION_1_0
855 {
856     cl_int return_value = CL_OUT_OF_RESOURCES;
857     test_icd_stub_log("clReleaseProgram(%p)\n", program);
858     free(program);
859     test_icd_stub_log("Value returned: %d\n", return_value);
860     return return_value;
861 }
862 
863 CL_API_ENTRY cl_int CL_API_CALL
clBuildProgram(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)864 clBuildProgram(cl_program            program ,
865                cl_uint               num_devices ,
866                const cl_device_id *  device_list ,
867                const char *          options ,
868                void (CL_CALLBACK *   pfn_notify)(cl_program  program , void *  user_data),
869                void *                user_data) CL_API_SUFFIX__VERSION_1_0
870 {
871     cl_int return_value = CL_OUT_OF_RESOURCES;
872     test_icd_stub_log("clBuildProgram(%p, %u, %p, %p, %p, %p)\n",
873                       program,
874                       num_devices,
875                       device_list,
876                       options,
877                       pfn_notify,
878                       user_data);
879     pfn_notify(program, NULL);
880     test_icd_stub_log("program_callback(%p, %p)\n", program, NULL);
881     test_icd_stub_log("Value returned: %d\n", return_value);
882     return return_value;
883 }
884 
885 CL_API_ENTRY cl_int CL_API_CALL
clUnloadCompiler(void)886 clUnloadCompiler(void) CL_API_SUFFIX__VERSION_1_0
887 {
888     cl_int return_value = CL_OUT_OF_RESOURCES;
889     test_icd_stub_log("clUnloadCompiler()\n");
890     test_icd_stub_log("Value returned: %d\n", return_value);
891     return return_value;
892 }
893 
894 CL_API_ENTRY cl_int CL_API_CALL
clCompileProgram(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)895 clCompileProgram(cl_program            program ,
896                  cl_uint               num_devices ,
897                  const cl_device_id *  device_list ,
898                  const char *          options ,
899                  cl_uint               num_input_headers ,
900                  const cl_program *    input_headers,
901                  const char **         header_include_names ,
902                  void (CL_CALLBACK *   pfn_notify)(cl_program  program , void *  user_data),
903                  void *                user_data) CL_API_SUFFIX__VERSION_1_2
904 {
905     (void)input_headers;
906     cl_int return_value = CL_OUT_OF_RESOURCES;
907     test_icd_stub_log("clCompileProgram(%p, %u, %p, %p, %u, %p, %p, %p)\n",
908                       program,
909                       num_devices,
910                       device_list,
911                       options,
912                       num_input_headers,
913                       header_include_names,
914                       pfn_notify,
915                       user_data);
916     pfn_notify(program, NULL);
917     test_icd_stub_log("program_callback(%p, %p)\n", program, NULL);
918     test_icd_stub_log("Value returned: %d\n", return_value);
919     return return_value;
920 }
921 
922 CL_API_ENTRY cl_program CL_API_CALL
clLinkProgram(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 * errcode_ret)923 clLinkProgram(cl_context            context ,
924               cl_uint               num_devices ,
925               const cl_device_id *  device_list ,
926               const char *          options ,
927               cl_uint               num_input_programs ,
928               const cl_program *    input_programs ,
929               void (CL_CALLBACK *   pfn_notify)(cl_program  program , void *  user_data),
930               void *                user_data ,
931               cl_int *              errcode_ret) CL_API_SUFFIX__VERSION_1_2
932 {
933     cl_program obj = (cl_program) malloc(sizeof(cl_program));
934     obj->dispatch = dispatchTable;
935     test_icd_stub_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n",
936                       context,
937                       num_devices,
938                       device_list,
939                       options,
940                       num_input_programs,
941                       input_programs,
942                       pfn_notify,
943                       user_data,
944                       errcode_ret);
945     pfn_notify(obj, NULL);
946     test_icd_stub_log("program_callback(%p, %p)\n", obj, NULL);
947     test_icd_stub_log("Value returned: %p\n", obj);
948     return obj;
949 }
950 
951 
952 CL_API_ENTRY cl_int CL_API_CALL
clUnloadPlatformCompiler(cl_platform_id platform)953 clUnloadPlatformCompiler(cl_platform_id  platform) CL_API_SUFFIX__VERSION_1_2
954 {
955     cl_int return_value = CL_OUT_OF_RESOURCES;
956     test_icd_stub_log("clUnloadPlatformCompiler(%p)\n", platform);
957     test_icd_stub_log("Value returned: %d\n", return_value);
958     return return_value;
959 }
960 
961 CL_API_ENTRY cl_int CL_API_CALL
clGetProgramInfo(cl_program program,cl_program_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)962 clGetProgramInfo(cl_program          program ,
963                  cl_program_info     param_name ,
964                  size_t              param_value_size ,
965                  void *              param_value ,
966                  size_t *            param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
967 {
968     cl_int return_value = CL_OUT_OF_RESOURCES;
969     test_icd_stub_log("clGetProgramInfo(%p, %u, %u, %p, %p)\n",
970                       program,
971                       param_name,
972                       param_value_size,
973                       param_value,
974                       param_value_size_ret);
975 
976     test_icd_stub_log("Value returned: %d\n", return_value);
977     return return_value;
978 }
979 
980 CL_API_ENTRY cl_int CL_API_CALL
clGetProgramBuildInfo(cl_program program,cl_device_id device,cl_program_build_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)981 clGetProgramBuildInfo(cl_program             program ,
982                       cl_device_id           device ,
983                       cl_program_build_info  param_name ,
984                       size_t                 param_value_size ,
985                       void *                 param_value ,
986                       size_t *               param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
987 {
988     cl_int return_value = CL_OUT_OF_RESOURCES;
989     test_icd_stub_log("clGetProgramBuildInfo(%p, %p, %u, %u, %p, %p)\n",
990                       program,
991                       device,
992                       param_name,
993                       param_value_size,
994                       param_value,
995                       param_value_size_ret);
996 
997     test_icd_stub_log("Value returned: %d\n", return_value);
998     return return_value;
999 }
1000 
1001 /* Kernel Object APIs */
1002 CL_API_ENTRY cl_kernel CL_API_CALL
clCreateKernel(cl_program program,const char * kernel_name,cl_int * errcode_ret)1003 clCreateKernel(cl_program       program ,
1004                const char *     kernel_name ,
1005                cl_int *         errcode_ret) CL_API_SUFFIX__VERSION_1_0
1006 {
1007     cl_kernel obj = (cl_kernel) malloc(sizeof(struct _cl_kernel));
1008     obj->dispatch = dispatchTable;
1009     test_icd_stub_log("clCreateKernel(%p, %p, %p)\n",
1010                       program,
1011                       kernel_name,
1012                       errcode_ret);
1013 
1014     test_icd_stub_log("Value returned: %p\n", obj);
1015     return obj;
1016 }
1017 
1018 CL_API_ENTRY cl_int CL_API_CALL
clCreateKernelsInProgram(cl_program program,cl_uint num_kernels,cl_kernel * kernels,cl_uint * num_kernels_ret)1019 clCreateKernelsInProgram(cl_program      program ,
1020                          cl_uint         num_kernels ,
1021                          cl_kernel *     kernels ,
1022                          cl_uint *       num_kernels_ret) CL_API_SUFFIX__VERSION_1_0
1023 {
1024     cl_int return_value = CL_OUT_OF_RESOURCES;
1025     test_icd_stub_log("clCreateKernelsInProgram(%p, %u, %p, %p)\n",
1026                       program,
1027                       num_kernels,
1028                       kernels,
1029                       num_kernels_ret);
1030 
1031     test_icd_stub_log("Value returned: %d\n", return_value);
1032     return return_value;
1033 }
1034 
1035 CL_API_ENTRY cl_int CL_API_CALL
clRetainKernel(cl_kernel kernel)1036 clRetainKernel(cl_kernel     kernel) CL_API_SUFFIX__VERSION_1_0
1037 {
1038     cl_int return_value = CL_OUT_OF_RESOURCES;
1039     test_icd_stub_log("clRetainKernel(%p)\n", kernel);
1040     test_icd_stub_log("Value returned: %d\n", return_value);
1041     return return_value;
1042 }
1043 
1044 CL_API_ENTRY cl_int CL_API_CALL
clReleaseKernel(cl_kernel kernel)1045 clReleaseKernel(cl_kernel    kernel) CL_API_SUFFIX__VERSION_1_0
1046 {
1047     cl_int return_value = CL_OUT_OF_RESOURCES;
1048     test_icd_stub_log("clReleaseKernel(%p)\n", kernel);
1049     free(kernel);
1050     test_icd_stub_log("Value returned: %d\n", return_value);
1051     return return_value;
1052 }
1053 
1054 CL_API_ENTRY cl_int CL_API_CALL
clSetKernelArg(cl_kernel kernel,cl_uint arg_index,size_t arg_size,const void * arg_value)1055 clSetKernelArg(cl_kernel     kernel ,
1056                cl_uint       arg_index ,
1057                size_t        arg_size ,
1058                const void *  arg_value) CL_API_SUFFIX__VERSION_1_0
1059 {
1060     cl_int return_value = CL_OUT_OF_RESOURCES;
1061     test_icd_stub_log("clSetKernelArg(%p, %u, %u, %p)\n",
1062                       kernel,
1063                       arg_index,
1064                       arg_size,
1065                       arg_value);
1066 
1067     test_icd_stub_log("Value returned: %d\n", return_value);
1068     return return_value;
1069 }
1070 
1071 CL_API_ENTRY cl_int CL_API_CALL
clGetKernelInfo(cl_kernel kernel,cl_kernel_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)1072 clGetKernelInfo(cl_kernel        kernel ,
1073                 cl_kernel_info   param_name ,
1074                 size_t           param_value_size ,
1075                 void *           param_value ,
1076                 size_t *         param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
1077 {
1078     cl_int return_value = CL_OUT_OF_RESOURCES;
1079     test_icd_stub_log("clGetKernelInfo(%p, %u, %u, %p, %p)\n",
1080                       kernel,
1081                       param_name,
1082                       param_value_size,
1083                       param_value,
1084                       param_value_size_ret);
1085 
1086     test_icd_stub_log("Value returned: %d\n", return_value);
1087     return return_value;
1088 }
1089 
1090 CL_API_ENTRY cl_int CL_API_CALL
clGetKernelArgInfo(cl_kernel kernel,cl_uint arg_indx,cl_kernel_arg_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)1091 clGetKernelArgInfo(cl_kernel        kernel ,
1092                    cl_uint          arg_indx ,
1093                    cl_kernel_arg_info   param_name ,
1094                    size_t           param_value_size ,
1095                    void *           param_value ,
1096                    size_t *         param_value_size_ret) CL_API_SUFFIX__VERSION_1_2
1097 {
1098     cl_int return_value = CL_OUT_OF_RESOURCES;
1099     test_icd_stub_log("clGetKernelArgInfo(%p, %u, %u, %u, %p, %p)\n",
1100                       kernel,
1101                       arg_indx,
1102                       param_name,
1103                       param_value_size,
1104                       param_value,
1105                       param_value_size_ret);
1106 
1107     test_icd_stub_log("Value returned: %d\n", return_value);
1108     return return_value;
1109 }
1110 
1111 CL_API_ENTRY cl_int CL_API_CALL
clGetKernelWorkGroupInfo(cl_kernel kernel,cl_device_id device,cl_kernel_work_group_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)1112 clGetKernelWorkGroupInfo(cl_kernel                   kernel ,
1113                          cl_device_id                device ,
1114                          cl_kernel_work_group_info   param_name ,
1115                          size_t                      param_value_size ,
1116                          void *                      param_value ,
1117                          size_t *                    param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
1118 {
1119     cl_int return_value = CL_OUT_OF_RESOURCES;
1120     test_icd_stub_log("clGetKernelWorkGroupInfo(%p, %p, %u, %u, %p, %p)\n",
1121                       kernel,
1122                       device,
1123                       param_name,
1124                       param_value_size,
1125                       param_value,
1126                       param_value_size_ret);
1127 
1128     test_icd_stub_log("Value returned: %d\n", return_value);
1129     return return_value;
1130 }
1131 
1132 /* Event Object APIs  */
1133 CL_API_ENTRY cl_int CL_API_CALL
clWaitForEvents(cl_uint num_events,const cl_event * event_list)1134 clWaitForEvents(cl_uint              num_events ,
1135                 const cl_event *     event_list) CL_API_SUFFIX__VERSION_1_0
1136 {
1137     cl_int return_value = CL_OUT_OF_RESOURCES;
1138     test_icd_stub_log("clWaitForEvents(%u, %p)\n",
1139                       num_events,
1140                       event_list);
1141 
1142     test_icd_stub_log("Value returned: %d\n", return_value);
1143     return return_value;
1144 }
1145 
1146 CL_API_ENTRY cl_int CL_API_CALL
clGetEventInfo(cl_event event,cl_event_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)1147 clGetEventInfo(cl_event          event ,
1148                cl_event_info     param_name ,
1149                size_t            param_value_size ,
1150                void *            param_value ,
1151                size_t *          param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
1152 {
1153     cl_int return_value = CL_OUT_OF_RESOURCES;
1154     test_icd_stub_log("clGetEventInfo(%p, %u, %u, %p, %p)\n",
1155                       event,
1156                       param_name,
1157                       param_value_size,
1158                       param_value,
1159                       param_value_size_ret);
1160 
1161     test_icd_stub_log("Value returned: %d\n", return_value);
1162     return return_value;
1163 }
1164 
1165 CL_API_ENTRY cl_event CL_API_CALL
clCreateUserEvent(cl_context context,cl_int * errcode_ret)1166 clCreateUserEvent(cl_context     context ,
1167                   cl_int *       errcode_ret) CL_API_SUFFIX__VERSION_1_1
1168 {
1169     cl_event obj = (cl_event) malloc(sizeof(struct _cl_event));
1170     obj->dispatch = dispatchTable;
1171     test_icd_stub_log("clCreateUserEvent(%p, %p)\n", context, errcode_ret);
1172     test_icd_stub_log("Value returned: %p\n", obj);
1173     return obj;
1174 }
1175 
1176 CL_API_ENTRY cl_int CL_API_CALL
clRetainEvent(cl_event event)1177 clRetainEvent(cl_event  event) CL_API_SUFFIX__VERSION_1_0
1178 {
1179     cl_int return_value = CL_OUT_OF_RESOURCES;
1180     test_icd_stub_log("clRetainEvent(%p)\n", event);
1181     test_icd_stub_log("Value returned: %d\n", return_value);
1182     return return_value;
1183 }
1184 
1185 CL_API_ENTRY cl_int CL_API_CALL
clReleaseEvent(cl_event event)1186 clReleaseEvent(cl_event  event) CL_API_SUFFIX__VERSION_1_0
1187 {
1188     cl_int return_value = CL_OUT_OF_RESOURCES;
1189     test_icd_stub_log("clReleaseEvent(%p)\n", event);
1190     free(event);
1191     test_icd_stub_log("Value returned: %d\n", return_value);
1192     return return_value;
1193 }
1194 
1195 CL_API_ENTRY cl_int CL_API_CALL
clSetUserEventStatus(cl_event event,cl_int execution_status)1196 clSetUserEventStatus(cl_event    event ,
1197                      cl_int      execution_status) CL_API_SUFFIX__VERSION_1_1
1198 {
1199     cl_int return_value = CL_OUT_OF_RESOURCES;
1200     test_icd_stub_log("clSetUserEventStatus(%p, %d)\n",
1201                       event,
1202                       execution_status);
1203     test_icd_stub_log("Value returned: %d\n", return_value);
1204     return return_value;
1205 }
1206 
1207 CL_API_ENTRY cl_int CL_API_CALL
clSetEventCallback(cl_event event,cl_int command_exec_callback_type,void (CL_CALLBACK * pfn_notify)(cl_event,cl_int,void *),void * user_data)1208 clSetEventCallback(cl_event     event ,
1209                     cl_int       command_exec_callback_type ,
1210                     void (CL_CALLBACK *  pfn_notify)(cl_event, cl_int, void *),
1211                     void *       user_data) CL_API_SUFFIX__VERSION_1_1
1212 {
1213     cl_int return_value = CL_OUT_OF_RESOURCES;
1214     test_icd_stub_log("clSetEventCallback(%p, %d, %p, %p)\n",
1215                       event,
1216                       command_exec_callback_type,
1217                       pfn_notify,
1218                       user_data);
1219     pfn_notify(event, command_exec_callback_type, NULL);
1220     test_icd_stub_log("setevent_callback(%p, %d, %p)\n",
1221                       event,
1222                       command_exec_callback_type,
1223                       NULL);
1224 
1225     test_icd_stub_log("Value returned: %d\n", return_value);
1226     return return_value;
1227 }
1228 
1229 /* Profiling APIs  */
1230 CL_API_ENTRY cl_int CL_API_CALL
clGetEventProfilingInfo(cl_event event,cl_profiling_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)1231 clGetEventProfilingInfo(cl_event             event ,
1232                         cl_profiling_info    param_name ,
1233                         size_t               param_value_size ,
1234                         void *               param_value ,
1235                         size_t *             param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
1236 {
1237     cl_int return_value = CL_OUT_OF_RESOURCES;
1238     test_icd_stub_log("clGetEventProfilingInfo(%p, %u, %u, %p, %p)\n",
1239                       event,
1240                       param_name,
1241                       param_value_size,
1242                       param_value,
1243                       param_value_size_ret);
1244 
1245     test_icd_stub_log("Value returned: %d\n", return_value);
1246     return return_value;
1247 }
1248 
1249 /* Flush and Finish APIs */
1250 CL_API_ENTRY cl_int CL_API_CALL
clFlush(cl_command_queue command_queue)1251 clFlush(cl_command_queue  command_queue) CL_API_SUFFIX__VERSION_1_0
1252 {
1253     cl_int return_value = CL_OUT_OF_RESOURCES;
1254     test_icd_stub_log("clFlush(%p)\n", command_queue);
1255     test_icd_stub_log("Value returned: %d\n", return_value);
1256     return return_value;
1257 }
1258 
1259 CL_API_ENTRY cl_int CL_API_CALL
clFinish(cl_command_queue command_queue)1260 clFinish(cl_command_queue  command_queue) CL_API_SUFFIX__VERSION_1_0
1261 {
1262     cl_int return_value = CL_OUT_OF_RESOURCES;
1263     test_icd_stub_log("clFinish(%p)\n", command_queue);
1264     test_icd_stub_log("Value returned: %d\n", return_value);
1265     return return_value;
1266 }
1267 
1268 /* Enqueued Commands APIs */
1269 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueReadBuffer(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_read,size_t offset,size_t cb,void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1270 clEnqueueReadBuffer(cl_command_queue     command_queue ,
1271                     cl_mem               buffer ,
1272                     cl_bool              blocking_read ,
1273                     size_t               offset ,
1274                     size_t               cb ,
1275                     void *               ptr ,
1276                     cl_uint              num_events_in_wait_list ,
1277                     const cl_event *     event_wait_list ,
1278                     cl_event *           event) CL_API_SUFFIX__VERSION_1_0
1279 {
1280     cl_int return_value = CL_OUT_OF_RESOURCES;
1281     test_icd_stub_log("clEnqueueReadBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n",
1282                       command_queue,
1283                       buffer,
1284                       blocking_read,
1285                       offset,
1286                       cb,
1287                       ptr,
1288                       num_events_in_wait_list,
1289                       event_wait_list, event);
1290 
1291     test_icd_stub_log("Value returned: %d\n", return_value);
1292     return return_value;
1293 }
1294 
1295 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueReadBufferRect(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)1296 clEnqueueReadBufferRect(cl_command_queue     command_queue ,
1297                         cl_mem               buffer ,
1298                         cl_bool              blocking_read ,
1299                         const size_t *       buffer_origin ,
1300                         const size_t *       host_origin ,
1301                         const size_t *       region ,
1302                         size_t               buffer_row_pitch ,
1303                         size_t               buffer_slice_pitch ,
1304                         size_t               host_row_pitch ,
1305                         size_t               host_slice_pitch ,
1306                         void *               ptr ,
1307                         cl_uint              num_events_in_wait_list ,
1308                         const cl_event *     event_wait_list ,
1309                         cl_event *           event) CL_API_SUFFIX__VERSION_1_1
1310 {
1311     cl_int return_value = CL_OUT_OF_RESOURCES;
1312     test_icd_stub_log("clEnqueueReadBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n",
1313                       command_queue,
1314                       buffer,
1315                       blocking_read,
1316                       buffer_origin,
1317                       host_origin,
1318                       region,
1319                       buffer_row_pitch,
1320                       buffer_slice_pitch,
1321                       host_row_pitch,
1322                       host_slice_pitch,
1323                       ptr,
1324                       num_events_in_wait_list,
1325                       event_wait_list,
1326                       event);
1327 
1328     test_icd_stub_log("Value returned: %d\n", return_value);
1329     return return_value;
1330 }
1331 
1332 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueWriteBuffer(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_write,size_t offset,size_t cb,const void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1333 clEnqueueWriteBuffer(cl_command_queue    command_queue ,
1334                      cl_mem              buffer ,
1335                      cl_bool             blocking_write ,
1336                      size_t              offset ,
1337                      size_t              cb ,
1338                      const void *        ptr ,
1339                      cl_uint             num_events_in_wait_list ,
1340                      const cl_event *    event_wait_list ,
1341                      cl_event *          event) CL_API_SUFFIX__VERSION_1_0
1342 {
1343     cl_int return_value = CL_OUT_OF_RESOURCES;
1344     test_icd_stub_log("clEnqueueWriteBuffer(%p, %p, %u, %u, %u, %p, %u, %p, %p)\n",
1345                       command_queue,
1346                       buffer,
1347                       blocking_write,
1348                       offset,
1349                       cb,
1350                       ptr,
1351                       num_events_in_wait_list,
1352                       event_wait_list,
1353                       event);
1354 
1355     test_icd_stub_log("Value returned: %d\n", return_value);
1356     return return_value;
1357 }
1358 
1359 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueWriteBufferRect(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)1360 clEnqueueWriteBufferRect(cl_command_queue     command_queue ,
1361                          cl_mem               buffer ,
1362                          cl_bool              blocking_write ,
1363                          const size_t *       buffer_origin ,
1364                          const size_t *       host_origin ,
1365                          const size_t *       region ,
1366                          size_t               buffer_row_pitch ,
1367                          size_t               buffer_slice_pitch ,
1368                          size_t               host_row_pitch ,
1369                          size_t               host_slice_pitch ,
1370                          const void *         ptr ,
1371                          cl_uint              num_events_in_wait_list ,
1372                          const cl_event *     event_wait_list ,
1373                          cl_event *           event) CL_API_SUFFIX__VERSION_1_1
1374 {
1375     cl_int return_value = CL_OUT_OF_RESOURCES;
1376     test_icd_stub_log("clEnqueueWriteBufferRect(%p, %p, %u, %p, %p, %p, %u, %u, %u, %u, %p, %u, %p, %p)\n",
1377                       command_queue,
1378                       buffer,
1379                       blocking_write,
1380                       buffer_origin,
1381                       host_origin,
1382                       region,
1383                       buffer_row_pitch,
1384                       buffer_slice_pitch,
1385                       host_row_pitch,
1386                       host_slice_pitch,
1387                       ptr,
1388                       num_events_in_wait_list,
1389                       event_wait_list,
1390                       event);
1391 
1392     test_icd_stub_log("Value returned: %d\n", return_value);
1393     return return_value;
1394 }
1395 
1396 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueCopyBuffer(cl_command_queue command_queue,cl_mem src_buffer,cl_mem dst_buffer,size_t src_offset,size_t dst_offset,size_t cb,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1397 clEnqueueCopyBuffer(cl_command_queue     command_queue ,
1398                     cl_mem               src_buffer ,
1399                     cl_mem               dst_buffer ,
1400                     size_t               src_offset ,
1401                     size_t               dst_offset ,
1402                     size_t               cb ,
1403                     cl_uint              num_events_in_wait_list ,
1404                     const cl_event *     event_wait_list ,
1405                     cl_event *           event) CL_API_SUFFIX__VERSION_1_0
1406 {
1407     cl_int return_value = CL_OUT_OF_RESOURCES;
1408     test_icd_stub_log("clEnqueueCopyBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n",
1409                       command_queue,
1410                       src_buffer,
1411                       dst_buffer,
1412                       src_offset,
1413                       dst_offset,
1414                       cb,
1415                       num_events_in_wait_list,
1416                       event_wait_list,
1417                       event);
1418 
1419     test_icd_stub_log("Value returned: %d\n", return_value);
1420     return return_value;
1421 }
1422 
1423 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueCopyBufferRect(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)1424 clEnqueueCopyBufferRect(cl_command_queue     command_queue ,
1425                         cl_mem               src_buffer ,
1426                         cl_mem               dst_buffer ,
1427                         const size_t *       src_origin ,
1428                         const size_t *       dst_origin ,
1429                         const size_t *       region ,
1430                         size_t               src_row_pitch ,
1431                         size_t               src_slice_pitch ,
1432                         size_t               dst_row_pitch ,
1433                         size_t               dst_slice_pitch ,
1434                         cl_uint              num_events_in_wait_list ,
1435                         const cl_event *     event_wait_list ,
1436                         cl_event *           event) CL_API_SUFFIX__VERSION_1_1
1437 {
1438     cl_int return_value = CL_OUT_OF_RESOURCES;
1439     test_icd_stub_log("clEnqueueCopyBufferRect(%p, %p, %p, %p, %p, %p, %u, %u, %u, %u, %u, %p, %p)\n",
1440                       command_queue,
1441                       src_buffer,
1442                       dst_buffer,
1443                       src_origin,
1444                       dst_origin,
1445                       region,
1446                       src_row_pitch,
1447                       src_slice_pitch,
1448                       dst_row_pitch,
1449                       dst_slice_pitch,
1450                       num_events_in_wait_list,
1451                       event_wait_list,
1452                       event);
1453 
1454     test_icd_stub_log("Value returned: %d\n", return_value);
1455     return return_value;
1456 }
1457 
1458 
1459 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueFillBuffer(cl_command_queue command_queue,cl_mem buffer,const void * pattern,size_t pattern_size,size_t offset,size_t cb,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1460 clEnqueueFillBuffer(cl_command_queue    command_queue ,
1461                     cl_mem              buffer ,
1462                     const void *        pattern ,
1463                     size_t              pattern_size ,
1464                     size_t              offset ,
1465                     size_t              cb ,
1466                     cl_uint             num_events_in_wait_list ,
1467                     const cl_event *    event_wait_list ,
1468                     cl_event *          event) CL_API_SUFFIX__VERSION_1_2
1469 {
1470     cl_int return_value = CL_OUT_OF_RESOURCES;
1471     test_icd_stub_log("clEnqueueFillBuffer(%p, %p, %p, %u, %u, %u, %u, %p, %p)\n",
1472                       command_queue,
1473                       buffer,
1474                       pattern,
1475                       pattern_size,
1476                       offset,
1477                       cb,
1478                       num_events_in_wait_list,
1479                       event_wait_list,
1480                       event);
1481 
1482     test_icd_stub_log("Value returned: %d\n", return_value);
1483     return return_value;
1484 }
1485 
1486 
1487 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueFillImage(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)1488 clEnqueueFillImage(cl_command_queue    command_queue ,
1489                    cl_mem              image ,
1490                    const void *        fill_color ,
1491                    const size_t *      origin ,
1492                    const size_t *      region ,
1493                    cl_uint             num_events_in_wait_list ,
1494                    const cl_event *    event_wait_list ,
1495                    cl_event *          event) CL_API_SUFFIX__VERSION_1_2
1496 {
1497     cl_int return_value = CL_OUT_OF_RESOURCES;
1498     test_icd_stub_log("clEnqueueFillImage(%p, %p, %p, %p, %p, %u, %p, %p)\n",
1499                       command_queue,
1500                       image,
1501                       fill_color,
1502                       origin,
1503                       region,
1504                       num_events_in_wait_list,
1505                       event_wait_list,
1506                       event);
1507 
1508     test_icd_stub_log("Value returned: %d\n", return_value);
1509     return return_value;
1510 }
1511 
1512 
1513 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueReadImage(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)1514 clEnqueueReadImage(cl_command_queue      command_queue ,
1515                    cl_mem                image ,
1516                    cl_bool               blocking_read ,
1517                    const size_t *        origin ,
1518                    const size_t *        region ,
1519                    size_t                row_pitch ,
1520                    size_t                slice_pitch ,
1521                    void *                ptr ,
1522                    cl_uint               num_events_in_wait_list ,
1523                    const cl_event *      event_wait_list ,
1524                    cl_event *            event) CL_API_SUFFIX__VERSION_1_0
1525 {
1526     cl_int return_value = CL_OUT_OF_RESOURCES;
1527     test_icd_stub_log("clEnqueueReadImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n",
1528                       command_queue,
1529                       image,
1530                       blocking_read,
1531                       origin,
1532                       region,
1533                       row_pitch,
1534                       slice_pitch,
1535                       ptr,
1536                       num_events_in_wait_list,
1537                       event_wait_list,
1538                       event);
1539 
1540     test_icd_stub_log("Value returned: %d\n", return_value);
1541     return return_value;
1542 }
1543 
1544 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueWriteImage(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)1545 clEnqueueWriteImage(cl_command_queue     command_queue ,
1546                     cl_mem               image ,
1547                     cl_bool              blocking_write ,
1548                     const size_t *       origin ,
1549                     const size_t *       region ,
1550                     size_t               input_row_pitch ,
1551                     size_t               input_slice_pitch ,
1552                     const void *         ptr ,
1553                     cl_uint              num_events_in_wait_list ,
1554                     const cl_event *     event_wait_list ,
1555                     cl_event *           event) CL_API_SUFFIX__VERSION_1_0
1556 {
1557     cl_int return_value = CL_OUT_OF_RESOURCES;
1558     test_icd_stub_log("clEnqueueWriteImage(%p, %p, %u, %p, %p, %u, %u, %p, %u, %p, %p)\n",
1559                       command_queue,
1560                       image,
1561                       blocking_write,
1562                       origin,
1563                       region,
1564                       input_row_pitch,
1565                       input_slice_pitch,
1566                       ptr,
1567                       num_events_in_wait_list,
1568                       event_wait_list,
1569                       event);
1570 
1571     test_icd_stub_log("Value returned: %d\n", return_value);
1572     return return_value;
1573 }
1574 
1575 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueCopyImage(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)1576 clEnqueueCopyImage(cl_command_queue      command_queue ,
1577                    cl_mem                src_image ,
1578                    cl_mem                dst_image ,
1579                    const size_t *        src_origin ,
1580                    const size_t *        dst_origin ,
1581                    const size_t *        region ,
1582                    cl_uint               num_events_in_wait_list ,
1583                    const cl_event *      event_wait_list ,
1584                    cl_event *            event) CL_API_SUFFIX__VERSION_1_0
1585 {
1586     cl_int return_value = CL_OUT_OF_RESOURCES;
1587     test_icd_stub_log("clEnqueueCopyImage(%p, %p, %p, %p, %p, %p, %u, %p, %p)\n",
1588                       command_queue,
1589                       src_image,
1590                       dst_image,
1591                       src_origin,
1592                       dst_origin,
1593                       region,
1594                       num_events_in_wait_list,
1595                       event_wait_list ,
1596                       event);
1597 
1598     test_icd_stub_log("Value returned: %d\n", return_value);
1599     return return_value;
1600 }
1601 
1602 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueCopyImageToBuffer(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)1603 clEnqueueCopyImageToBuffer(cl_command_queue  command_queue ,
1604                            cl_mem            src_image ,
1605                            cl_mem            dst_buffer ,
1606                            const size_t *    src_origin ,
1607                            const size_t *    region ,
1608                            size_t            dst_offset ,
1609                            cl_uint           num_events_in_wait_list ,
1610                            const cl_event *  event_wait_list ,
1611                            cl_event *        event) CL_API_SUFFIX__VERSION_1_0
1612 {
1613     cl_int return_value = CL_OUT_OF_RESOURCES;
1614     test_icd_stub_log("clEnqueueCopyImageToBuffer(%p, %p, %p, %p, %p, %u, %u, %p, %p)\n",
1615                       command_queue,
1616                       src_image,
1617                       dst_buffer,
1618                       src_origin,
1619                       region,
1620                       dst_offset,
1621                       num_events_in_wait_list,
1622                       event_wait_list,
1623                       event);
1624 
1625     test_icd_stub_log("Value returned: %d\n", return_value);
1626     return return_value;
1627 }
1628 
1629 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueCopyBufferToImage(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)1630 clEnqueueCopyBufferToImage(cl_command_queue  command_queue ,
1631                            cl_mem            src_buffer ,
1632                            cl_mem            dst_image ,
1633                            size_t            src_offset ,
1634                            const size_t *    dst_origin ,
1635                            const size_t *    region ,
1636                            cl_uint           num_events_in_wait_list ,
1637                            const cl_event *  event_wait_list ,
1638                            cl_event *        event) CL_API_SUFFIX__VERSION_1_0
1639 {
1640     cl_int return_value = CL_OUT_OF_RESOURCES;
1641     test_icd_stub_log("clEnqueueCopyBufferToImage(%p, %p, %p, %u, %p, %p, %u, %p, %p)\n",
1642                       command_queue,
1643                       src_buffer,
1644                       dst_image,
1645                       src_offset,
1646                       dst_origin,
1647                       region,
1648                       num_events_in_wait_list,
1649                       event_wait_list,
1650                       event);
1651 
1652     test_icd_stub_log("Value returned: %d\n", return_value);
1653     return return_value;
1654 }
1655 
1656 CL_API_ENTRY void * CL_API_CALL
clEnqueueMapBuffer(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_map,cl_map_flags map_flags,size_t offset,size_t cb,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event,cl_int * errcode_ret)1657 clEnqueueMapBuffer(cl_command_queue  command_queue ,
1658                    cl_mem            buffer ,
1659                    cl_bool           blocking_map ,
1660                    cl_map_flags      map_flags ,
1661                    size_t            offset ,
1662                    size_t            cb ,
1663                    cl_uint           num_events_in_wait_list ,
1664                    const cl_event *  event_wait_list ,
1665                    cl_event *        event ,
1666                    cl_int *          errcode_ret) CL_API_SUFFIX__VERSION_1_0
1667 {
1668     void *return_value = (void *) malloc(sizeof(void *));
1669     test_icd_stub_log("clEnqueueMapBuffer(%p, %p, %u, %x, %u, %u, %u, %p, %p, %p)\n",
1670                       command_queue,
1671                       buffer,
1672                       blocking_map,
1673                       map_flags,
1674                       offset,
1675                       cb,
1676                       num_events_in_wait_list,
1677                       event_wait_list,
1678                       event,
1679                       errcode_ret);
1680 
1681     test_icd_stub_log("Value returned: %p\n", return_value);
1682     return return_value;
1683 }
1684 
1685 CL_API_ENTRY void * CL_API_CALL
clEnqueueMapImage(cl_command_queue command_queue,cl_mem image,cl_bool blocking_map,cl_map_flags 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 * errcode_ret)1686 clEnqueueMapImage(cl_command_queue   command_queue ,
1687                   cl_mem             image ,
1688                   cl_bool            blocking_map ,
1689                   cl_map_flags       map_flags ,
1690                   const size_t *     origin ,
1691                   const size_t *     region ,
1692                   size_t *           image_row_pitch ,
1693                   size_t *           image_slice_pitch ,
1694                   cl_uint            num_events_in_wait_list ,
1695                   const cl_event *   event_wait_list ,
1696                   cl_event *         event ,
1697                   cl_int *           errcode_ret) CL_API_SUFFIX__VERSION_1_0
1698 {
1699     void *return_value = (void *) malloc(sizeof(void *));
1700     test_icd_stub_log("clEnqueueMapImage(%p, %p, %u, %x, %p, %p, %p, %p, %u, %p, %p, %p)\n",
1701                       command_queue,
1702                       image,
1703                       blocking_map,
1704                       map_flags,
1705                       origin,
1706                       region,
1707                       image_row_pitch,
1708                       image_slice_pitch,
1709                       num_events_in_wait_list,
1710                       event_wait_list,
1711                       event,
1712                       errcode_ret);
1713 
1714     test_icd_stub_log("Value returned: %p\n", return_value);
1715     return return_value;
1716 }
1717 
1718 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueUnmapMemObject(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)1719 clEnqueueUnmapMemObject(cl_command_queue  command_queue ,
1720                         cl_mem            memobj ,
1721                         void *            mapped_ptr ,
1722                         cl_uint           num_events_in_wait_list ,
1723                         const cl_event *   event_wait_list ,
1724                         cl_event *         event) CL_API_SUFFIX__VERSION_1_0
1725 {
1726     cl_int return_value = CL_OUT_OF_RESOURCES;
1727     test_icd_stub_log("clEnqueueUnmapMemObject(%p, %p, %p, %u, %p, %p)\n",
1728                       command_queue,
1729                       memobj,
1730                       mapped_ptr,
1731                       num_events_in_wait_list,
1732                       event_wait_list,
1733                       event);
1734 
1735     test_icd_stub_log("Value returned: %d\n", return_value);
1736     return return_value;
1737 }
1738 
1739 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueMigrateMemObjects(cl_command_queue command_queue,cl_uint num_mem_objects,const cl_mem * mem_objects,cl_mem_migration_flags flags,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1740 clEnqueueMigrateMemObjects(cl_command_queue        command_queue ,
1741                            cl_uint                 num_mem_objects ,
1742                            const cl_mem *          mem_objects ,
1743                            cl_mem_migration_flags  flags ,
1744                            cl_uint                 num_events_in_wait_list ,
1745                            const cl_event *        event_wait_list ,
1746                            cl_event *              event) CL_API_SUFFIX__VERSION_1_2
1747 {
1748     cl_int return_value = CL_OUT_OF_RESOURCES;
1749     test_icd_stub_log("clEnqueueMigrateMemObjects(%p, %u, %p, %x, %u, %p, %p)\n",
1750                       command_queue,
1751                       num_mem_objects,
1752                       mem_objects,
1753                       flags,
1754                       num_events_in_wait_list,
1755                       event_wait_list,
1756                       event);
1757 
1758     test_icd_stub_log("Value returned: %d\n", return_value);
1759     return return_value;
1760 }
1761 
1762 
1763 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueNDRangeKernel(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)1764 clEnqueueNDRangeKernel(cl_command_queue  command_queue ,
1765                        cl_kernel         kernel ,
1766                        cl_uint           work_dim ,
1767                        const size_t *    global_work_offset ,
1768                        const size_t *    global_work_size ,
1769                        const size_t *    local_work_size ,
1770                        cl_uint           num_events_in_wait_list ,
1771                        const cl_event *  event_wait_list ,
1772                        cl_event *        event) CL_API_SUFFIX__VERSION_1_0
1773 {
1774     cl_int return_value = CL_OUT_OF_RESOURCES;
1775     test_icd_stub_log("clEnqueueNDRangeKernel(%p, %p, %u, %p, %p, %p, %u, %p, %p)\n",
1776                       command_queue,
1777                       kernel,
1778                       work_dim,
1779                       global_work_offset,
1780                       global_work_size,
1781                       local_work_size,
1782                       num_events_in_wait_list,
1783                       event_wait_list,
1784                       event);
1785 
1786     test_icd_stub_log("Value returned: %d\n", return_value);
1787     return return_value;
1788 }
1789 
1790 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueTask(cl_command_queue command_queue,cl_kernel kernel,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1791 clEnqueueTask(cl_command_queue   command_queue ,
1792               cl_kernel          kernel ,
1793               cl_uint            num_events_in_wait_list ,
1794               const cl_event *   event_wait_list ,
1795               cl_event *         event) CL_API_SUFFIX__VERSION_1_0
1796 {
1797     cl_int return_value = CL_OUT_OF_RESOURCES;
1798     test_icd_stub_log("clEnqueueTask(%p, %p, %u, %p, %p)\n",
1799                       command_queue,
1800                       kernel,
1801                       num_events_in_wait_list,
1802                       event_wait_list,
1803                       event);
1804 
1805     test_icd_stub_log("Value returned: %d\n", return_value);
1806     return return_value;
1807 }
1808 
1809 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueNativeKernel(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)1810 clEnqueueNativeKernel(cl_command_queue   command_queue ,
1811                       void (CL_CALLBACK *user_func)(void *),
1812                       void *             args ,
1813                       size_t             cb_args ,
1814                       cl_uint            num_mem_objects ,
1815                       const cl_mem *     mem_list ,
1816                       const void **      args_mem_loc ,
1817                       cl_uint            num_events_in_wait_list ,
1818                       const cl_event *   event_wait_list ,
1819                       cl_event *         event) CL_API_SUFFIX__VERSION_1_0
1820 {
1821     cl_int return_value = CL_OUT_OF_RESOURCES;
1822     test_icd_stub_log("clEnqueueNativeKernel(%p, %p, %p, %u, %u, %p, %p, %u, %p, %p)\n",
1823                       command_queue,
1824                       user_func,
1825                       args,
1826                       cb_args,
1827                       num_mem_objects,
1828                       mem_list,
1829                       args_mem_loc,
1830                       num_events_in_wait_list,
1831                       event_wait_list,
1832                       event);
1833 
1834     test_icd_stub_log("Value returned: %d\n", return_value);
1835     return return_value;
1836 }
1837 
1838 CL_API_ENTRY void * CL_API_CALL
clGetExtensionFunctionAddressForPlatform(cl_platform_id platform,const char * func_name)1839 clGetExtensionFunctionAddressForPlatform(cl_platform_id  platform ,
1840                                          const char *    func_name) CL_API_SUFFIX__VERSION_1_2
1841 {
1842     void *return_value = (void *) malloc(sizeof(void *));
1843     test_icd_stub_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n",
1844                       platform,
1845                       func_name);
1846 
1847     test_icd_stub_log("Value returned: %p\n", return_value);
1848     return return_value;
1849 }
1850 
1851 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueMarkerWithWaitList(cl_command_queue command_queue,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1852 clEnqueueMarkerWithWaitList(cl_command_queue  command_queue ,
1853                             cl_uint            num_events_in_wait_list ,
1854                             const cl_event *   event_wait_list ,
1855                             cl_event *         event) CL_API_SUFFIX__VERSION_1_2
1856 
1857 {
1858     cl_int return_value = CL_OUT_OF_RESOURCES;
1859     test_icd_stub_log("clEnqueueMarkerWithWaitList(%p, %u, %p, %p)\n",
1860                       command_queue,
1861                       num_events_in_wait_list,
1862                       event_wait_list,
1863                       event);
1864 
1865     test_icd_stub_log("Value returned: %d\n", return_value);
1866     return return_value;
1867 }
1868 
1869 extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueBarrierWithWaitList(cl_command_queue command_queue,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1870 clEnqueueBarrierWithWaitList(cl_command_queue  command_queue ,
1871                              cl_uint            num_events_in_wait_list ,
1872                              const cl_event *   event_wait_list ,
1873                              cl_event *         event) CL_API_SUFFIX__VERSION_1_2
1874 {
1875     cl_int return_value = CL_OUT_OF_RESOURCES;
1876     test_icd_stub_log("clEnqueueBarrierWithWaitList(%p, %u, %p, %p)\n",
1877                       command_queue,
1878                       num_events_in_wait_list,
1879                       event_wait_list,
1880                       event);
1881 
1882     test_icd_stub_log("Value returned: %d\n", return_value);
1883     return return_value;
1884 }
1885 
1886 extern CL_API_ENTRY cl_int CL_API_CALL
clSetPrintfCallback(cl_context context,void (CL_CALLBACK * pfn_notify)(cl_context program,cl_uint printf_data_len,char * printf_data_ptr,void * user_data),void * user_data)1887 clSetPrintfCallback(cl_context           context ,
1888                     void (CL_CALLBACK *  pfn_notify)(cl_context  program ,
1889                                                           cl_uint printf_data_len ,
1890                                                           char *  printf_data_ptr ,
1891                                                           void *  user_data),
1892                     void *               user_data) CL_API_SUFFIX__VERSION_1_2
1893 {
1894     cl_int return_value = CL_OUT_OF_RESOURCES;
1895     test_icd_stub_log("clSetPrintfCallback(%p, %p, %p)\n",
1896                       context,
1897                       pfn_notify,
1898                       user_data);
1899     pfn_notify(context, 0, NULL, NULL);
1900     test_icd_stub_log("setprintf_callback(%p, %u, %p, %p)\n",
1901                       context,
1902                       0,
1903                       NULL,
1904                       NULL);
1905     test_icd_stub_log("Value returned: %d\n", return_value);
1906     return return_value;
1907 }
1908 
1909 
1910 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueMarker(cl_command_queue command_queue,cl_event * event)1911 clEnqueueMarker(cl_command_queue     command_queue ,
1912                 cl_event *           event) CL_API_SUFFIX__VERSION_1_0
1913 {
1914     cl_int return_value = CL_OUT_OF_RESOURCES;
1915     test_icd_stub_log("clEnqueueMarker(%p, %p)\n", command_queue, event);
1916     test_icd_stub_log("Value returned: %d\n", return_value);
1917     return return_value;
1918 }
1919 
1920 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueWaitForEvents(cl_command_queue command_queue,cl_uint num_events,const cl_event * event_list)1921 clEnqueueWaitForEvents(cl_command_queue  command_queue ,
1922                        cl_uint           num_events ,
1923                        const cl_event *  event_list) CL_API_SUFFIX__VERSION_1_0
1924 {
1925     cl_int return_value = CL_OUT_OF_RESOURCES;
1926     test_icd_stub_log("clEnqueueWaitForEvents(%p, %u, %p)\n",
1927                       command_queue,
1928                       num_events,
1929                       event_list);
1930 
1931     test_icd_stub_log("Value returned: %d\n", return_value);
1932     return return_value;
1933 }
1934 
1935 CL_API_ENTRY cl_int CL_API_CALL
clEnqueueBarrier(cl_command_queue command_queue)1936 clEnqueueBarrier(cl_command_queue  command_queue) CL_API_SUFFIX__VERSION_1_0
1937 {
1938     cl_int return_value = CL_OUT_OF_RESOURCES;
1939     test_icd_stub_log("clEnqueueBarrier(%p)\n", command_queue);
1940     test_icd_stub_log("Value returned: %d\n", return_value);
1941     return return_value;
1942 }
1943 
1944 extern cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable);
1945 
1946 CL_API_ENTRY cl_int CL_API_CALL
clIcdGetPlatformIDsKHR(cl_uint num_entries,cl_platform_id * platforms,cl_uint * num_platforms)1947 clIcdGetPlatformIDsKHR(cl_uint           num_entries,
1948                        cl_platform_id * platforms,
1949                        cl_uint *        num_platforms)
1950 {
1951     cl_int result = CL_SUCCESS;
1952     if (!initialized) {
1953         result = cliIcdDispatchTableCreate(&dispatchTable);
1954         platform = (cl_platform_id) malloc(sizeof(struct _cl_platform_id));
1955         memset(platform, 0, sizeof(struct _cl_platform_id));
1956 
1957         platform->dispatch = dispatchTable;
1958         platform->version = "OpenCL 1.2 Stub";
1959         platform->vendor = "stubvendorxxx";
1960         platform->profile = "stubprofilexxx";
1961         platform->name = "ICD_LOADER_TEST_OPENCL_STUB";
1962         platform->extensions = "cl_khr_icd cl_khr_gl cl_khr_d3d10";
1963         platform->suffix = "ilts";
1964         platform->dispatch = dispatchTable;
1965         initialized = CL_TRUE;
1966     }
1967 
1968     if ((platforms && num_entries >1) ||
1969         (platforms && num_entries <= 0) ||
1970         (!platforms && num_entries >= 1)) {
1971         result = CL_INVALID_VALUE;
1972         goto Done;
1973     }
1974 
1975     if (platforms && num_entries == 1) {
1976         platforms[0] = platform;
1977     }
1978 
1979 Done:
1980     if (num_platforms) {
1981         *num_platforms = 1;
1982     }
1983 
1984     return result;
1985 }
1986 
1987