blob: 5ac56423bd51dfb7e370459f86d911e97f6f05d4 [file] [log] [blame]
surmeh013537c2c2018-05-18 16:31:43 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
surmeh013537c2c2018-05-18 16:31:43 +01004//
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
13namespace armnn
14{
15
telsoa01c577f2c2018-08-31 09:22:23 +010016class IGpuAccTunedParameters;
surmeh013537c2c2018-05-18 16:31:43 +010017class ClTunedParameters;
18
telsoa01c577f2c2018-08-31 09:22:23 +010019// ARM Compute OpenCL context control.
surmeh013537c2c2018-05-18 16:31:43 +010020class ClContextControl
21{
22public:
23
telsoa01c577f2c2018-08-31 09:22:23 +010024 ClContextControl(IGpuAccTunedParameters* clTunedParameters = nullptr,
25 bool profilingEnabled = false);
surmeh013537c2c2018-05-18 16:31:43 +010026
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
telsoa01c577f2c2018-08-31 09:22:23 +010035 // Clear the CL cache, without losing the tuned parameter settings.
surmeh013537c2c2018-05-18 16:31:43 +010036 void ClearClCache();
37
38private:
39
40 void DoLoadOpenClRuntime(bool useTunedParameters);
41
42 ClTunedParameters* m_clTunedParameters;
43
telsoa01c577f2c2018-08-31 09:22:23 +010044 bool m_ProfilingEnabled;
surmeh013537c2c2018-05-18 16:31:43 +010045};
46
telsoa01c577f2c2018-08-31 09:22:23 +010047class ClTunedParameters : public IGpuAccTunedParameters
surmeh013537c2c2018-05-18 16:31:43 +010048{
49public:
telsoa01c577f2c2018-08-31 09:22:23 +010050 ClTunedParameters(armnn::IGpuAccTunedParameters::Mode mode);
surmeh013537c2c2018-05-18 16:31:43 +010051
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