COMPMID-1122: Store the cl_context only in one place

Change-Id: I39a8dd34a27f9f891397d58af36bd5f9d152281e
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/130358
Reviewed-by: Pablo Tello <pablo.tello@arm.com>
Tested-by: Jenkins <bsgcomp@arm.com>
diff --git a/arm_compute/core/CL/CLKernelLibrary.h b/arm_compute/core/CL/CLKernelLibrary.h
index 4c42d8e..2511966 100644
--- a/arm_compute/core/CL/CLKernelLibrary.h
+++ b/arm_compute/core/CL/CLKernelLibrary.h
@@ -261,6 +261,16 @@
             _device = cl_devices[0];
         }
     }
+
+    /** Accessor for the associated CL context.
+     *
+     * @return A CL context.
+     */
+    cl::Context &context()
+    {
+        return _context;
+    }
+
     /** Sets the CL device for which the programs are created.
      *
      * @param[in] device A CL device.
diff --git a/arm_compute/runtime/CL/CLScheduler.h b/arm_compute/runtime/CL/CLScheduler.h
index 0d81d73..26b459c 100644
--- a/arm_compute/runtime/CL/CLScheduler.h
+++ b/arm_compute/runtime/CL/CLScheduler.h
@@ -123,7 +123,7 @@
     void init(cl::Context context = cl::Context::getDefault(), cl::CommandQueue queue = cl::CommandQueue::getDefault(),
               cl::Device device = cl::Device::getDefault(), ICLTuner *cl_tuner = nullptr)
     {
-        _context        = std::move(context);
+        set_context(context);
         _queue          = std::move(queue);
         _target         = get_target_from_device(device);
         _is_initialised = true;
@@ -137,7 +137,7 @@
     cl::Context &context()
     {
         ARM_COMPUTE_ERROR_ON(!_is_initialised);
-        return _context;
+        return CLKernelLibrary::get().context();
     }
 
     /** Accessor to set the CL context to be used by the scheduler.
@@ -146,7 +146,7 @@
      */
     void set_context(cl::Context context)
     {
-        _context = std::move(context);
+        CLKernelLibrary::get().set_context(context);
     }
 
     /** Accessor for the associated CL command queue.
@@ -225,7 +225,6 @@
     /** 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;
diff --git a/src/runtime/CL/CLScheduler.cpp b/src/runtime/CL/CLScheduler.cpp
index 2a5d836..fdae615 100644
--- a/src/runtime/CL/CLScheduler.cpp
+++ b/src/runtime/CL/CLScheduler.cpp
@@ -31,7 +31,7 @@
 std::once_flag CLScheduler::_initialize_symbols;
 
 CLScheduler::CLScheduler()
-    : _context(), _queue(), _target(GPUTarget::MIDGARD), _is_initialised(false), _cl_tuner()
+    : _queue(), _target(GPUTarget::MIDGARD), _is_initialised(false), _cl_tuner()
 {
 }