Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 1 | /* |
Viet-Hoa Do | f8bb092 | 2022-05-30 15:15:15 +0100 | [diff] [blame] | 2 | * Copyright (c) 2021-2022 Arm Limited. |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 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 | */ |
Georgios Pinitas | 06ac6e4 | 2021-07-05 08:08:52 +0100 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_ACL_OPENCL_EXT_H_ |
| 25 | #define ARM_COMPUTE_ACL_OPENCL_EXT_H_ |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/AclTypes.h" |
| 28 | |
| 29 | #ifndef CL_TARGET_OPENCL_VERSION |
Viet-Hoa Do | f8bb092 | 2022-05-30 15:15:15 +0100 | [diff] [blame] | 30 | #define CL_TARGET_OPENCL_VERSION 300 |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 31 | #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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 40 | extern "C" |
| 41 | { |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 42 | #endif /* __cplusplus */ |
| 43 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 44 | /** Extract the underlying OpenCL context used by a given Compute Library context object |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 45 | * |
| 46 | * @note @ref AclContext should be of an OpenCL backend target |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 47 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 53 | AclStatus AclGetClContext(AclContext ctx, cl_context *opencl_context); |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 54 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 55 | /** Extract the underlying OpenCL device id used by a given Compute Library context object |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 56 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 64 | AclStatus AclGetClDevice(AclContext ctx, cl_device_id *opencl_device); |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 65 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 66 | /** Set the underlying OpenCL context to be used by a given Compute Library context object |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 67 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 75 | AclStatus AclSetClContext(AclContext ctx, cl_context opencl_context); |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 76 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 77 | /** Extract the underlying OpenCL queue used by a given Compute Library queue object |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 78 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 87 | AclStatus AclGetClQueue(AclQueue queue, cl_command_queue *opencl_queue); |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 88 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 89 | /** Set the underlying OpenCL queue to be used by a given Compute Library queue object |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 90 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 99 | AclStatus AclSetClQueue(AclQueue queue, cl_command_queue opencl_queue); |
Georgios Pinitas | c3c352e | 2021-03-18 10:59:40 +0000 | [diff] [blame] | 100 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 101 | /** Extract the underlying OpenCL memory object by a given Compute Library tensor object |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 102 | * |
| 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 Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 108 | AclStatus AclGetClMem(AclTensor tensor, cl_mem *opencl_mem); |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 109 | |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 110 | #ifdef __cplusplus |
| 111 | } |
| 112 | #endif /* __cplusplus */ |
Georgios Pinitas | 06ac6e4 | 2021-07-05 08:08:52 +0100 | [diff] [blame] | 113 | #endif /* ARM_COMPUTE_ACL_OPENCL_EXT_H_ */ |