#include "ClContextControl.hpp"
-#include "armnn/Exceptions.hpp"
+#include <armnn/Exceptions.hpp>
+
+#include <LeakChecking.hpp>
-#ifdef ARMCOMPUTECL_ENABLED
#include <arm_compute/core/CL/CLKernelLibrary.h>
#include <arm_compute/runtime/CL/CLScheduler.h>
-#endif
#include <boost/assert.hpp>
#include <boost/format.hpp>
#include <boost/polymorphic_cast.hpp>
#include <boost/core/ignore_unused.hpp>
-#include "LeakChecking.hpp"
-
namespace cl
{
class Context;
// Ignore m_ProfilingEnabled if unused to avoid compiling problems when ArmCompute is disabled.
boost::ignore_unused(m_ProfilingEnabled);
-#ifdef ARMCOMPUTECL_ENABLED
try
{
std::vector<cl::Platform> platforms;
// Always load the OpenCL runtime.
LoadOpenClRuntime();
-#endif
}
ClContextControl::~ClContextControl()
{
-#ifdef ARMCOMPUTECL_ENABLED
// Load the OpencCL runtime without the tuned parameters to free the memory for them.
try
{
std::cerr << "A CL error occurred unloading the runtime tuner parameters: "
<< clError.what() << ". CL error code is: " << clError.err() << std::endl;
}
-#endif
}
void ClContextControl::LoadOpenClRuntime()
void ClContextControl::DoLoadOpenClRuntime(bool useTunedParameters)
{
-#ifdef ARMCOMPUTECL_ENABLED
cl::Device device = cl::Device::getDefault();
cl::Context context;
cl::CommandQueue commandQueue;
tuner = &m_clTunedParameters->m_Tuner;
}
arm_compute::CLScheduler::get().init(context, commandQueue, device, tuner);
-#endif
}
void ClContextControl::ClearClCache()
ClTunedParameters::ClTunedParameters(armnn::IGpuAccTunedParameters::Mode mode)
: m_Mode(mode)
-#ifdef ARMCOMPUTECL_ENABLED
, m_Tuner(mode == ClTunedParameters::Mode::UpdateTunedParameters)
-#endif
{
}
void ClTunedParameters::Load(const char* filename)
{
-#ifdef ARMCOMPUTECL_ENABLED
try
{
m_Tuner.load_from_file(filename);
throw armnn::Exception(std::string("Failed to load tuned parameters file '") + filename + "': " +
e.what());
}
-#endif
}
void ClTunedParameters::Save(const char* filename) const
{
-#ifdef ARMCOMPUTECL_ENABLED
try
{
m_Tuner.save_to_file(filename);
throw armnn::Exception(std::string("Failed to save tuned parameters file to '") + filename + "': " +
e.what());
}
-#endif
}
} // namespace armnn