From 72ccc440b5312160ede96f9c27c747965a5b08bf Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 14 Aug 2018 12:52:53 +0100 Subject: 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 Tested-by: Jenkins --- arm_compute/runtime/CL/CLScheduler.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'arm_compute/runtime/CL/CLScheduler.h') diff --git a/arm_compute/runtime/CL/CLScheduler.h b/arm_compute/runtime/CL/CLScheduler.h index 807d8bb448..663f78a56c 100644 --- a/arm_compute/runtime/CL/CLScheduler.h +++ b/arm_compute/runtime/CL/CLScheduler.h @@ -74,8 +74,7 @@ public: * @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 @@ public: 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 @@ public: */ 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 @@ private: /** 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; -- cgit v1.2.1