blob: 8997d7d1fd568b6c749f2974f24a6f0e33b43ec6 [file] [log] [blame]
Viet-Hoa Do500e10b2023-09-12 17:49:38 +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
25#ifndef ACL_SRC_CORE_CL_CLMUTABLECOMMANDBUFFER_H
26#define ACL_SRC_CORE_CL_CLMUTABLECOMMANDBUFFER_H
27
28#include "src/core/CL/CLCommandBuffer.h"
29
30#include <vector>
31
32namespace arm_compute
33{
34
35/** Command buffer implementaton based on CL mutable dispatch command buffer extension. */
36class CLMutableCommandBuffer : public CLCommandBuffer
37{
38public:
39 /** Create a new mutable dispatch command buffer targeting the specified command queue.
40 *
41 * @param[in] queue The command queue to execute the command buffer.
42 */
43 CLMutableCommandBuffer(cl_command_queue queue);
44
45 /** Destructor. */
46 virtual ~CLMutableCommandBuffer();
47
48 /** Disallow copy constructor. */
49 CLMutableCommandBuffer(const CLMutableCommandBuffer &) = delete;
50
51 /** Disallow copy assignment. */
52 CLMutableCommandBuffer &operator=(const CLMutableCommandBuffer &) = delete;
53
54 /** Disallow move constructor. */
55 CLMutableCommandBuffer(CLMutableCommandBuffer &&) = delete;
56
57 /** Disallow move assignment. */
58 CLMutableCommandBuffer &operator=(CLMutableCommandBuffer &&) = delete;
59
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010060 void add_kernel(cl_kernel kernel,
61 const cl::NDRange &offset,
62 const cl::NDRange &global,
63 const cl::NDRange &local) override;
Viet-Hoa Do500e10b2023-09-12 17:49:38 +010064
65 void finalize() override;
66
67 void update() override;
68
69 void enqueue() override;
70
71 bool is_finalized() const override;
72
73protected:
74 void add_mutable_argument_generic(cl_uint arg_idx, const void *value, size_t size) override;
75
76private:
77 cl_command_buffer_khr _cb{};
78 cl_mutable_base_config_khr _mut_cfg{};
79 std::vector<cl_mutable_dispatch_config_khr> _mut_dispatch_cfgs{};
80 std::vector<cl_mutable_dispatch_arg_khr> _mut_arg_cfgs{};
81};
82
83} // namespace arm_compute
84
85#endif // ACL_SRC_CORE_CL_CLMUTABLECOMMANDBUFFER_H