blob: ef80fd24434d9bb97e3a6c86a5cd7bc7b497c464 [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
40extern "C" {
41#endif /* __cplusplus */
42
43/** Extract the underlying OpenCL context used by a given Compute Library context object
44 *
45 * @note @ref AclContext should be of an OpenCL backend target
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000046 *
47 * @param[in] ctx A valid non-zero context
48 * @param[out] opencl_context Underlying OpenCL context used
49 *
50 * @return Status code
51 */
52AclStatus AclGetClContext(AclContext ctx, cl_context *opencl_context);
53
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000054/** Extract the underlying OpenCL device id used by a given Compute Library context object
55 *
56 * @note @ref AclContext should be of an OpenCL backend target
57 *
58 * @param[in] ctx A valid non-zero context
59 * @param[out] opencl_device Underlying OpenCL device used
60 *
61 * @return Status code
62 */
63AclStatus AclGetClDevice(AclContext ctx, cl_device_id *opencl_device);
64
65/** Set the underlying OpenCL context to be used by a given Compute Library context object
Georgios Pinitas8a5146f2021-01-12 15:51:07 +000066 *
67 * @note @ref AclContext should be of an OpenCL backend target
68 *
69 * @param[in] ctx A valid non-zero context object
70 * @param[out] opencl_context Underlying OpenCL context to be used
71 *
72 * @return Status code
73 */
74AclStatus AclSetClContext(AclContext ctx, cl_context opencl_context);
75
Georgios Pinitasc3c352e2021-03-18 10:59:40 +000076/** Extract the underlying OpenCL queue used by a given Compute Library queue object
77 *
78 * @note @ref AclQueue should be of an OpenCL backend target
79 * @note @ref AclQueue refcount should be 0, meaning not used by other objects
80 *
81 * @param[in] queue A valid non-zero queue
82 * @param[out] opencl_queue Underlying OpenCL queue used
83 *
84 * @return Status code
85 */
86AclStatus AclGetClQueue(AclQueue queue, cl_command_queue *opencl_queue);
87
88/** Set the underlying OpenCL queue to be used by a given Compute Library queue object
89 *
90 * @note @ref AclQueue should be of an OpenCL backend target
91 * @note opecl_queue needs to be created from the same context that the AclContext that the queue will use
92 *
93 * @param[in] queue A valid non-zero queue object
94 * @param[out] opencl_queue Underlying OpenCL queue to be used
95 *
96 * @return Status code
97 */
98AclStatus AclSetClQueue(AclQueue queue, cl_command_queue opencl_queue);
99
Georgios Pinitas3f26ef42021-02-23 10:01:33 +0000100/** Extract the underlying OpenCL memory object by a given Compute Library tensor object
101 *
102 * @param[in] tensor A valid non-zero tensor
103 * @param[out] opencl_mem Underlyig OpenCL memory object
104 *
105 * @return Status code
106 */
107AclStatus AclGetClMem(AclTensor tensor, cl_mem *opencl_mem);
108
Georgios Pinitas8a5146f2021-01-12 15:51:07 +0000109#ifdef __cplusplus
110}
111#endif /* __cplusplus */
Georgios Pinitas06ac6e42021-07-05 08:08:52 +0100112#endif /* ARM_COMPUTE_ACL_OPENCL_EXT_H_ */