From 836b27bd73d62795e82d0ce666d728c94c216067 Mon Sep 17 00:00:00 2001 From: Derek Lamberti Date: Wed, 20 Nov 2019 10:51:57 +0000 Subject: IVGCVSW-4157 Pass custom options directly to backends Change-Id: I98cfb913dbd00cb94bdb5dbe82753ca147f7f671 Signed-off-by: Derek Lamberti --- src/backends/cl/ClContextControl.cpp | 43 +++++++----------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) (limited to 'src/backends/cl/ClContextControl.cpp') diff --git a/src/backends/cl/ClContextControl.cpp b/src/backends/cl/ClContextControl.cpp index cf5ae64c78..72c8e9fe45 100644 --- a/src/backends/cl/ClContextControl.cpp +++ b/src/backends/cl/ClContextControl.cpp @@ -27,9 +27,9 @@ class Device; namespace armnn { -ClContextControl::ClContextControl(IGpuAccTunedParameters* clTunedParameters, +ClContextControl::ClContextControl(arm_compute::CLTuner *tuner, bool profilingEnabled) - : m_clTunedParameters(boost::polymorphic_downcast(clTunedParameters)) + : m_Tuner(tuner) , m_ProfilingEnabled(profilingEnabled) { // Ignore m_ProfilingEnabled if unused to avoid compiling problems when ArmCompute is disabled. @@ -97,7 +97,7 @@ void ClContextControl::UnloadOpenClRuntime() DoLoadOpenClRuntime(false); } -void ClContextControl::DoLoadOpenClRuntime(bool useTunedParameters) +void ClContextControl::DoLoadOpenClRuntime(bool updateTunedParameters) { cl::Device device = cl::Device::getDefault(); cl::Context context; @@ -133,8 +133,8 @@ void ClContextControl::DoLoadOpenClRuntime(bool useTunedParameters) // NOTE: In this specific case profiling has to be enabled on the command queue // in order for the CLTuner to work. - bool profilingNeededForClTuner = useTunedParameters && m_clTunedParameters && - m_clTunedParameters->m_Mode == IGpuAccTunedParameters::Mode::UpdateTunedParameters; + bool profilingNeededForClTuner = updateTunedParameters && m_Tuner && + m_Tuner->tune_new_kernels(); if (m_ProfilingEnabled || profilingNeededForClTuner) { @@ -156,34 +156,7 @@ void ClContextControl::DoLoadOpenClRuntime(bool useTunedParameters) // Note the first argument (path to cl source code) will be ignored as they should be embedded in the armcompute. arm_compute::CLKernelLibrary::get().init(".", context, device); - - arm_compute::ICLTuner* tuner = nullptr; - if (useTunedParameters && m_clTunedParameters) - { - tuner = &m_clTunedParameters->m_Tuner; - auto clTuner = boost::polymorphic_downcast(tuner); - - auto ConvertTuningLevel = [](IGpuAccTunedParameters::TuningLevel level) - { - switch(level) - { - case IGpuAccTunedParameters::TuningLevel::Rapid: - return arm_compute::CLTunerMode::RAPID; - case IGpuAccTunedParameters::TuningLevel::Normal: - return arm_compute::CLTunerMode::NORMAL; - case IGpuAccTunedParameters::TuningLevel::Exhaustive: - return arm_compute::CLTunerMode::EXHAUSTIVE; - default: - { - BOOST_ASSERT_MSG(false, "Tuning level not recognised."); - return arm_compute::CLTunerMode::NORMAL; - } - } - }; - - clTuner->set_tuner_mode(ConvertTuningLevel(m_clTunedParameters->m_TuningLevel)); - } - arm_compute::CLScheduler::get().init(context, commandQueue, device, tuner); + arm_compute::CLScheduler::get().init(context, commandQueue, device, m_Tuner); } void ClContextControl::ClearClCache() @@ -225,7 +198,7 @@ void ClTunedParameters::Load(const char* filename) catch (const std::exception& e) { throw armnn::Exception(std::string("Failed to load tuned parameters file '") + filename + "': " + - e.what()); + e.what()); } } @@ -238,7 +211,7 @@ void ClTunedParameters::Save(const char* filename) const catch (const std::exception& e) { throw armnn::Exception(std::string("Failed to save tuned parameters file to '") + filename + "': " + - e.what()); + e.what()); } } -- cgit v1.2.1