Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Cathal Corbett | d9e55f0 | 2023-01-11 13:03:21 +0000 | [diff] [blame] | 2 | // Copyright © 2017, 2023 Arm Ltd and Contributors. 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 | |
Cathal Corbett | d9e55f0 | 2023-01-11 13:03:21 +0000 | [diff] [blame] | 7 | #include <aclCommon/ArmComputeTuningUtils.hpp> |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 8 | |
| 9 | namespace armnn |
| 10 | { |
| 11 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 12 | // ARM Compute OpenCL context control. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 13 | class ClContextControl |
| 14 | { |
| 15 | public: |
| 16 | |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 17 | ClContextControl(arm_compute::CLTuner* = nullptr, |
Finn Williams | 4064632 | 2021-02-11 16:16:42 +0000 | [diff] [blame] | 18 | arm_compute::CLGEMMHeuristicsHandle* = nullptr, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 19 | bool profilingEnabled = false); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 20 | |
| 21 | virtual ~ClContextControl(); |
| 22 | |
| 23 | void LoadOpenClRuntime(); |
| 24 | |
| 25 | // Users should call this (after freeing all of the cl::Context objects they use) |
| 26 | // to release the cached memory used by the compute library. |
| 27 | void UnloadOpenClRuntime(); |
| 28 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 29 | // Clear the CL cache, without losing the tuned parameter settings. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 30 | void ClearClCache(); |
| 31 | |
| 32 | private: |
| 33 | |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 34 | void DoLoadOpenClRuntime(bool updateTunedParameters); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 35 | |
Derek Lamberti | 836b27b | 2019-11-20 10:51:57 +0000 | [diff] [blame] | 36 | arm_compute::CLTuner* m_Tuner; |
Finn Williams | 4064632 | 2021-02-11 16:16:42 +0000 | [diff] [blame] | 37 | arm_compute::CLGEMMHeuristicsHandle* m_HeuristicsHandle; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 38 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 39 | bool m_ProfilingEnabled; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 40 | }; |
| 41 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 42 | } // namespace armnn |