Compute Library
 23.08
ClQueue.cpp
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 #include "src/gpu/cl/ClQueue.h"
25 
28 
29 namespace arm_compute
30 {
31 namespace gpu
32 {
33 namespace opencl
34 {
35 namespace
36 {
37 CLTunerMode map_tuner_mode(AclTuningMode mode)
38 {
39  switch(mode)
40  {
41  case AclRapid:
42  return CLTunerMode::RAPID;
43  break;
44  case AclNormal:
45  return CLTunerMode::NORMAL;
46  break;
47  case AclExhaustive:
49  break;
50  default:
51  ARM_COMPUTE_ERROR("Invalid tuner mode");
52  break;
53  }
54 }
55 
56 std::unique_ptr<CLTuner> populate_tuner(const AclQueueOptions *options)
57 {
58  if(options == nullptr || options->mode == AclTuningModeNone)
59  {
60  return nullptr;
61  }
62 
63  CLTuningInfo tune_info;
64  tune_info.tuner_mode = map_tuner_mode(options->mode);
65  tune_info.tune_wbsm = false;
66 
67  return std::make_unique<CLTuner>(true /* tune_new_kernels */, tune_info);
68 }
69 } // namespace
70 
72  : IQueue(ctx), _tuner(nullptr)
73 {
74  _tuner = populate_tuner(options);
75 }
76 
78 {
80 }
81 
82 ::cl::CommandQueue ClQueue::cl_queue()
83 {
85 }
86 
87 bool ClQueue::set_cl_queue(::cl::CommandQueue queue)
88 {
89  // TODO: Check queue is from the same context
91  return true;
92 }
93 
95 {
97  return StatusCode::Success;
98 }
99 
100 } // namespace opencl
101 } // namespace gpu
102 } // namespace arm_compute
arm_compute::CLScheduler
Provides global access to a CL context and command queue.
Definition: CLScheduler.h:43
AclExhaustive
@ AclExhaustive
Exhaustive tuning mode, increased tuning time but with best results.
Definition: AclTypes.h:151
arm_compute::gpu::opencl::ClQueue::scheduler
arm_compute::CLScheduler & scheduler()
Return legacy scheduler.
Definition: ClQueue.cpp:77
arm_compute::StatusCode::Success
@ Success
ARM_COMPUTE_ERROR
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:353
AclQueueOptions::mode
AclTuningMode mode
Tuning mode.
Definition: AclTypes.h:157
arm_compute::IQueue
Base class specifying the queue interface.
Definition: IQueue.h:41
arm_compute::gpu::opencl::ClQueue::set_cl_queue
bool set_cl_queue(::cl::CommandQueue queue)
Update/inject an underlying cl command queue object.
Definition: ClQueue.cpp:87
AclTuningMode
AclTuningMode
Definition: AclTypes.h:146
AclRapid
@ AclRapid
Fast tuning mode, testing a small portion of the tuning space.
Definition: AclTypes.h:149
arm_compute::IContext
Context interface.
Definition: IContext.h:51
arm_compute::CLTunerMode::EXHAUSTIVE
@ EXHAUSTIVE
Searches all possible LWS configurations while tuning.
arm_compute::gpu::opencl::ClQueue::cl_queue
::cl::CommandQueue cl_queue()
Underlying cl command queue accessor.
Definition: ClQueue.cpp:82
arm_compute::CLTunerMode::NORMAL
@ NORMAL
Searches a subset of LWS configurations while tuning.
CLTuner.h
arm_compute::StatusCode
StatusCode
Definition: Types.h:32
arm_compute::gpu::opencl::ClQueue::ClQueue
ClQueue(IContext *ctx, const AclQueueOptions *options)
Construct a new CpuQueue object.
Definition: ClQueue.cpp:71
CLScheduler.h
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
arm_compute::CLTunerMode::RAPID
@ RAPID
Searches a minimal subset of LWS configurations while tuning.
arm_compute::gpu::opencl::ClQueue::finish
StatusCode finish() override
Definition: ClQueue.cpp:94
arm_compute::CLScheduler::get
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:103
AclTuningModeNone
@ AclTuningModeNone
No tuning.
Definition: AclTypes.h:148
arm_compute
Copyright (c) 2017-2023 Arm Limited.
Definition: introduction.dox:24
clang_tidy_rules.mode
mode
Definition: clang_tidy_rules.py:196
AclNormal
@ AclNormal
Normal tuning mode, gives a good balance between tuning mode and performance.
Definition: AclTypes.h:150
arm_compute::CLTunerMode
CLTunerMode
< OpenCL tuner modes
Definition: CLTunerTypes.h:35
arm_compute::CLScheduler::queue
cl::CommandQueue & queue()
Accessor for the associated CL command queue.
Definition: CLScheduler.cpp:39
AclQueueOptions
Definition: AclTypes.h:155
arm_compute::CLScheduler::set_queue
void set_queue(cl::CommandQueue queue)
Accessor to set the CL command queue to be used by the scheduler.
Definition: CLScheduler.cpp:55
ClQueue.h