From 908f6163155e07e0c2e58c4d05389e0c68122e45 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 4 May 2021 10:11:09 +0100 Subject: 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 Change-Id: Idcd491783b5a413bd944d385956075ead0204362 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5572 Reviewed-by: Michele Di Giorgio Reviewed-by: Aleksandr Nikolaev Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- src/core/CL/CLHelpers.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'src/core/CL/CLHelpers.cpp') diff --git a/src/core/CL/CLHelpers.cpp b/src/core/CL/CLHelpers.cpp index aff897738a..6af378c7ab 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 #include @@ -386,26 +387,15 @@ size_t get_cl_image_pitch_alignment(const cl::Device &device) } } -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(ctx->kernel_library()->create_kernel(kernel_name, build_opts.options())); - } - else - { - // Legacy code through the singleton - return static_cast(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options())); - } -} - cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set &build_opts) { - const std::string program_name = CLKernelLibrary::get().get_program_name(kernel_name); - std::pair kernel_src = CLKernelLibrary::get().get_program(program_name); - const std::string kernel_path = CLKernelLibrary::get().get_kernel_path(); - return static_cast(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(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) -- cgit v1.2.1