blob: b092dfb4e28bb523cdfbb3c3ab55a3faeb03b8ec [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Ramy Elgammala7db3562023-04-19 18:49:44 +01002 * Copyright (c) 2017-2023 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
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
Michalis Spyrou6bff1952019-10-02 17:22:11 +010025#pragma GCC diagnostic push
26#pragma GCC diagnostic ignored "-Wunused-parameter"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010027#include "arm_compute/core/CL/OpenCL.h"
Michalis Spyrou6bff1952019-10-02 17:22:11 +010028#pragma GCC diagnostic pop
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029
Pablo Tellodb8485a2019-09-24 11:03:47 +010030#include "arm_compute/core/Error.h"
31
Ramy Elgammala7db3562023-04-19 18:49:44 +010032#include <algorithm>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010033#include <dlfcn.h>
34#include <iostream>
Ramy Elgammala7db3562023-04-19 18:49:44 +010035#include <sstream>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036
Moritz Pflanzer725788e2017-07-07 15:35:56 +010037namespace arm_compute
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038{
Georgios Pinitas0b192e82020-02-20 17:09:28 +000039CLSymbols::CLSymbols() noexcept(false)
40 : _loaded(
41{
42 false, false
Georgios Pinitas42bd2652021-03-12 18:40:30 +000043})
Georgios Pinitas0b192e82020-02-20 17:09:28 +000044{
45}
46
Moritz Pflanzer725788e2017-07-07 15:35:56 +010047CLSymbols &CLSymbols::get()
48{
49 static CLSymbols symbols;
50 return symbols;
51}
52
53bool CLSymbols::load_default()
54{
Ramy Elgammala7db3562023-04-19 18:49:44 +010055 static const std::vector<std::string> libraries_filenames{ "libOpenCL.so", "libGLES_mali.so", "libmali.so" };
Moritz Pflanzer725788e2017-07-07 15:35:56 +010056
57 if(_loaded.first)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010058 {
Moritz Pflanzer725788e2017-07-07 15:35:56 +010059 return _loaded.second;
60 }
61
62 // Indicate that default loading has been tried
63 _loaded.first = true;
64
Ramy Elgammala7db3562023-04-19 18:49:44 +010065 if(load(libraries_filenames, /* use_loader */ false))
Moritz Pflanzer725788e2017-07-07 15:35:56 +010066 {
Ramy Elgammala7db3562023-04-19 18:49:44 +010067 ARM_COMPUTE_ERROR_ON_MSG(this->clBuildProgram_ptr == nullptr, "Failed to load OpenCL symbols from shared library");
68 return true;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010069 }
70
ohadagoogle3efdfb32022-06-20 16:16:13 +000071#ifdef __ANDROID__
72 // When running in NDK environment, the above libraries are not accessible.
Ramy Elgammala7db3562023-04-19 18:49:44 +010073 static const std::vector<std::string> android_libraries_filenames{ "libOpenCL-pixel.so", "libOpenCL-car.so" };
ohadagoogle3efdfb32022-06-20 16:16:13 +000074
Ramy Elgammala7db3562023-04-19 18:49:44 +010075 if(load(android_libraries_filenames, /* use_loader */ true))
ohadagoogle3efdfb32022-06-20 16:16:13 +000076 {
Ramy Elgammala7db3562023-04-19 18:49:44 +010077 ARM_COMPUTE_ERROR_ON_MSG(this->clBuildProgram_ptr == nullptr, "Failed to load OpenCL symbols from android shared library");
78 return true;
ohadagoogle3efdfb32022-06-20 16:16:13 +000079 }
Ramy Elgammala7db3562023-04-19 18:49:44 +010080#endif // __ANDROID__
ohadagoogle3efdfb32022-06-20 16:16:13 +000081
Ramy Elgammala7db3562023-04-19 18:49:44 +010082 // If not returned till here then libraries not found
83 std::stringstream ss;
84 std::for_each(libraries_filenames.begin(), libraries_filenames.end(), [&ss](const std::string & s)
85 {
86 ss << s << " ";
87 });
88#ifdef __ANDROID__
89 std::for_each(android_libraries_filenames.begin(), android_libraries_filenames.end(), [&ss](const std::string & s)
90 {
91 ss << s << " ";
92 });
93#endif // __ANDROID__
94 std::cerr << "Couldn't find any of the following OpenCL library: " << ss.str() << std::endl;
Moritz Pflanzer725788e2017-07-07 15:35:56 +010095 return false;
96}
97
Ramy Elgammala7db3562023-04-19 18:49:44 +010098bool CLSymbols::load(const std::vector<std::string> &libraries_filenames, bool use_loader)
Moritz Pflanzer725788e2017-07-07 15:35:56 +010099{
Ramy Elgammala7db3562023-04-19 18:49:44 +0100100 void *handle = nullptr;
101 unsigned int index = 0;
102 for(index = 0; index < libraries_filenames.size(); ++index)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100103 {
Ramy Elgammala7db3562023-04-19 18:49:44 +0100104 handle = dlopen(libraries_filenames[index].c_str(), RTLD_LAZY | RTLD_LOCAL);
105 if(handle != nullptr)
106 {
107 break;
108 }
109 }
Omar Al Khatibf15c6152023-05-17 08:42:28 +0000110 if(index == libraries_filenames.size())
Ramy Elgammala7db3562023-04-19 18:49:44 +0100111 {
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100112 // Set status of loading to failed
113 _loaded.second = false;
114 return false;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100115 }
116
ohadagoogle3efdfb32022-06-20 16:16:13 +0000117#ifdef __ANDROID__
118 typedef void* (*loadOpenCLPointer_t)(const char* name);
119 loadOpenCLPointer_t loadOpenCLPointer;
120 if (use_loader) {
121 typedef void (*enableOpenCL_t)();
122 enableOpenCL_t enableOpenCL =
123 reinterpret_cast<enableOpenCL_t>(dlsym(handle, "enableOpenCL"));
124 enableOpenCL();
125
126 loadOpenCLPointer = reinterpret_cast<loadOpenCLPointer_t>(
127 dlsym(handle, "loadOpenCLPointer"));
128 } else {
129 loadOpenCLPointer = nullptr;
130 }
131#define LOAD_FUNCTION_PTR(func_name, _handle) \
132 func_name##_ptr = reinterpret_cast<decltype(func_name) *>( use_loader ? \
133 loadOpenCLPointer(#func_name) : dlsym(handle, #func_name));
134#else /* __ANDROID__ */
135 (void)use_loader; // Avoid unused warning
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000136#define LOAD_FUNCTION_PTR(func_name, handle) \
137 func_name##_ptr = reinterpret_cast<decltype(func_name) *>(dlsym(handle, #func_name));
ohadagoogle3efdfb32022-06-20 16:16:13 +0000138#endif /* __ANDROID__ */
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000139
Georgios Pinitas42bd2652021-03-12 18:40:30 +0000140 LOAD_FUNCTION_PTR(clCreateContext, handle);
141 LOAD_FUNCTION_PTR(clCreateContextFromType, handle);
142 LOAD_FUNCTION_PTR(clCreateCommandQueue, handle);
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000143 LOAD_FUNCTION_PTR(clCreateCommandQueueWithProperties, handle);
Georgios Pinitas42bd2652021-03-12 18:40:30 +0000144 LOAD_FUNCTION_PTR(clGetContextInfo, handle);
145 LOAD_FUNCTION_PTR(clBuildProgram, handle);
146 LOAD_FUNCTION_PTR(clEnqueueNDRangeKernel, handle);
147 LOAD_FUNCTION_PTR(clSetKernelArg, handle);
148 LOAD_FUNCTION_PTR(clReleaseKernel, handle);
149 LOAD_FUNCTION_PTR(clCreateProgramWithSource, handle);
150 LOAD_FUNCTION_PTR(clCreateBuffer, handle);
151 LOAD_FUNCTION_PTR(clRetainKernel, handle);
152 LOAD_FUNCTION_PTR(clCreateKernel, handle);
153 LOAD_FUNCTION_PTR(clGetProgramInfo, handle);
154 LOAD_FUNCTION_PTR(clFlush, handle);
155 LOAD_FUNCTION_PTR(clFinish, handle);
156 LOAD_FUNCTION_PTR(clReleaseProgram, handle);
157 LOAD_FUNCTION_PTR(clRetainContext, handle);
158 LOAD_FUNCTION_PTR(clCreateProgramWithBinary, handle);
159 LOAD_FUNCTION_PTR(clReleaseCommandQueue, handle);
160 LOAD_FUNCTION_PTR(clEnqueueMapBuffer, handle);
161 LOAD_FUNCTION_PTR(clRetainProgram, handle);
162 LOAD_FUNCTION_PTR(clGetProgramBuildInfo, handle);
163 LOAD_FUNCTION_PTR(clEnqueueReadBuffer, handle);
164 LOAD_FUNCTION_PTR(clEnqueueWriteBuffer, handle);
165 LOAD_FUNCTION_PTR(clReleaseEvent, handle);
166 LOAD_FUNCTION_PTR(clReleaseContext, handle);
167 LOAD_FUNCTION_PTR(clRetainCommandQueue, handle);
168 LOAD_FUNCTION_PTR(clEnqueueUnmapMemObject, handle);
169 LOAD_FUNCTION_PTR(clRetainMemObject, handle);
170 LOAD_FUNCTION_PTR(clReleaseMemObject, handle);
171 LOAD_FUNCTION_PTR(clGetDeviceInfo, handle);
172 LOAD_FUNCTION_PTR(clGetDeviceIDs, handle);
173 LOAD_FUNCTION_PTR(clGetMemObjectInfo, handle);
174 LOAD_FUNCTION_PTR(clRetainEvent, handle);
Michalis Spyrou402740d2021-04-20 11:26:21 +0100175 LOAD_FUNCTION_PTR(clGetPlatformInfo, handle);
Georgios Pinitas42bd2652021-03-12 18:40:30 +0000176 LOAD_FUNCTION_PTR(clGetPlatformIDs, handle);
177 LOAD_FUNCTION_PTR(clGetKernelWorkGroupInfo, handle);
178 LOAD_FUNCTION_PTR(clGetCommandQueueInfo, handle);
179 LOAD_FUNCTION_PTR(clGetKernelInfo, handle);
180 LOAD_FUNCTION_PTR(clGetEventProfilingInfo, handle);
181 LOAD_FUNCTION_PTR(clSVMAlloc, handle);
182 LOAD_FUNCTION_PTR(clSVMFree, handle);
183 LOAD_FUNCTION_PTR(clEnqueueSVMMap, handle);
184 LOAD_FUNCTION_PTR(clEnqueueSVMUnmap, handle);
185 LOAD_FUNCTION_PTR(clEnqueueMarker, handle);
186 LOAD_FUNCTION_PTR(clWaitForEvents, handle);
187 LOAD_FUNCTION_PTR(clCreateImage, handle);
188 LOAD_FUNCTION_PTR(clSetKernelExecInfo, handle);
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000189
Viet-Hoa Do500e10b2023-09-12 17:49:38 +0100190 // Command buffer and mutable dispatch command buffer extensions
191 LOAD_FUNCTION_PTR(clCreateCommandBufferKHR, handle);
192 LOAD_FUNCTION_PTR(clRetainCommandBufferKHR, handle);
193 LOAD_FUNCTION_PTR(clReleaseCommandBufferKHR, handle);
194 LOAD_FUNCTION_PTR(clFinalizeCommandBufferKHR, handle);
195 LOAD_FUNCTION_PTR(clEnqueueCommandBufferKHR, handle);
196 LOAD_FUNCTION_PTR(clCommandNDRangeKernelKHR, handle);
197
198 LOAD_FUNCTION_PTR(clUpdateMutableCommandsKHR, handle);
199
Georgios Pinitas4d0351c2019-04-03 15:11:16 +0100200 // Third-party extensions
Georgios Pinitas42bd2652021-03-12 18:40:30 +0000201 LOAD_FUNCTION_PTR(clImportMemoryARM, handle);
Georgios Pinitas4d0351c2019-04-03 15:11:16 +0100202
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000203#undef LOAD_FUNCTION_PTR
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100204
Georgios Pinitas42bd2652021-03-12 18:40:30 +0000205 //Don't call dlclose(handle) or all the symbols will be unloaded !
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100206
207 // Disable default loading and set status to successful
208 _loaded = std::make_pair(true, true);
209
210 return true;
211}
212
213bool opencl_is_available()
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100214{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100215 CLSymbols::get().load_default();
Marco Antognini4a5f73d2021-03-23 16:59:08 +0000216
217 // Using static objects that rely on OpenCL in their constructor or
218 // destructor is implementation defined according to the OpenCL API
219 // Specification. These objects include CLScheduler.
220 //
221 // For compatibility with OpenCL runtimes that also use static objects to
222 // hold their state, we call a harmless OpenCL function (clGetPlatformIDs
223 // with invalid parameters must result in CL_INVALID_VALUE) to ensure the
224 // runtimes have a chance to initialize their static objects first. Thanks
ramelg01b2eba7f2021-12-23 08:32:08 +0000225 // to C++11 rules about normal program completion (cf [basic.start]), this
Marco Antognini4a5f73d2021-03-23 16:59:08 +0000226 // ensures their static objects are destroyed last, i.e. after the
227 // singleton CLScheduler is destroyed.
228 //
229 // When OpenCL is not available, this call results in CL_OUT_OF_RESOURCES,
230 // which is equally harmless.
231 (void)clGetPlatformIDs(0, nullptr, nullptr);
232
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000233 return CLSymbols::get().clBuildProgram_ptr != nullptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100234}
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100235} // namespace arm_compute
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100236
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100237cl_int clEnqueueMarker(cl_command_queue command_queue,
238 cl_event *event)
239{
240 arm_compute::CLSymbols::get().load_default();
241 auto func = arm_compute::CLSymbols::get().clEnqueueMarker_ptr;
242 if(func != nullptr)
243 {
244 return func(command_queue, event);
245 }
246 else
247 {
248 return CL_OUT_OF_RESOURCES;
249 }
250}
251
252cl_int clWaitForEvents(cl_uint num_events,
253 const cl_event *event_list)
254{
255 arm_compute::CLSymbols::get().load_default();
256 auto func = arm_compute::CLSymbols::get().clWaitForEvents_ptr;
257 if(func != nullptr)
258 {
259 return func(num_events, event_list);
260 }
261 else
262 {
263 return CL_OUT_OF_RESOURCES;
264 }
265}
266
Pablo Telloe86a09f2018-01-11 15:44:48 +0000267cl_int clEnqueueSVMMap(cl_command_queue command_queue, cl_bool blocking_map, cl_map_flags flags, void *svm_ptr,
268 size_t size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
269{
270 arm_compute::CLSymbols::get().load_default();
271 auto func = arm_compute::CLSymbols::get().clEnqueueSVMMap_ptr;
272 if(func != nullptr)
273 {
274 return func(command_queue, blocking_map, flags, svm_ptr, size, num_events_in_wait_list, event_wait_list, event);
275 }
276 else
277 {
278 return CL_OUT_OF_RESOURCES;
279 }
280}
281
282cl_int clEnqueueSVMUnmap(cl_command_queue command_queue, void *svm_ptr, cl_uint num_events_in_wait_list,
283 const cl_event *event_wait_list, cl_event *event)
284{
285 arm_compute::CLSymbols::get().load_default();
286 auto func = arm_compute::CLSymbols::get().clEnqueueSVMUnmap_ptr;
287 if(func != nullptr)
288 {
289 return func(command_queue, svm_ptr, num_events_in_wait_list, event_wait_list, event);
290 }
291 else
292 {
293 return CL_OUT_OF_RESOURCES;
294 }
295}
296
297void *clSVMAlloc(cl_context context, cl_svm_mem_flags_arm flags, size_t size, cl_uint alignment)
298{
299 arm_compute::CLSymbols::get().load_default();
300 auto func = arm_compute::CLSymbols::get().clSVMAlloc_ptr;
301 if(func != nullptr)
302 {
303 return func(context, flags, size, alignment);
304 }
305 else
306 {
307 return nullptr;
308 }
309}
310
311void clSVMFree(cl_context context, void *svm_pointer)
312{
313 arm_compute::CLSymbols::get().load_default();
314 auto func = arm_compute::CLSymbols::get().clSVMFree_ptr;
315 if(func != nullptr)
316 {
317 func(context, svm_pointer);
318 }
319}
320
Anthony Barbiera9e15332017-12-22 16:37:30 +0000321cl_int clGetContextInfo(cl_context context,
322 cl_context_info param_name,
323 size_t param_value_size,
324 void *param_value,
325 size_t *param_value_size_ret)
326{
327 arm_compute::CLSymbols::get().load_default();
328 auto func = arm_compute::CLSymbols::get().clGetContextInfo_ptr;
329 if(func != nullptr)
330 {
331 return func(context, param_name, param_value_size, param_value, param_value_size_ret);
332 }
333 else
334 {
335 return CL_OUT_OF_RESOURCES;
336 }
337}
338
339cl_command_queue clCreateCommandQueue(cl_context context,
340 cl_device_id device,
341 cl_command_queue_properties properties,
342 cl_int *errcode_ret)
343{
344 arm_compute::CLSymbols::get().load_default();
345 auto func = arm_compute::CLSymbols::get().clCreateCommandQueue_ptr;
346 if(func != nullptr)
347 {
348 return func(context, device, properties, errcode_ret);
349 }
350 else
351 {
352 return nullptr;
353 }
354}
355
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000356cl_command_queue clCreateCommandQueueWithProperties(cl_context context,
357 cl_device_id device,
358 const cl_queue_properties *properties,
359 cl_int *errcode_ret)
360{
361 arm_compute::CLSymbols::get().load_default();
362 auto func = arm_compute::CLSymbols::get().clCreateCommandQueueWithProperties_ptr;
363 if(func != nullptr)
364 {
365 return func(context, device, properties, errcode_ret);
366 }
367 else
368 {
369 return nullptr;
370 }
371}
372
Anthony Barbierb6eb3532018-08-08 13:20:04 +0100373cl_context clCreateContext(
374 const cl_context_properties *properties,
375 cl_uint num_devices,
376 const cl_device_id *devices,
377 void (*pfn_notify)(const char *, const void *, size_t, void *),
378 void *user_data,
379 cl_int *errcode_ret)
380{
381 arm_compute::CLSymbols::get().load_default();
382 auto func = arm_compute::CLSymbols::get().clCreateContext_ptr;
383 if(func != nullptr)
384 {
385 return func(properties, num_devices, devices, pfn_notify, user_data, errcode_ret);
386 }
387 else
388 {
389 return nullptr;
390 }
391}
392
Anthony Barbiera9e15332017-12-22 16:37:30 +0000393cl_context clCreateContextFromType(const cl_context_properties *properties,
394 cl_device_type device_type,
395 void (*pfn_notify)(const char *, const void *, size_t, void *),
396 void *user_data,
397 cl_int *errcode_ret)
398{
399 arm_compute::CLSymbols::get().load_default();
400 auto func = arm_compute::CLSymbols::get().clCreateContextFromType_ptr;
401 if(func != nullptr)
402 {
403 return func(properties, device_type, pfn_notify, user_data, errcode_ret);
404 }
405 else
406 {
407 return nullptr;
408 }
409}
410
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100411cl_int clBuildProgram(
412 cl_program program,
413 cl_uint num_devices,
414 const cl_device_id *device_list,
415 const char *options,
416 void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data),
417 void *user_data)
418{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100419 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000420 auto func = arm_compute::CLSymbols::get().clBuildProgram_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100421 if(func != nullptr)
422 {
423 return func(program, num_devices, device_list, options, pfn_notify, user_data);
424 }
425 else
426 {
427 return CL_OUT_OF_RESOURCES;
428 }
429}
430
431cl_int clEnqueueNDRangeKernel(
432 cl_command_queue command_queue,
433 cl_kernel kernel,
434 cl_uint work_dim,
435 const size_t *global_work_offset,
436 const size_t *global_work_size,
437 const size_t *local_work_size,
438 cl_uint num_events_in_wait_list,
439 const cl_event *event_wait_list,
440 cl_event *event)
441{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100442 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000443 auto func = arm_compute::CLSymbols::get().clEnqueueNDRangeKernel_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100444 if(func != nullptr)
445 {
446 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);
447 }
448 else
449 {
450 return CL_OUT_OF_RESOURCES;
451 }
452}
453
454cl_int clSetKernelArg(
455 cl_kernel kernel,
456 cl_uint arg_index,
457 size_t arg_size,
458 const void *arg_value)
459{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100460 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000461 auto func = arm_compute::CLSymbols::get().clSetKernelArg_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100462 if(func != nullptr)
463 {
464 return func(kernel, arg_index, arg_size, arg_value);
465 }
466 else
467 {
468 return CL_OUT_OF_RESOURCES;
469 }
470}
471
Georgios Pinitasbaf174e2017-09-08 19:47:30 +0100472cl_int clRetainMemObject(cl_mem memobj)
473{
474 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000475 auto func = arm_compute::CLSymbols::get().clRetainMemObject_ptr;
Georgios Pinitasbaf174e2017-09-08 19:47:30 +0100476 if(func != nullptr)
477 {
478 return func(memobj);
479 }
480 else
481 {
482 return CL_OUT_OF_RESOURCES;
483 }
484}
485
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100486cl_int clReleaseMemObject(cl_mem memobj)
487{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100488 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000489 auto func = arm_compute::CLSymbols::get().clReleaseMemObject_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100490 if(func != nullptr)
491 {
492 return func(memobj);
493 }
494 else
495 {
496 return CL_OUT_OF_RESOURCES;
497 }
498}
499
500cl_int clEnqueueUnmapMemObject(
501 cl_command_queue command_queue,
502 cl_mem memobj,
503 void *mapped_ptr,
504 cl_uint num_events_in_wait_list,
505 const cl_event *event_wait_list,
506 cl_event *event)
507{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100508 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000509 auto func = arm_compute::CLSymbols::get().clEnqueueUnmapMemObject_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100510 if(func != nullptr)
511 {
512 return func(command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
513 }
514 else
515 {
516 return CL_OUT_OF_RESOURCES;
517 }
518}
519
520cl_int clRetainCommandQueue(cl_command_queue command_queue)
521{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100522 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000523 auto func = arm_compute::CLSymbols::get().clRetainCommandQueue_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100524 if(func != nullptr)
525 {
526 return func(command_queue);
527 }
528 else
529 {
530 return CL_OUT_OF_RESOURCES;
531 }
532}
533
534cl_int clReleaseContext(cl_context context)
535{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100536 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000537 auto func = arm_compute::CLSymbols::get().clReleaseContext_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100538 if(func != nullptr)
539 {
540 return func(context);
541 }
542 else
543 {
544 return CL_OUT_OF_RESOURCES;
545 }
546}
547cl_int clReleaseEvent(cl_event event)
548{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100549 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000550 auto func = arm_compute::CLSymbols::get().clReleaseEvent_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100551 if(func != nullptr)
552 {
553 return func(event);
554 }
555 else
556 {
557 return CL_OUT_OF_RESOURCES;
558 }
559}
560
561cl_int clEnqueueWriteBuffer(
562 cl_command_queue command_queue,
563 cl_mem buffer,
564 cl_bool blocking_write,
565 size_t offset,
566 size_t size,
567 const void *ptr,
568 cl_uint num_events_in_wait_list,
569 const cl_event *event_wait_list,
570 cl_event *event)
571{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100572 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000573 auto func = arm_compute::CLSymbols::get().clEnqueueWriteBuffer_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100574 if(func != nullptr)
575 {
576 return func(command_queue, buffer, blocking_write, offset, size, ptr, num_events_in_wait_list, event_wait_list, event);
577 }
578 else
579 {
580 return CL_OUT_OF_RESOURCES;
581 }
582}
583
584cl_int clEnqueueReadBuffer(
585 cl_command_queue command_queue,
586 cl_mem buffer,
587 cl_bool blocking_read,
588 size_t offset,
589 size_t size,
590 void *ptr,
591 cl_uint num_events_in_wait_list,
592 const cl_event *event_wait_list,
593 cl_event *event)
594{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100595 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000596 auto func = arm_compute::CLSymbols::get().clEnqueueReadBuffer_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100597 if(func != nullptr)
598 {
599 return func(command_queue, buffer, blocking_read, offset, size, ptr, num_events_in_wait_list, event_wait_list, event);
600 }
601 else
602 {
603 return CL_OUT_OF_RESOURCES;
604 }
605}
606
607cl_int clGetProgramBuildInfo(
608 cl_program program,
609 cl_device_id device,
610 cl_program_build_info param_name,
611 size_t param_value_size,
612 void *param_value,
613 size_t *param_value_size_ret)
614{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100615 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000616 auto func = arm_compute::CLSymbols::get().clGetProgramBuildInfo_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100617 if(func != nullptr)
618 {
619 return func(program, device, param_name, param_value_size, param_value, param_value_size_ret);
620 }
621 else
622 {
623 return CL_OUT_OF_RESOURCES;
624 }
625}
626
627cl_int clRetainProgram(cl_program program)
628{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100629 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000630 auto func = arm_compute::CLSymbols::get().clRetainProgram_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100631 if(func != nullptr)
632 {
633 return func(program);
634 }
635 else
636 {
637 return CL_OUT_OF_RESOURCES;
638 }
639}
640
641void *clEnqueueMapBuffer(
642 cl_command_queue command_queue,
643 cl_mem buffer,
644 cl_bool blocking_map,
645 cl_map_flags map_flags,
646 size_t offset,
647 size_t size,
648 cl_uint num_events_in_wait_list,
649 const cl_event *event_wait_list,
650 cl_event *event,
651 cl_int *errcode_ret)
652{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100653 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000654 auto func = arm_compute::CLSymbols::get().clEnqueueMapBuffer_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100655 if(func != nullptr)
656 {
657 return func(command_queue, buffer, blocking_map, map_flags, offset, size, num_events_in_wait_list, event_wait_list, event, errcode_ret);
658 }
659 else
660 {
661 if(errcode_ret != nullptr)
662 {
663 *errcode_ret = CL_OUT_OF_RESOURCES;
664 }
665 return nullptr;
666 }
667}
668
669cl_int clReleaseCommandQueue(cl_command_queue command_queue)
670{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100671 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000672 auto func = arm_compute::CLSymbols::get().clReleaseCommandQueue_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100673 if(func != nullptr)
674 {
675 return func(command_queue);
676 }
677 else
678 {
679 return CL_OUT_OF_RESOURCES;
680 }
681}
682
683cl_program clCreateProgramWithBinary(
684 cl_context context,
685 cl_uint num_devices,
686 const cl_device_id *device_list,
687 const size_t *lengths,
688 const unsigned char **binaries,
689 cl_int *binary_status,
690 cl_int *errcode_ret)
691{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100692 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000693 auto func = arm_compute::CLSymbols::get().clCreateProgramWithBinary_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100694 if(func != nullptr)
695 {
696 return func(context, num_devices, device_list, lengths, binaries, binary_status, errcode_ret);
697 }
698 else
699 {
700 if(errcode_ret != nullptr)
701 {
702 *errcode_ret = CL_OUT_OF_RESOURCES;
703 }
704 return nullptr;
705 }
706}
707
708cl_int clRetainContext(cl_context context)
709{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100710 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000711 auto func = arm_compute::CLSymbols::get().clRetainContext_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100712 if(func != nullptr)
713 {
714 return func(context);
715 }
716 else
717 {
718 return CL_OUT_OF_RESOURCES;
719 }
720}
721
722cl_int clReleaseProgram(cl_program program)
723{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100724 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000725 auto func = arm_compute::CLSymbols::get().clReleaseProgram_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100726 if(func != nullptr)
727 {
728 return func(program);
729 }
730 else
731 {
732 return CL_OUT_OF_RESOURCES;
733 }
734}
735
736cl_int clFlush(cl_command_queue command_queue)
737{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100738 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000739 auto func = arm_compute::CLSymbols::get().clFlush_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100740 if(func != nullptr)
741 {
742 return func(command_queue);
743 }
744 else
745 {
746 return CL_OUT_OF_RESOURCES;
747 }
748}
749
Gian Marco Iodice63d76a72017-08-11 11:56:52 +0100750cl_int clFinish(cl_command_queue command_queue)
751{
752 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000753 auto func = arm_compute::CLSymbols::get().clFinish_ptr;
Gian Marco Iodice63d76a72017-08-11 11:56:52 +0100754 if(func != nullptr)
755 {
756 return func(command_queue);
757 }
758 else
759 {
760 return CL_OUT_OF_RESOURCES;
761 }
762}
763
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100764cl_int clGetProgramInfo(
765 cl_program program,
766 cl_program_info param_name,
767 size_t param_value_size,
768 void *param_value,
769 size_t *param_value_size_ret)
770{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100771 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000772 auto func = arm_compute::CLSymbols::get().clGetProgramInfo_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100773 if(func != nullptr)
774 {
775 return func(program, param_name, param_value_size, param_value, param_value_size_ret);
776 }
777 else
778 {
779 return CL_OUT_OF_RESOURCES;
780 }
781}
782
783cl_kernel clCreateKernel(
784 cl_program program,
785 const char *kernel_name,
786 cl_int *errcode_ret)
787{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100788 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000789 auto func = arm_compute::CLSymbols::get().clCreateKernel_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100790 if(func != nullptr)
791 {
792 return func(program, kernel_name, errcode_ret);
793 }
794 else
795 {
796 if(errcode_ret != nullptr)
797 {
798 *errcode_ret = CL_OUT_OF_RESOURCES;
799 }
800 return nullptr;
801 }
802}
803
804cl_int clRetainKernel(cl_kernel kernel)
805{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100806 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000807 auto func = arm_compute::CLSymbols::get().clRetainKernel_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100808 if(func != nullptr)
809 {
810 return func(kernel);
811 }
812 else
813 {
814 return CL_OUT_OF_RESOURCES;
815 }
816}
817
818cl_mem clCreateBuffer(
819 cl_context context,
820 cl_mem_flags flags,
821 size_t size,
822 void *host_ptr,
823 cl_int *errcode_ret)
824{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100825 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000826 auto func = arm_compute::CLSymbols::get().clCreateBuffer_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100827 if(func != nullptr)
828 {
829 return func(context, flags, size, host_ptr, errcode_ret);
830 }
831 else
832 {
833 if(errcode_ret != nullptr)
834 {
835 *errcode_ret = CL_OUT_OF_RESOURCES;
836 }
837 return nullptr;
838 }
839}
840
841cl_program clCreateProgramWithSource(
842 cl_context context,
843 cl_uint count,
844 const char **strings,
845 const size_t *lengths,
846 cl_int *errcode_ret)
847{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100848 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000849 auto func = arm_compute::CLSymbols::get().clCreateProgramWithSource_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100850 if(func != nullptr)
851 {
852 return func(context, count, strings, lengths, errcode_ret);
853 }
854 else
855 {
856 if(errcode_ret != nullptr)
857 {
858 *errcode_ret = CL_OUT_OF_RESOURCES;
859 }
860 return nullptr;
861 }
862}
863
864cl_int clReleaseKernel(cl_kernel kernel)
865{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100866 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000867 auto func = arm_compute::CLSymbols::get().clReleaseKernel_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100868 if(func != nullptr)
869 {
870 return func(kernel);
871 }
872 else
873 {
874 return CL_OUT_OF_RESOURCES;
875 }
876}
877
878cl_int clGetDeviceIDs(cl_platform_id platform,
879 cl_device_type device_type,
880 cl_uint num_entries,
881 cl_device_id *devices,
882 cl_uint *num_devices)
883{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100884 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000885 auto func = arm_compute::CLSymbols::get().clGetDeviceIDs_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100886 if(func != nullptr)
887 {
888 return func(platform, device_type, num_entries, devices, num_devices);
889 }
890 else
891 {
892 return CL_OUT_OF_RESOURCES;
893 }
894}
895
896cl_int clGetDeviceInfo(cl_device_id device,
897 cl_device_info param_name,
898 size_t param_value_size,
899 void *param_value,
900 size_t *param_value_size_ret)
901{
Moritz Pflanzer725788e2017-07-07 15:35:56 +0100902 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000903 auto func = arm_compute::CLSymbols::get().clGetDeviceInfo_ptr;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100904 if(func != nullptr)
905 {
906 return func(device, param_name, param_value_size, param_value, param_value_size_ret);
907 }
908 else
909 {
910 return CL_OUT_OF_RESOURCES;
911 }
912}
Giorgio Arena9fe41442017-08-23 16:36:24 +0100913
Georgios Pinitasdf310362018-11-14 13:16:56 +0000914cl_int clGetMemObjectInfo(cl_mem memobj,
915 cl_mem_info param_name,
916 size_t param_value_size,
917 void *param_value,
918 size_t *param_value_size_ret)
919{
920 arm_compute::CLSymbols::get().load_default();
921 auto func = arm_compute::CLSymbols::get().clGetMemObjectInfo_ptr;
922 if(func != nullptr)
923 {
924 return func(memobj, param_name, param_value_size, param_value, param_value_size_ret);
925 }
926 else
927 {
928 return CL_OUT_OF_RESOURCES;
929 }
930}
931
Giorgio Arena9fe41442017-08-23 16:36:24 +0100932cl_int clRetainEvent(cl_event event)
933{
Moritz Pflanzer159b6da2017-09-20 16:03:35 +0100934 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000935 auto func = arm_compute::CLSymbols::get().clRetainEvent_ptr;
Giorgio Arena9fe41442017-08-23 16:36:24 +0100936 if(func != nullptr)
937 {
938 return func(event);
939 }
940 else
941 {
942 return CL_OUT_OF_RESOURCES;
943 }
944}
steniu01f01f9de2017-09-27 17:00:11 +0100945
Michalis Spyrou402740d2021-04-20 11:26:21 +0100946cl_int clGetPlatformInfo(cl_platform_id platform,
947 cl_platform_info param_name,
948 size_t param_value_size,
949 void *param_value,
950 size_t *param_value_size_ret)
951{
952 arm_compute::CLSymbols::get().load_default();
953 auto func = arm_compute::CLSymbols::get().clGetPlatformInfo_ptr;
954 if(func != nullptr)
955 {
956 return func(platform, param_name, param_value_size, param_value, param_value_size_ret);
957 }
958 else
959 {
960 return CL_OUT_OF_RESOURCES;
961 }
962}
963
steniu01f01f9de2017-09-27 17:00:11 +0100964cl_int clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
965{
966 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000967 auto func = arm_compute::CLSymbols::get().clGetPlatformIDs_ptr;
steniu01f01f9de2017-09-27 17:00:11 +0100968 if(func != nullptr)
969 {
970 return func(num_entries, platforms, num_platforms);
971 }
972 else
973 {
974 return CL_OUT_OF_RESOURCES;
975 }
976}
Abel Bernabeu5a6e0532017-09-28 09:53:45 +0100977
978cl_int
979clGetKernelWorkGroupInfo(cl_kernel kernel,
980 cl_device_id device,
981 cl_kernel_work_group_info param_name,
982 size_t param_value_size,
983 void *param_value,
984 size_t *param_value_size_ret)
985{
986 arm_compute::CLSymbols::get().load_default();
Anthony Barbier58c4ff12017-11-09 09:15:32 +0000987 auto func = arm_compute::CLSymbols::get().clGetKernelWorkGroupInfo_ptr;
Abel Bernabeu5a6e0532017-09-28 09:53:45 +0100988 if(func != nullptr)
989 {
990 return func(kernel, device, param_name, param_value_size, param_value, param_value_size_ret);
991 }
992 else
993 {
994 return CL_OUT_OF_RESOURCES;
995 }
996}
Gian Marco85e6f512018-02-01 16:57:48 +0000997
998cl_int
999clGetCommandQueueInfo(cl_command_queue command_queue,
1000 cl_command_queue_info param_name,
1001 size_t param_value_size,
1002 void *param_value,
1003 size_t *param_value_size_ret)
1004{
1005 arm_compute::CLSymbols::get().load_default();
1006 auto func = arm_compute::CLSymbols::get().clGetCommandQueueInfo_ptr;
1007 if(func != nullptr)
1008 {
1009 return func(command_queue, param_name, param_value_size, param_value, param_value_size_ret);
1010 }
1011 else
1012 {
1013 return CL_OUT_OF_RESOURCES;
1014 }
1015}
1016
1017cl_int
1018clGetKernelInfo(cl_kernel kernel,
1019 cl_kernel_info param_name,
1020 size_t param_value_size,
1021 void *param_value,
1022 size_t *param_value_size_ret)
1023{
1024 arm_compute::CLSymbols::get().load_default();
1025 auto func = arm_compute::CLSymbols::get().clGetKernelInfo_ptr;
1026 if(func != nullptr)
1027 {
1028 return func(kernel, param_name, param_value_size, param_value, param_value_size_ret);
1029 }
1030 else
1031 {
1032 return CL_OUT_OF_RESOURCES;
1033 }
1034}
1035
1036cl_int
1037clGetEventProfilingInfo(cl_event event,
1038 cl_profiling_info param_name,
1039 size_t param_value_size,
1040 void *param_value,
1041 size_t *param_value_size_ret)
1042{
1043 arm_compute::CLSymbols::get().load_default();
1044 auto func = arm_compute::CLSymbols::get().clGetEventProfilingInfo_ptr;
1045 if(func != nullptr)
1046 {
1047 return func(event, param_name, param_value_size, param_value, param_value_size_ret);
1048 }
1049 else
1050 {
1051 return CL_OUT_OF_RESOURCES;
1052 }
Anthony Barbierf5dcf792018-02-28 18:04:45 +00001053}
Georgios Pinitas4d0351c2019-04-03 15:11:16 +01001054
1055cl_mem
Gian Marco Iodicea98dee22020-06-02 12:12:35 +01001056clCreateImage(cl_context context,
1057 cl_mem_flags flags,
1058 const cl_image_format *image_format,
1059 const cl_image_desc *image_desc,
1060 void *host_ptr,
1061 cl_int *errcode_ret)
1062{
1063 arm_compute::CLSymbols::get().load_default();
1064 auto func = arm_compute::CLSymbols::get().clCreateImage_ptr;
1065 if(func != nullptr)
1066 {
1067 return func(context, flags, image_format, image_desc, host_ptr, errcode_ret);
1068 }
1069 else
1070 {
1071 if(errcode_ret != nullptr)
1072 {
1073 *errcode_ret = CL_OUT_OF_RESOURCES;
1074 }
1075 return nullptr;
1076 }
1077}
1078
Manuel Bottinibe9f9f92021-01-25 15:07:17 +00001079cl_int clSetKernelExecInfo(cl_kernel kernel,
1080 cl_kernel_exec_info param_name,
1081 size_t param_value_size,
1082 const void *param_value)
1083{
1084 arm_compute::CLSymbols::get().load_default();
1085 auto func = arm_compute::CLSymbols::get().clSetKernelExecInfo_ptr;
1086 if(func != nullptr)
1087 {
1088 return func(kernel, param_name, param_value_size, param_value);
1089 }
1090 else
1091 {
1092 return CL_OUT_OF_RESOURCES;
1093 }
1094}
1095
Viet-Hoa Do500e10b2023-09-12 17:49:38 +01001096cl_command_buffer_khr clCreateCommandBufferKHR(
1097 cl_uint num_queues,
1098 const cl_command_queue* queues,
1099 const cl_command_buffer_properties_khr* properties,
1100 cl_int* errcode_ret)
1101{
1102 arm_compute::CLSymbols::get().load_default();
1103 const auto func = arm_compute::CLSymbols::get().clCreateCommandBufferKHR_ptr;
1104
1105 if(func != nullptr)
1106 {
1107 return func(num_queues, queues, properties, errcode_ret);
1108 }
1109 else
1110 {
1111 if(errcode_ret != nullptr)
1112 {
1113 *errcode_ret = CL_INVALID_OPERATION;
1114 }
1115
1116 return {};
1117 }
1118}
1119
1120cl_int clFinalizeCommandBufferKHR(cl_command_buffer_khr command_buffer)
1121{
1122 arm_compute::CLSymbols::get().load_default();
1123 const auto func = arm_compute::CLSymbols::get().clFinalizeCommandBufferKHR_ptr;
1124
1125 if(func != nullptr)
1126 {
1127 return func(command_buffer);
1128 }
1129 else
1130 {
1131 return CL_INVALID_OPERATION;
1132 }
1133}
1134
1135cl_int clRetainCommandBufferKHR(cl_command_buffer_khr command_buffer)
1136{
1137 arm_compute::CLSymbols::get().load_default();
1138 const auto func = arm_compute::CLSymbols::get().clRetainCommandBufferKHR_ptr;
1139
1140 if(func != nullptr)
1141 {
1142 return func(command_buffer);
1143 }
1144 else
1145 {
1146 return CL_INVALID_OPERATION;
1147 }
1148}
1149
1150cl_int clReleaseCommandBufferKHR(cl_command_buffer_khr command_buffer)
1151{
1152 arm_compute::CLSymbols::get().load_default();
1153 const auto func = arm_compute::CLSymbols::get().clReleaseCommandBufferKHR_ptr;
1154
1155 if(func != nullptr)
1156 {
1157 return func(command_buffer);
1158 }
1159 else
1160 {
1161 return CL_INVALID_OPERATION;
1162 }
1163}
1164
1165cl_int clEnqueueCommandBufferKHR(
1166 cl_uint num_queues,
1167 cl_command_queue* queues,
1168 cl_command_buffer_khr command_buffer,
1169 cl_uint num_events_in_wait_list,
1170 const cl_event* event_wait_list,
1171 cl_event* event)
1172{
1173 arm_compute::CLSymbols::get().load_default();
1174 const auto func = arm_compute::CLSymbols::get().clEnqueueCommandBufferKHR_ptr;
1175
1176 if(func != nullptr)
1177 {
1178 return func(num_queues, queues, command_buffer, num_events_in_wait_list, event_wait_list, event);
1179 }
1180 else
1181 {
1182 return CL_INVALID_OPERATION;
1183 }
1184}
1185
1186
1187cl_int clCommandNDRangeKernelKHR(
1188 cl_command_buffer_khr command_buffer,
1189 cl_command_queue command_queue,
1190 const cl_ndrange_kernel_command_properties_khr* properties,
1191 cl_kernel kernel,
1192 cl_uint work_dim,
1193 const size_t* global_work_offset,
1194 const size_t* global_work_size,
1195 const size_t* local_work_size,
1196 cl_uint num_sync_points_in_wait_list,
1197 const cl_sync_point_khr* sync_point_wait_list,
1198 cl_sync_point_khr* sync_point,
1199 cl_mutable_command_khr* mutable_handle)
1200{
1201 arm_compute::CLSymbols::get().load_default();
1202 const auto func = arm_compute::CLSymbols::get().clCommandNDRangeKernelKHR_ptr;
1203
1204 if(func != nullptr)
1205 {
1206 return func(command_buffer, command_queue, properties, kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_sync_points_in_wait_list, sync_point_wait_list, sync_point, mutable_handle);
1207 }
1208 else
1209 {
1210 return CL_INVALID_OPERATION;
1211 }
1212}
1213
1214cl_int clUpdateMutableCommandsKHR(
1215 cl_command_buffer_khr command_buffer,
1216 const cl_mutable_base_config_khr* mutable_config)
1217{
1218 arm_compute::CLSymbols::get().load_default();
1219 const auto func = arm_compute::CLSymbols::get().clUpdateMutableCommandsKHR_ptr;
1220
1221 if(func != nullptr)
1222 {
1223 return func(command_buffer, mutable_config);
1224 }
1225 else
1226 {
1227 return CL_INVALID_OPERATION;
1228 }
1229}
1230
Gian Marco Iodicea98dee22020-06-02 12:12:35 +01001231cl_mem
Georgios Pinitas4d0351c2019-04-03 15:11:16 +01001232clImportMemoryARM(cl_context context,
1233 cl_mem_flags flags,
1234 const cl_import_properties_arm *properties,
1235 void *memory,
1236 size_t size,
1237 cl_int *errcode_ret)
1238{
1239 arm_compute::CLSymbols::get().load_default();
1240 auto func = arm_compute::CLSymbols::get().clImportMemoryARM_ptr;
1241 if(func != nullptr)
1242 {
1243 return func(context, flags, properties, memory, size, errcode_ret);
1244 }
1245 else
1246 {
1247 if(errcode_ret != nullptr)
1248 {
1249 *errcode_ret = CL_OUT_OF_RESOURCES;
1250 }
1251 return nullptr;
1252 }
Pablo Tellodb8485a2019-09-24 11:03:47 +01001253}