blob: 4d11b5e3e41212a357ce29f6e275c1012be4bd28 [file] [log] [blame]
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +01001/*
2 * Copyright (c) 2023 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
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010025#ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_GPUCKWSCOPEDKERNELWRITER_H
26#define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_GPUCKWSCOPEDKERNELWRITER_H
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010027
28#include <cstdint>
29
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010030namespace arm_compute
31{
32namespace experimental
33{
34namespace dynamic_fusion
35{
36
37class GpuCkwKernelWriter;
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010038
39/** Helper to automatically manage kernel writer ID space. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010040class GpuCkwScopedKernelWriter
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010041{
42public:
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010043 /** Initialize a new instance of @ref GpuCkwScopedKernelWriter class. */
44 explicit GpuCkwScopedKernelWriter(GpuCkwKernelWriter *writer);
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010045
46 /** Create a new scope from the specified scoped kernel writer. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010047 GpuCkwScopedKernelWriter(const GpuCkwScopedKernelWriter &other);
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010048
49 /** Assignment is disallowed. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010050 GpuCkwScopedKernelWriter &operator=(const GpuCkwScopedKernelWriter &) = delete;
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010051
52 /** Access the underlying kernel writer. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010053 GpuCkwKernelWriter *operator->();
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010054
55 /** Access the underlying kernel writer. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010056 const GpuCkwKernelWriter *operator->() const;
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010057
58 /** Get the kernel writer. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010059 GpuCkwKernelWriter *writer();
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010060
61 /** Get the kernel writer. */
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010062 const GpuCkwKernelWriter *writer() const;
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010063
64private:
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010065 GpuCkwKernelWriter *_writer;
Viet-Hoa Dobd4f6b92023-05-30 09:34:32 +010066 int32_t _parent_id_space;
67};
68
Viet-Hoa Doce3c48c2023-07-03 13:44:43 +010069} // namespace dynamic_fusion
70} // namespace experimental
71} // namespace arm_compute
72
73#endif // ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_GPUCKWSCOPEDKERNELWRITER_H