blob: 8a5abf7bb286185417e8443b046bf6b6024657ee [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
surmeh013537c2c2018-05-18 16:31:43 +01009#include <arm_compute/runtime/CL/CLTuner.h>
surmeh013537c2c2018-05-18 16:31:43 +010010
11namespace armnn
12{
13
telsoa01c577f2c2018-08-31 09:22:23 +010014class IGpuAccTunedParameters;
surmeh013537c2c2018-05-18 16:31:43 +010015class ClTunedParameters;
16
telsoa01c577f2c2018-08-31 09:22:23 +010017// ARM Compute OpenCL context control.
surmeh013537c2c2018-05-18 16:31:43 +010018class ClContextControl
19{
20public:
21
telsoa01c577f2c2018-08-31 09:22:23 +010022 ClContextControl(IGpuAccTunedParameters* clTunedParameters = nullptr,
23 bool profilingEnabled = false);
surmeh013537c2c2018-05-18 16:31:43 +010024
25 virtual ~ClContextControl();
26
27 void LoadOpenClRuntime();
28
29 // Users should call this (after freeing all of the cl::Context objects they use)
30 // to release the cached memory used by the compute library.
31 void UnloadOpenClRuntime();
32
telsoa01c577f2c2018-08-31 09:22:23 +010033 // Clear the CL cache, without losing the tuned parameter settings.
surmeh013537c2c2018-05-18 16:31:43 +010034 void ClearClCache();
35
36private:
37
38 void DoLoadOpenClRuntime(bool useTunedParameters);
39
40 ClTunedParameters* m_clTunedParameters;
41
telsoa01c577f2c2018-08-31 09:22:23 +010042 bool m_ProfilingEnabled;
surmeh013537c2c2018-05-18 16:31:43 +010043};
44
telsoa01c577f2c2018-08-31 09:22:23 +010045class ClTunedParameters : public IGpuAccTunedParameters
surmeh013537c2c2018-05-18 16:31:43 +010046{
47public:
Ruomei Yan49937f32019-04-25 14:24:05 +010048 ClTunedParameters(armnn::IGpuAccTunedParameters::Mode mode, armnn::IGpuAccTunedParameters::TuningLevel tuningLevel);
surmeh013537c2c2018-05-18 16:31:43 +010049
50 virtual void Load(const char* filename);
51 virtual void Save(const char* filename) const;
52
53 Mode m_Mode;
Ruomei Yan49937f32019-04-25 14:24:05 +010054 TuningLevel m_TuningLevel;
surmeh013537c2c2018-05-18 16:31:43 +010055
surmeh013537c2c2018-05-18 16:31:43 +010056 arm_compute::CLTuner m_Tuner;
surmeh013537c2c2018-05-18 16:31:43 +010057};
58
59} // namespace armnn