Compute Library
 22.11
ClQueue.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 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 #ifndef SRC_GPU_CLQUEUE_H
25 #define SRC_GPU_CLQUEUE_H
26 
27 #include "src/common/IQueue.h"
28 
30 
31 #include <memory>
32 
33 namespace arm_compute
34 {
35 // Forward declarations
36 class CLTuner;
37 
38 namespace gpu
39 {
40 namespace opencl
41 {
42 /** OpenCL queue implementation class */
43 class ClQueue final : public IQueue
44 {
45 public:
46  /** Construct a new CpuQueue object
47  *
48  * @param[in] ctx Context to be used
49  * @param[in] options Command queue options
50  */
51  ClQueue(IContext *ctx, const AclQueueOptions *options);
52 
53  /** Return legacy scheduler
54  *
55  * @return arm_compute::IScheduler&
56  */
58 
59  /** Underlying cl command queue accessor
60  *
61  * @return the cl command queue used
62  */
63  ::cl::CommandQueue cl_queue();
64 
65  /** Update/inject an underlying cl command queue object
66  *
67  * @warning Command queue needs to come from the same context as the AclQueue
68  *
69  * @param[in] queue Underlying cl command queue to be used
70  *
71  * @return true if the queue was set successfully else falseS
72  */
73  bool set_cl_queue(::cl::CommandQueue queue);
74 
75  // Inherited functions overridden
76  StatusCode finish() override;
77 
78 private:
79  std::unique_ptr<CLTuner> _tuner;
80 };
81 } // namespace opencl
82 } // namespace gpu
83 } // namespace arm_compute
84 #endif /* SRC_GPU_CLQUEUE_H */
::cl::CommandQueue cl_queue()
Underlying cl command queue accessor.
Definition: ClQueue.cpp:82
Base class specifying the queue interface.
Definition: IQueue.h:41
ClQueue(IContext *ctx, const AclQueueOptions *options)
Construct a new CpuQueue object.
Definition: ClQueue.cpp:71
bool set_cl_queue(::cl::CommandQueue queue)
Update/inject an underlying cl command queue object.
Definition: ClQueue.cpp:87
OpenCL queue implementation class.
Definition: ClQueue.h:43
Context interface.
Definition: IContext.h:50
Copyright (c) 2017-2022 Arm Limited.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
StatusCode
Definition: Types.h:32
StatusCode finish() override
Definition: ClQueue.cpp:94
Provides global access to a CL context and command queue.
Definition: CLScheduler.h:56
arm_compute::CLScheduler & scheduler()
Return legacy scheduler.
Definition: ClQueue.cpp:77