blob: 28e918d371d6f6c50ee2d0993f54bacefc60f065 [file] [log] [blame]
Georgios Pinitas8a5146f2021-01-12 15:51:07 +00001/*
Viet-Hoa Dof8bb0922022-05-30 15:15:15 +01002 * Copyright (c) 2021-2022 Arm Limited.
Georgios Pinitas8a5146f2021-01-12 15:51:07 +00003 *
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 */
Georgios Pinitas06ac6e42021-07-05 08:08:52 +010024#ifndef ARM_COMPUTE_ACL_OPENCL_EXT_H_
25#define ARM_COMPUTE_ACL_OPENCL_EXT_H_
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000026
27#include "arm_compute/AclTypes.h"
28
29#ifndef CL_TARGET_OPENCL_VERSION
Viet-Hoa Dof8bb0922022-05-30 15:15:15 +010030#define CL_TARGET_OPENCL_VERSION 300
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000031#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
32#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
33#endif /* CL_TARGET_OPENCL_VERSION */
34#pragma GCC diagnostic push
35#pragma GCC diagnostic ignored "-Weffc++"
36#include "include/CL/cl.h"
37#pragma GCC diagnostic pop
38
39#ifdef __cplusplus
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010040extern "C"
41{
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000042#endif /* __cplusplus */
43
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010044 /** Extract the underlying OpenCL context used by a given Compute Library context object
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000045 *
46 * @note @ref AclContext should be of an OpenCL backend target
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000047 *
48 * @param[in] ctx A valid non-zero context
49 * @param[out] opencl_context Underlying OpenCL context used
50 *
51 * @return Status code
52 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010053 AclStatus AclGetClContext(AclContext ctx, cl_context *opencl_context);
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000054
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010055 /** Extract the underlying OpenCL device id used by a given Compute Library context object
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000056 *
57 * @note @ref AclContext should be of an OpenCL backend target
58 *
59 * @param[in] ctx A valid non-zero context
60 * @param[out] opencl_device Underlying OpenCL device used
61 *
62 * @return Status code
63 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010064 AclStatus AclGetClDevice(AclContext ctx, cl_device_id *opencl_device);
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000065
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010066 /** Set the underlying OpenCL context to be used by a given Compute Library context object
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000067 *
68 * @note @ref AclContext should be of an OpenCL backend target
69 *
70 * @param[in] ctx A valid non-zero context object
71 * @param[out] opencl_context Underlying OpenCL context to be used
72 *
73 * @return Status code
74 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010075 AclStatus AclSetClContext(AclContext ctx, cl_context opencl_context);
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000076
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010077 /** Extract the underlying OpenCL queue used by a given Compute Library queue object
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000078 *
79 * @note @ref AclQueue should be of an OpenCL backend target
80 * @note @ref AclQueue refcount should be 0, meaning not used by other objects
81 *
82 * @param[in] queue A valid non-zero queue
83 * @param[out] opencl_queue Underlying OpenCL queue used
84 *
85 * @return Status code
86 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010087 AclStatus AclGetClQueue(AclQueue queue, cl_command_queue *opencl_queue);
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000088
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010089 /** Set the underlying OpenCL queue to be used by a given Compute Library queue object
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000090 *
91 * @note @ref AclQueue should be of an OpenCL backend target
92 * @note opecl_queue needs to be created from the same context that the AclContext that the queue will use
93 *
94 * @param[in] queue A valid non-zero queue object
95 * @param[out] opencl_queue Underlying OpenCL queue to be used
96 *
97 * @return Status code
98 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010099 AclStatus AclSetClQueue(AclQueue queue, cl_command_queue opencl_queue);
Georgios Pinitasc3c352e2021-03-18 10:59:40 +0000100
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100101 /** Extract the underlying OpenCL memory object by a given Compute Library tensor object
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000102 *
103 * @param[in] tensor A valid non-zero tensor
104 * @param[out] opencl_mem Underlyig OpenCL memory object
105 *
106 * @return Status code
107 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100108 AclStatus AclGetClMem(AclTensor tensor, cl_mem *opencl_mem);
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000109
Georgios Pinitas8a5146f2021-01-12 15:51:07 +0000110#ifdef __cplusplus
111}
112#endif /* __cplusplus */
Georgios Pinitas06ac6e42021-07-05 08:08:52 +0100113#endif /* ARM_COMPUTE_ACL_OPENCL_EXT_H_ */