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 | |
| 9 | #ifdef ARMCOMPUTECL_ENABLED |
| 10 | #include <arm_compute/runtime/CL/CLTuner.h> |
| 11 | #endif |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 16 | class IGpuAccTunedParameters; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 17 | class ClTunedParameters; |
| 18 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 19 | // ARM Compute OpenCL context control. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 20 | class ClContextControl |
| 21 | { |
| 22 | public: |
| 23 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 24 | ClContextControl(IGpuAccTunedParameters* clTunedParameters = nullptr, |
| 25 | bool profilingEnabled = false); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 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 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 35 | // Clear the CL cache, without losing the tuned parameter settings. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 36 | void ClearClCache(); |
| 37 | |
| 38 | private: |
| 39 | |
| 40 | void DoLoadOpenClRuntime(bool useTunedParameters); |
| 41 | |
| 42 | ClTunedParameters* m_clTunedParameters; |
| 43 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 44 | bool m_ProfilingEnabled; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 45 | }; |
| 46 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 47 | class ClTunedParameters : public IGpuAccTunedParameters |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 48 | { |
| 49 | public: |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 50 | ClTunedParameters(armnn::IGpuAccTunedParameters::Mode mode); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 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 |