surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #include "armnn/IRuntime.hpp" |
| 8 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 9 | #include <arm_compute/runtime/CL/CLTuner.h> |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 10 | |
| 11 | namespace armnn |
| 12 | { |
| 13 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 14 | class IGpuAccTunedParameters; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 15 | class ClTunedParameters; |
| 16 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 17 | // ARM Compute OpenCL context control. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 18 | class ClContextControl |
| 19 | { |
| 20 | public: |
| 21 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 22 | ClContextControl(IGpuAccTunedParameters* clTunedParameters = nullptr, |
| 23 | bool profilingEnabled = false); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 24 | |
| 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 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 33 | // Clear the CL cache, without losing the tuned parameter settings. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 34 | void ClearClCache(); |
| 35 | |
| 36 | private: |
| 37 | |
| 38 | void DoLoadOpenClRuntime(bool useTunedParameters); |
| 39 | |
| 40 | ClTunedParameters* m_clTunedParameters; |
| 41 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 42 | bool m_ProfilingEnabled; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 43 | }; |
| 44 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 45 | class ClTunedParameters : public IGpuAccTunedParameters |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 46 | { |
| 47 | public: |
Ruomei Yan | 49937f3 | 2019-04-25 14:24:05 +0100 | [diff] [blame] | 48 | ClTunedParameters(armnn::IGpuAccTunedParameters::Mode mode, armnn::IGpuAccTunedParameters::TuningLevel tuningLevel); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 49 | |
| 50 | virtual void Load(const char* filename); |
| 51 | virtual void Save(const char* filename) const; |
| 52 | |
| 53 | Mode m_Mode; |
Ruomei Yan | 49937f3 | 2019-04-25 14:24:05 +0100 | [diff] [blame] | 54 | TuningLevel m_TuningLevel; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 55 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 56 | arm_compute::CLTuner m_Tuner; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | } // namespace armnn |