From 5f9107280d098de719782530e19663cd655c9a71 Mon Sep 17 00:00:00 2001 From: steniu01 Date: Wed, 23 Aug 2017 10:15:22 +0100 Subject: COMPMID-513 Choose maximum local workgroup size at run time Change-Id: I9ab3cf6dc92a93b0ae5f746e078355e443b3a545 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/84906 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- arm_compute/core/CL/CLKernelLibrary.h | 25 +++++++++++++++++++++---- arm_compute/core/CL/ICLKernel.h | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'arm_compute/core/CL') diff --git a/arm_compute/core/CL/CLKernelLibrary.h b/arm_compute/core/CL/CLKernelLibrary.h index 38cfad6c1d..4d4565d6fd 100644 --- a/arm_compute/core/CL/CLKernelLibrary.h +++ b/arm_compute/core/CL/CLKernelLibrary.h @@ -162,9 +162,11 @@ public: */ void init(std::string kernel_path = ".", cl::Context context = cl::Context::getDefault(), cl::Device device = cl::Device::getDefault()) { - _kernel_path = std::move(kernel_path); - _context = std::move(context); - _device = std::move(device); + _kernel_path = std::move(kernel_path); + _context = std::move(context); + _device = std::move(device); + _max_workgroup_size = 0; + max_local_workgroup_size(); } /** Sets the path that the kernels reside in. * @@ -206,6 +208,9 @@ public: { _device = cl_devices[0]; } + + _max_workgroup_size = 0; + max_local_workgroup_size(); }; /** Sets the CL device for which the programs are created. * @@ -213,7 +218,9 @@ public: */ void set_device(cl::Device device) { - _device = std::move(device); + _device = std::move(device); + _max_workgroup_size = 0; + max_local_workgroup_size(); }; /** Creates a kernel from the kernel library. * @@ -231,6 +238,15 @@ public: * */ void load_binary(); + /** Find the maximum number of local work items in a workgroup can be supported by the device + * + */ + size_t max_local_workgroup_size(); + + /** Return the default NDRange that is suitable for the device. + * + */ + cl::NDRange default_ndrange(); private: /** Load program and its dependencies. @@ -254,6 +270,7 @@ private: static const std::map _kernel_program_map; /**< Map that associates kernel names with programs. */ static const std::map _program_source_map; /**< Contains sources for all programs. Used for compile-time kernel inclusion. >*/ + size_t _max_workgroup_size; /** Maximum local workgroup size supported on the device */ }; } #endif /* __ARM_COMPUTE_CLKERNELLIBRARY_H__ */ diff --git a/arm_compute/core/CL/ICLKernel.h b/arm_compute/core/CL/ICLKernel.h index d96b9c026e..cfbf760f1e 100644 --- a/arm_compute/core/CL/ICLKernel.h +++ b/arm_compute/core/CL/ICLKernel.h @@ -24,6 +24,7 @@ #ifndef __ARM_COMPUTE_ICLKERNEL_H__ #define __ARM_COMPUTE_ICLKERNEL_H__ +#include "arm_compute/core/CL/CLKernelLibrary.h" #include "arm_compute/core/CL/CLTypes.h" #include "arm_compute/core/CL/OpenCL.h" #include "arm_compute/core/IKernel.h" @@ -175,6 +176,6 @@ protected: * * @note If any dimension of the lws is greater than the global workgroup size then no lws will be passed. */ -void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint = cl::Range_128_1); +void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint = CLKernelLibrary::get().default_ndrange()); } #endif /*__ARM_COMPUTE_ICLKERNEL_H__ */ -- cgit v1.2.1