blob: fd27ced1f9566f9ac3d6e1182b188327e74c665c [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 +010014// ARM Compute OpenCL context control.
surmeh013537c2c2018-05-18 16:31:43 +010015class ClContextControl
16{
17public:
18
Derek Lamberti836b27b2019-11-20 10:51:57 +000019 ClContextControl(arm_compute::CLTuner* = nullptr,
telsoa01c577f2c2018-08-31 09:22:23 +010020 bool profilingEnabled = false);
surmeh013537c2c2018-05-18 16:31:43 +010021
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
telsoa01c577f2c2018-08-31 09:22:23 +010030 // Clear the CL cache, without losing the tuned parameter settings.
surmeh013537c2c2018-05-18 16:31:43 +010031 void ClearClCache();
32
33private:
34
Derek Lamberti836b27b2019-11-20 10:51:57 +000035 void DoLoadOpenClRuntime(bool updateTunedParameters);
surmeh013537c2c2018-05-18 16:31:43 +010036
Derek Lamberti836b27b2019-11-20 10:51:57 +000037 arm_compute::CLTuner* m_Tuner;
surmeh013537c2c2018-05-18 16:31:43 +010038
telsoa01c577f2c2018-08-31 09:22:23 +010039 bool m_ProfilingEnabled;
surmeh013537c2c2018-05-18 16:31:43 +010040};
41
telsoa01c577f2c2018-08-31 09:22:23 +010042class ClTunedParameters : public IGpuAccTunedParameters
surmeh013537c2c2018-05-18 16:31:43 +010043{
44public:
Ruomei Yan49937f32019-04-25 14:24:05 +010045 ClTunedParameters(armnn::IGpuAccTunedParameters::Mode mode, armnn::IGpuAccTunedParameters::TuningLevel tuningLevel);
surmeh013537c2c2018-05-18 16:31:43 +010046
47 virtual void Load(const char* filename);
48 virtual void Save(const char* filename) const;
49
50 Mode m_Mode;
Ruomei Yan49937f32019-04-25 14:24:05 +010051 TuningLevel m_TuningLevel;
surmeh013537c2c2018-05-18 16:31:43 +010052
surmeh013537c2c2018-05-18 16:31:43 +010053 arm_compute::CLTuner m_Tuner;
surmeh013537c2c2018-05-18 16:31:43 +010054};
55
56} // namespace armnn