blob: 7520d102a5917fb53702aa517193560d71ed4120 [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
Cathal Corbettd9e55f02023-01-11 13:03:21 +00002// Copyright © 2017, 2023 Arm Ltd and Contributors. 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
Cathal Corbettd9e55f02023-01-11 13:03:21 +00007#include <aclCommon/ArmComputeTuningUtils.hpp>
surmeh013537c2c2018-05-18 16:31:43 +01008
9namespace armnn
10{
11
telsoa01c577f2c2018-08-31 09:22:23 +010012// ARM Compute OpenCL context control.
surmeh013537c2c2018-05-18 16:31:43 +010013class ClContextControl
14{
15public:
16
Derek Lamberti836b27b2019-11-20 10:51:57 +000017 ClContextControl(arm_compute::CLTuner* = nullptr,
Finn Williams40646322021-02-11 16:16:42 +000018 arm_compute::CLGEMMHeuristicsHandle* = nullptr,
telsoa01c577f2c2018-08-31 09:22:23 +010019 bool profilingEnabled = false);
surmeh013537c2c2018-05-18 16:31:43 +010020
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
telsoa01c577f2c2018-08-31 09:22:23 +010029 // Clear the CL cache, without losing the tuned parameter settings.
surmeh013537c2c2018-05-18 16:31:43 +010030 void ClearClCache();
31
32private:
33
Derek Lamberti836b27b2019-11-20 10:51:57 +000034 void DoLoadOpenClRuntime(bool updateTunedParameters);
surmeh013537c2c2018-05-18 16:31:43 +010035
Derek Lamberti836b27b2019-11-20 10:51:57 +000036 arm_compute::CLTuner* m_Tuner;
Finn Williams40646322021-02-11 16:16:42 +000037 arm_compute::CLGEMMHeuristicsHandle* m_HeuristicsHandle;
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
surmeh013537c2c2018-05-18 16:31:43 +010042} // namespace armnn