COMPMID-1504: (Nightly) Segfaults on CL and android
Keeps a copy of context in Scheduler to avoid releasing KernelLibrary
resources before Scheduler resourses leading to a segfault.
Does not exactly revert COMPMID-1122 as it still tries to keep context
in sync.
Change-Id: I3deb6bc1725b80f65f51ebd34d536f612ef6dd86
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/144024
Reviewed-by: Michele DiGiorgio <michele.digiorgio@arm.com>
Tested-by: Jenkins <bsgcomp@arm.com>
diff --git a/arm_compute/runtime/CL/CLScheduler.h b/arm_compute/runtime/CL/CLScheduler.h
index 807d8bb..663f78a 100644
--- a/arm_compute/runtime/CL/CLScheduler.h
+++ b/arm_compute/runtime/CL/CLScheduler.h
@@ -74,8 +74,7 @@
* @param[in] cl_tuner (Optional) Pointer to OpenCL tuner (default=nullptr)
* Note: It is caller's responsibility to release the allocated memory for CLTuner
*/
- void init(cl::Context context, cl::CommandQueue queue,
- cl::Device device, ICLTuner *cl_tuner = nullptr)
+ void init(cl::Context context, cl::CommandQueue queue, cl::Device device, ICLTuner *cl_tuner = nullptr)
{
set_context(context);
_queue = std::move(queue);
@@ -91,7 +90,8 @@
cl::Context &context()
{
ARM_COMPUTE_ERROR_ON(!_is_initialised);
- return CLKernelLibrary::get().context();
+ _context = CLKernelLibrary::get().context();
+ return _context;
}
/** Accessor for the associated CL command queue.
@@ -119,7 +119,8 @@
*/
void set_context(cl::Context context)
{
- CLKernelLibrary::get().set_context(context);
+ _context = std::move(context);
+ CLKernelLibrary::get().set_context(_context);
}
/** Accessor to set the CL command queue to be used by the scheduler.
@@ -188,6 +189,7 @@
/** Flag to ensure symbols initialisation is happening before Scheduler creation */
static std::once_flag _initialize_symbols;
+ cl::Context _context;
cl::CommandQueue _queue;
GPUTarget _target;
bool _is_initialised;