blob: cc2391977b402e2fd2017a3e3014c4b7e5106ebd [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#include "arm_compute/core/CL/OpenCL.h"
26
27#include <dlfcn.h>
28#include <iostream>
29
Moritz Pflanzer725788e2017-07-07 15:35:56 +010030namespace arm_compute
Anthony Barbier6ff3b192017-09-04 18:44:23 +010031{
Moritz Pflanzer725788e2017-07-07 15:35:56 +010032CLSymbols &CLSymbols::get()
33{
34 static CLSymbols symbols;
35 return symbols;
36}
37
38bool CLSymbols::load_default()
39{
40 static const std::vector<std::string> libraries{ "libOpenCL.so", "libGLES_mali.so", "libmali.so" };
41
42 if(_loaded.first)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010043 {
Moritz Pflanzer725788e2017-07-07 15:35:56 +010044 return _loaded.second;
45 }
46
47 // Indicate that default loading has been tried
48 _loaded.first = true;
49
50 for(const auto &lib : libraries)
51 {
52 if(load(lib))
Anthony Barbier6ff3b192017-09-04 18:44:23 +010053 {
Moritz Pflanzer725788e2017-07-07 15:35:56 +010054 return true;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010055 }
56 }
57
Moritz Pflanzer725788e2017-07-07 15:35:56 +010058 std::cerr << "Couldn't find any OpenCL library.\n";
59 return false;
60}
61
62bool CLSymbols::load(const std::string &library)
63{
64 void *handle = dlopen(library.c_str(), RTLD_LAZY | RTLD_LOCAL);
65
66 if(handle == nullptr)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010067 {
Moritz Pflanzer725788e2017-07-07 15:35:56 +010068 std::cerr << "Can't load " << library << ": " << dlerror() << "\n";
69 // Set status of loading to failed
70 _loaded.second = false;
71 return false;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072 }
73
Moritz Pflanzer725788e2017-07-07 15:35:56 +010074 clBuildProgram = reinterpret_cast<clBuildProgram_func>(dlsym(handle, "clBuildProgram"));
75 clEnqueueNDRangeKernel = reinterpret_cast<clEnqueueNDRangeKernel_func>(dlsym(handle, "clEnqueueNDRangeKernel"));
76 clSetKernelArg = reinterpret_cast<clSetKernelArg_func>(dlsym(handle, "clSetKernelArg"));
77 clReleaseKernel = reinterpret_cast<clReleaseKernel_func>(dlsym(handle, "clReleaseKernel"));
78 clCreateProgramWithSource = reinterpret_cast<clCreateProgramWithSource_func>(dlsym(handle, "clCreateProgramWithSource"));
79 clCreateBuffer = reinterpret_cast<clCreateBuffer_func>(dlsym(handle, "clCreateBuffer"));
80 clRetainKernel = reinterpret_cast<clRetainKernel_func>(dlsym(handle, "clRetainKernel"));
81 clCreateKernel = reinterpret_cast<clCreateKernel_func>(dlsym(handle, "clCreateKernel"));
82 clGetProgramInfo = reinterpret_cast<clGetProgramInfo_func>(dlsym(handle, "clGetProgramInfo"));
83 clFlush = reinterpret_cast<clFlush_func>(dlsym(handle, "clFlush"));
Gian Marco Iodice63d76a72017-08-11 11:56:52 +010084 clFinish = reinterpret_cast<clFinish_func>(dlsym(handle, "clFinish"));
Moritz Pflanzer725788e2017-07-07 15:35:56 +010085 clReleaseProgram = reinterpret_cast<clReleaseProgram_func>(dlsym(handle, "clReleaseProgram"));
86 clRetainContext = reinterpret_cast<clRetainContext_func>(dlsym(handle, "clRetainContext"));
87 clCreateProgramWithBinary = reinterpret_cast<clCreateProgramWithBinary_func>(dlsym(handle, "clCreateProgramWithBinary"));
88 clReleaseCommandQueue = reinterpret_cast<clReleaseCommandQueue_func>(dlsym(handle, "clReleaseCommandQueue"));
89 clEnqueueMapBuffer = reinterpret_cast<clEnqueueMapBuffer_func>(dlsym(handle, "clEnqueueMapBuffer"));
90 clRetainProgram = reinterpret_cast<clRetainProgram_func>(dlsym(handle, "clRetainProgram"));
91 clGetProgramBuildInfo = reinterpret_cast<clGetProgramBuildInfo_func>(dlsym(handle, "clGetProgramBuildInfo"));
92 clEnqueueReadBuffer = reinterpret_cast<clEnqueueReadBuffer_func>(dlsym(handle, "clEnqueueReadBuffer"));
93 clEnqueueWriteBuffer = reinterpret_cast<clEnqueueWriteBuffer_func>(dlsym(handle, "clEnqueueWriteBuffer"));
94 clReleaseEvent = reinterpret_cast<clReleaseEvent_func>(dlsym(handle, "clReleaseEvent"));
95 clReleaseContext = reinterpret_cast<clReleaseContext_func>(dlsym(handle, "clReleaseContext"));
96 clRetainCommandQueue = reinterpret_cast<clRetainCommandQueue_func>(dlsym(handle, "clRetainCommandQueue"));
97 clEnqueueUnmapMemObject = reinterpret_cast<clEnqueueUnmapMemObject_func>(dlsym(handle, "clEnqueueUnmapMemObject"));
Georgios Pinitasbaf174e2017-09-08 19:47:30 +010098 clRetainMemObject = reinterpret_cast<clRetainMemObject_func>(dlsym(handle, "clRetainMemObject"));
Moritz Pflanzer725788e2017-07-07 15:35:56 +010099 clReleaseMemObject = reinterpret_cast<clReleaseMemObject_func>(dlsym(handle, "clReleaseMemObject"));
100 clGetDeviceInfo = reinterpret_cast<clGetDeviceInfo_func>(dlsym(handle, "clGetDeviceInfo"));
101 clGetDeviceIDs = reinterpret_cast<clGetDeviceIDs_func>(dlsym(handle, "clGetDeviceIDs"));
Giorgio Arena9fe41442017-08-23 16:36:24 +0100102 clRetainEvent = reinterpret_cast<clRetainEvent_func>(dlsym(handle, "clRetainEvent"));
steniu01f01f9de2017-09-27 17:00:11 +0100103 clGetPlatformIDs = reinterpret_cast<clGetPlatformIDs_func>(dlsym(handle, "clGetPlatformIDs"));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100104
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100105 dlclose(handle);
106
107 // Disable default loading and set status to successful
108 _loaded = std::make_pair(true, true);
109
110 return true;
111}
112
113bool opencl_is_available()
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100114{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100115 CLSymbols::get().load_default();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100116 return CLSymbols::get().clBuildProgram != nullptr;
117}
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100118} // namespace arm_compute
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100119
120cl_int clBuildProgram(
121 cl_program program,
122 cl_uint num_devices,
123 const cl_device_id *device_list,
124 const char *options,
125 void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data),
126 void *user_data)
127{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100128 arm_compute::CLSymbols::get().load_default();
129 auto func = arm_compute::CLSymbols::get().clBuildProgram;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100130 if(func != nullptr)
131 {
132 return func(program, num_devices, device_list, options, pfn_notify, user_data);
133 }
134 else
135 {
136 return CL_OUT_OF_RESOURCES;
137 }
138}
139
140cl_int clEnqueueNDRangeKernel(
141 cl_command_queue command_queue,
142 cl_kernel kernel,
143 cl_uint work_dim,
144 const size_t *global_work_offset,
145 const size_t *global_work_size,
146 const size_t *local_work_size,
147 cl_uint num_events_in_wait_list,
148 const cl_event *event_wait_list,
149 cl_event *event)
150{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100151 arm_compute::CLSymbols::get().load_default();
152 auto func = arm_compute::CLSymbols::get().clEnqueueNDRangeKernel;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100153 if(func != nullptr)
154 {
155 return func(command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_events_in_wait_list, event_wait_list, event);
156 }
157 else
158 {
159 return CL_OUT_OF_RESOURCES;
160 }
161}
162
163cl_int clSetKernelArg(
164 cl_kernel kernel,
165 cl_uint arg_index,
166 size_t arg_size,
167 const void *arg_value)
168{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100169 arm_compute::CLSymbols::get().load_default();
170 auto func = arm_compute::CLSymbols::get().clSetKernelArg;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100171 if(func != nullptr)
172 {
173 return func(kernel, arg_index, arg_size, arg_value);
174 }
175 else
176 {
177 return CL_OUT_OF_RESOURCES;
178 }
179}
180
Georgios Pinitasbaf174e2017-09-08 19:47:30 +0100181cl_int clRetainMemObject(cl_mem memobj)
182{
183 arm_compute::CLSymbols::get().load_default();
184 auto func = arm_compute::CLSymbols::get().clRetainMemObject;
185 if(func != nullptr)
186 {
187 return func(memobj);
188 }
189 else
190 {
191 return CL_OUT_OF_RESOURCES;
192 }
193}
194
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100195cl_int clReleaseMemObject(cl_mem memobj)
196{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100197 arm_compute::CLSymbols::get().load_default();
198 auto func = arm_compute::CLSymbols::get().clReleaseMemObject;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100199 if(func != nullptr)
200 {
201 return func(memobj);
202 }
203 else
204 {
205 return CL_OUT_OF_RESOURCES;
206 }
207}
208
209cl_int clEnqueueUnmapMemObject(
210 cl_command_queue command_queue,
211 cl_mem memobj,
212 void *mapped_ptr,
213 cl_uint num_events_in_wait_list,
214 const cl_event *event_wait_list,
215 cl_event *event)
216{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100217 arm_compute::CLSymbols::get().load_default();
218 auto func = arm_compute::CLSymbols::get().clEnqueueUnmapMemObject;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100219 if(func != nullptr)
220 {
221 return func(command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
222 }
223 else
224 {
225 return CL_OUT_OF_RESOURCES;
226 }
227}
228
229cl_int clRetainCommandQueue(cl_command_queue command_queue)
230{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100231 arm_compute::CLSymbols::get().load_default();
232 auto func = arm_compute::CLSymbols::get().clRetainCommandQueue;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100233 if(func != nullptr)
234 {
235 return func(command_queue);
236 }
237 else
238 {
239 return CL_OUT_OF_RESOURCES;
240 }
241}
242
243cl_int clReleaseContext(cl_context context)
244{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100245 arm_compute::CLSymbols::get().load_default();
246 auto func = arm_compute::CLSymbols::get().clReleaseContext;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100247 if(func != nullptr)
248 {
249 return func(context);
250 }
251 else
252 {
253 return CL_OUT_OF_RESOURCES;
254 }
255}
256cl_int clReleaseEvent(cl_event event)
257{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100258 arm_compute::CLSymbols::get().load_default();
259 auto func = arm_compute::CLSymbols::get().clReleaseEvent;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100260 if(func != nullptr)
261 {
262 return func(event);
263 }
264 else
265 {
266 return CL_OUT_OF_RESOURCES;
267 }
268}
269
270cl_int clEnqueueWriteBuffer(
271 cl_command_queue command_queue,
272 cl_mem buffer,
273 cl_bool blocking_write,
274 size_t offset,
275 size_t size,
276 const void *ptr,
277 cl_uint num_events_in_wait_list,
278 const cl_event *event_wait_list,
279 cl_event *event)
280{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100281 arm_compute::CLSymbols::get().load_default();
282 auto func = arm_compute::CLSymbols::get().clEnqueueWriteBuffer;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100283 if(func != nullptr)
284 {
285 return func(command_queue, buffer, blocking_write, offset, size, ptr, num_events_in_wait_list, event_wait_list, event);
286 }
287 else
288 {
289 return CL_OUT_OF_RESOURCES;
290 }
291}
292
293cl_int clEnqueueReadBuffer(
294 cl_command_queue command_queue,
295 cl_mem buffer,
296 cl_bool blocking_read,
297 size_t offset,
298 size_t size,
299 void *ptr,
300 cl_uint num_events_in_wait_list,
301 const cl_event *event_wait_list,
302 cl_event *event)
303{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100304 arm_compute::CLSymbols::get().load_default();
305 auto func = arm_compute::CLSymbols::get().clEnqueueReadBuffer;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100306 if(func != nullptr)
307 {
308 return func(command_queue, buffer, blocking_read, offset, size, ptr, num_events_in_wait_list, event_wait_list, event);
309 }
310 else
311 {
312 return CL_OUT_OF_RESOURCES;
313 }
314}
315
316cl_int clGetProgramBuildInfo(
317 cl_program program,
318 cl_device_id device,
319 cl_program_build_info param_name,
320 size_t param_value_size,
321 void *param_value,
322 size_t *param_value_size_ret)
323{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100324 arm_compute::CLSymbols::get().load_default();
325 auto func = arm_compute::CLSymbols::get().clGetProgramBuildInfo;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100326 if(func != nullptr)
327 {
328 return func(program, device, param_name, param_value_size, param_value, param_value_size_ret);
329 }
330 else
331 {
332 return CL_OUT_OF_RESOURCES;
333 }
334}
335
336cl_int clRetainProgram(cl_program program)
337{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100338 arm_compute::CLSymbols::get().load_default();
339 auto func = arm_compute::CLSymbols::get().clRetainProgram;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100340 if(func != nullptr)
341 {
342 return func(program);
343 }
344 else
345 {
346 return CL_OUT_OF_RESOURCES;
347 }
348}
349
350void *clEnqueueMapBuffer(
351 cl_command_queue command_queue,
352 cl_mem buffer,
353 cl_bool blocking_map,
354 cl_map_flags map_flags,
355 size_t offset,
356 size_t size,
357 cl_uint num_events_in_wait_list,
358 const cl_event *event_wait_list,
359 cl_event *event,
360 cl_int *errcode_ret)
361{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100362 arm_compute::CLSymbols::get().load_default();
363 auto func = arm_compute::CLSymbols::get().clEnqueueMapBuffer;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100364 if(func != nullptr)
365 {
366 return func(command_queue, buffer, blocking_map, map_flags, offset, size, num_events_in_wait_list, event_wait_list, event, errcode_ret);
367 }
368 else
369 {
370 if(errcode_ret != nullptr)
371 {
372 *errcode_ret = CL_OUT_OF_RESOURCES;
373 }
374 return nullptr;
375 }
376}
377
378cl_int clReleaseCommandQueue(cl_command_queue command_queue)
379{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100380 arm_compute::CLSymbols::get().load_default();
381 auto func = arm_compute::CLSymbols::get().clReleaseCommandQueue;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100382 if(func != nullptr)
383 {
384 return func(command_queue);
385 }
386 else
387 {
388 return CL_OUT_OF_RESOURCES;
389 }
390}
391
392cl_program clCreateProgramWithBinary(
393 cl_context context,
394 cl_uint num_devices,
395 const cl_device_id *device_list,
396 const size_t *lengths,
397 const unsigned char **binaries,
398 cl_int *binary_status,
399 cl_int *errcode_ret)
400{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100401 arm_compute::CLSymbols::get().load_default();
402 auto func = arm_compute::CLSymbols::get().clCreateProgramWithBinary;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100403 if(func != nullptr)
404 {
405 return func(context, num_devices, device_list, lengths, binaries, binary_status, errcode_ret);
406 }
407 else
408 {
409 if(errcode_ret != nullptr)
410 {
411 *errcode_ret = CL_OUT_OF_RESOURCES;
412 }
413 return nullptr;
414 }
415}
416
417cl_int clRetainContext(cl_context context)
418{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100419 arm_compute::CLSymbols::get().load_default();
420 auto func = arm_compute::CLSymbols::get().clRetainContext;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100421 if(func != nullptr)
422 {
423 return func(context);
424 }
425 else
426 {
427 return CL_OUT_OF_RESOURCES;
428 }
429}
430
431cl_int clReleaseProgram(cl_program program)
432{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100433 arm_compute::CLSymbols::get().load_default();
434 auto func = arm_compute::CLSymbols::get().clReleaseProgram;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100435 if(func != nullptr)
436 {
437 return func(program);
438 }
439 else
440 {
441 return CL_OUT_OF_RESOURCES;
442 }
443}
444
445cl_int clFlush(cl_command_queue command_queue)
446{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100447 arm_compute::CLSymbols::get().load_default();
448 auto func = arm_compute::CLSymbols::get().clFlush;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100449 if(func != nullptr)
450 {
451 return func(command_queue);
452 }
453 else
454 {
455 return CL_OUT_OF_RESOURCES;
456 }
457}
458
Gian Marco Iodice63d76a72017-08-11 11:56:52 +0100459cl_int clFinish(cl_command_queue command_queue)
460{
461 arm_compute::CLSymbols::get().load_default();
462 auto func = arm_compute::CLSymbols::get().clFinish;
463 if(func != nullptr)
464 {
465 return func(command_queue);
466 }
467 else
468 {
469 return CL_OUT_OF_RESOURCES;
470 }
471}
472
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100473cl_int clGetProgramInfo(
474 cl_program program,
475 cl_program_info param_name,
476 size_t param_value_size,
477 void *param_value,
478 size_t *param_value_size_ret)
479{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100480 arm_compute::CLSymbols::get().load_default();
481 auto func = arm_compute::CLSymbols::get().clGetProgramInfo;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100482 if(func != nullptr)
483 {
484 return func(program, param_name, param_value_size, param_value, param_value_size_ret);
485 }
486 else
487 {
488 return CL_OUT_OF_RESOURCES;
489 }
490}
491
492cl_kernel clCreateKernel(
493 cl_program program,
494 const char *kernel_name,
495 cl_int *errcode_ret)
496{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100497 arm_compute::CLSymbols::get().load_default();
498 auto func = arm_compute::CLSymbols::get().clCreateKernel;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100499 if(func != nullptr)
500 {
501 return func(program, kernel_name, errcode_ret);
502 }
503 else
504 {
505 if(errcode_ret != nullptr)
506 {
507 *errcode_ret = CL_OUT_OF_RESOURCES;
508 }
509 return nullptr;
510 }
511}
512
513cl_int clRetainKernel(cl_kernel kernel)
514{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100515 arm_compute::CLSymbols::get().load_default();
516 auto func = arm_compute::CLSymbols::get().clRetainKernel;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100517 if(func != nullptr)
518 {
519 return func(kernel);
520 }
521 else
522 {
523 return CL_OUT_OF_RESOURCES;
524 }
525}
526
527cl_mem clCreateBuffer(
528 cl_context context,
529 cl_mem_flags flags,
530 size_t size,
531 void *host_ptr,
532 cl_int *errcode_ret)
533{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100534 arm_compute::CLSymbols::get().load_default();
535 auto func = arm_compute::CLSymbols::get().clCreateBuffer;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100536 if(func != nullptr)
537 {
538 return func(context, flags, size, host_ptr, errcode_ret);
539 }
540 else
541 {
542 if(errcode_ret != nullptr)
543 {
544 *errcode_ret = CL_OUT_OF_RESOURCES;
545 }
546 return nullptr;
547 }
548}
549
550cl_program clCreateProgramWithSource(
551 cl_context context,
552 cl_uint count,
553 const char **strings,
554 const size_t *lengths,
555 cl_int *errcode_ret)
556{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100557 arm_compute::CLSymbols::get().load_default();
558 auto func = arm_compute::CLSymbols::get().clCreateProgramWithSource;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100559 if(func != nullptr)
560 {
561 return func(context, count, strings, lengths, errcode_ret);
562 }
563 else
564 {
565 if(errcode_ret != nullptr)
566 {
567 *errcode_ret = CL_OUT_OF_RESOURCES;
568 }
569 return nullptr;
570 }
571}
572
573cl_int clReleaseKernel(cl_kernel kernel)
574{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100575 arm_compute::CLSymbols::get().load_default();
576 auto func = arm_compute::CLSymbols::get().clReleaseKernel;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100577 if(func != nullptr)
578 {
579 return func(kernel);
580 }
581 else
582 {
583 return CL_OUT_OF_RESOURCES;
584 }
585}
586
587cl_int clGetDeviceIDs(cl_platform_id platform,
588 cl_device_type device_type,
589 cl_uint num_entries,
590 cl_device_id *devices,
591 cl_uint *num_devices)
592{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100593 arm_compute::CLSymbols::get().load_default();
594 auto func = arm_compute::CLSymbols::get().clGetDeviceIDs;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100595 if(func != nullptr)
596 {
597 return func(platform, device_type, num_entries, devices, num_devices);
598 }
599 else
600 {
601 return CL_OUT_OF_RESOURCES;
602 }
603}
604
605cl_int clGetDeviceInfo(cl_device_id device,
606 cl_device_info param_name,
607 size_t param_value_size,
608 void *param_value,
609 size_t *param_value_size_ret)
610{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100611 arm_compute::CLSymbols::get().load_default();
612 auto func = arm_compute::CLSymbols::get().clGetDeviceInfo;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100613 if(func != nullptr)
614 {
615 return func(device, param_name, param_value_size, param_value, param_value_size_ret);
616 }
617 else
618 {
619 return CL_OUT_OF_RESOURCES;
620 }
621}
Giorgio Arena9fe41442017-08-23 16:36:24 +0100622
623cl_int clRetainEvent(cl_event event)
624{
Moritz Pflanzer159b6da2017-09-20 16:03:35 +0100625 arm_compute::CLSymbols::get().load_default();
Giorgio Arena9fe41442017-08-23 16:36:24 +0100626 auto func = arm_compute::CLSymbols::get().clRetainEvent;
627 if(func != nullptr)
628 {
629 return func(event);
630 }
631 else
632 {
633 return CL_OUT_OF_RESOURCES;
634 }
635}
steniu01f01f9de2017-09-27 17:00:11 +0100636
637cl_int clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
638{
639 arm_compute::CLSymbols::get().load_default();
640 auto func = arm_compute::CLSymbols::get().clGetPlatformIDs;
641 if(func != nullptr)
642 {
643 return func(num_entries, platforms, num_platforms);
644 }
645 else
646 {
647 return CL_OUT_OF_RESOURCES;
648 }
649}