Creates ClKerneLibrary to serve just as a kernel container without build logic

Moves all the kernels out of the legacy CLKernelLibrary into a separate
class that its planned responsibility is to only handle the kernel
strings.

Currently CLKernelLibrary mixes kernel inventory and building logic,
thus coupling multiple responsibilities.
By separating compilation logic, the kernel library removes any dependencies
from the OpenCL and simplifies maintainance but also increases flexibility.

Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com>
Change-Id: Idcd491783b5a413bd944d385956075ead0204362
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5572
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Reviewed-by: Aleksandr Nikolaev <aleksandr.nikolaev@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
diff --git a/src/core/CL/CLHelpers.cpp b/src/core/CL/CLHelpers.cpp
index aff8977..6af378c 100644
--- a/src/core/CL/CLHelpers.cpp
+++ b/src/core/CL/CLHelpers.cpp
@@ -22,12 +22,13 @@
  * SOFTWARE.
  */
 #include "arm_compute/core/CL/CLHelpers.h"
-#include "arm_compute/core/CL/CLCoreRuntimeContext.h"
-#include "arm_compute/core/CL/CLKernelLibrary.h"
 #include "arm_compute/core/CL/CLTypes.h"
 #include "arm_compute/core/Error.h"
 #include "arm_compute/core/Log.h"
 #include "arm_compute/core/Types.h"
+#include "src/core/gpu/cl/ClCompileContext.h"
+
+#include "src/core/gpu/cl/ClKernelLibrary.h"
 
 #include <utility>
 #include <vector>
@@ -386,26 +387,15 @@
     }
 }
 
-cl::Kernel create_opencl_kernel(CLCoreRuntimeContext *ctx, const std::string &kernel_name, const CLBuildOptions &build_opts)
-{
-    if(ctx && ctx->kernel_library())
-    {
-        // New api going through the core context
-        return static_cast<cl::Kernel>(ctx->kernel_library()->create_kernel(kernel_name, build_opts.options()));
-    }
-    else
-    {
-        // Legacy code through the singleton
-        return static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options()));
-    }
-}
-
 cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set<std::string> &build_opts)
 {
-    const std::string program_name = CLKernelLibrary::get().get_program_name(kernel_name);
-    std::pair<std::string, bool> kernel_src = CLKernelLibrary::get().get_program(program_name);
-    const std::string kernel_path = CLKernelLibrary::get().get_kernel_path();
-    return static_cast<cl::Kernel>(ctx.create_kernel(kernel_name, program_name, kernel_src.first, kernel_path, build_opts, kernel_src.second));
+    opencl::ClKernelLibrary &klib = opencl::ClKernelLibrary::get();
+
+    const std::string program_name = klib.program_name(kernel_name);
+    auto              kernel_src   = klib.program(program_name);
+    const std::string kernel_path  = klib.kernel_path();
+
+    return static_cast<cl::Kernel>(ctx.create_kernel(kernel_name, program_name, kernel_src.program, kernel_path, build_opts, kernel_src.is_binary));
 }
 
 cl::NDRange create_lws_hint_parallel_implementations(unsigned int input_dimension, unsigned int vector_size)