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