Compute Library
 22.05
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
::cl::CommandQueue cl_queue()
Underlying cl command queue accessor.
Definition: ClQueue.cpp:82
Base class specifying the queue interface.
Definition: IQueue.h:41
No tuning.
Definition: AclTypes.h:148
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
static CLScheduler & get()
Access the scheduler singleton.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
Normal tuning mode, gives a good balance between tuning mode and performance.
Definition: AclTypes.h:150
Searches a subset of LWS configurations while tuning.
AclTuningMode
Definition: AclTypes.h:146
Context interface.
Definition: IContext.h:50
Copyright (c) 2017-2022 Arm Limited.
Searches a minimal subset of LWS configurations while tuning.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
AclTuningMode mode
Tuning mode.
Definition: AclTypes.h:157
StatusCode
Definition: Types.h:32
Fast tuning mode, testing a small portion of the tuning space.
Definition: AclTypes.h:149
cl::CommandQueue & queue()
Accessor for the associated CL command queue.
Definition: CLScheduler.cpp:43
void set_queue(cl::CommandQueue queue)
Accessor to set the CL command queue to be used by the scheduler.
Definition: CLScheduler.cpp:59
StatusCode finish() override
Definition: ClQueue.cpp:94
CLTunerMode
< OpenCL tuner modes
Definition: CLTunerTypes.h:35
Provides global access to a CL context and command queue.
Definition: CLScheduler.h:56
Exhaustive tuning mode, increased tuning time but with best results.
Definition: AclTypes.h:151
Searches all possible LWS configurations while tuning.
arm_compute::CLScheduler & scheduler()
Return legacy scheduler.
Definition: ClQueue.cpp:77