2ed43bc60bb7ef7f50103c8c1406baab7b780386
[platform/upstream/armnn.git] / src / backends / cl / ClContextControl.hpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6
7 #include "armnn/IRuntime.hpp"
8
9 #include <arm_compute/runtime/CL/CLTuner.h>
10
11 namespace armnn
12 {
13
14 // ARM Compute OpenCL context control.
15 class ClContextControl
16 {
17 public:
18
19     ClContextControl(arm_compute::CLTuner* = nullptr,
20                      bool profilingEnabled = false);
21
22     virtual ~ClContextControl();
23
24     void LoadOpenClRuntime();
25
26     // Users should call this (after freeing all of the cl::Context objects they use)
27     // to release the cached memory used by the compute library.
28     void UnloadOpenClRuntime();
29
30     // Clear the CL cache, without losing the tuned parameter settings.
31     void ClearClCache();
32
33 private:
34
35     void DoLoadOpenClRuntime(bool updateTunedParameters);
36
37     arm_compute::CLTuner* m_Tuner;
38
39     bool m_ProfilingEnabled;
40 };
41
42 class ClTunedParameters : public IGpuAccTunedParameters
43 {
44 public:
45     ClTunedParameters(armnn::IGpuAccTunedParameters::Mode mode, armnn::IGpuAccTunedParameters::TuningLevel tuningLevel);
46
47     virtual void Load(const char* filename);
48     virtual void Save(const char* filename) const;
49
50     Mode m_Mode;
51     TuningLevel m_TuningLevel;
52
53     arm_compute::CLTuner m_Tuner;
54 };
55
56 } // namespace armnn