From 6f8b17dedb7b53b550e6210fd1c78c3a3e086271 Mon Sep 17 00:00:00 2001 From: Joseph Dobson Date: Tue, 11 Feb 2020 19:32:11 +0000 Subject: [ONCPUML-7] arm_compute support for ND parallelism Currently 1D ranges of work are specified by the scheduler via two integers, start and end. This limit opportunities for advance parallelism and scheduling This patch expands the interfaces to allow for ND parallism. `GemmCommon::get_window_size` now returns an `NDRange` specifying the work in N-dimensions rather than with the single integer it used prior (1D) Execute now takes an `NDCoordinate` which specifies an `NDRange` with a start position for that work along with an `NDCoordinate` to specify the thread location In addition to expanding the interface to enable this functionality, we have added the capability to SGEMM when the number of threads is high this has the effective of allowing a much greater degree of parallelism where te problem dimension would previously have limited the number of threads. Change-Id: I3e1a8b7276216627bec4ff6f24ac2147552ea9fb Signed-off-by: Joseph Dobson Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/2962 Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice Comments-Addressed: Arm Jenkins --- .../kernels/assembly/NEGEMMAssemblyWrapperKernel.h | 35 +++++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'arm_compute/core/NEON/kernels/assembly/NEGEMMAssemblyWrapperKernel.h') diff --git a/arm_compute/core/NEON/kernels/assembly/NEGEMMAssemblyWrapperKernel.h b/arm_compute/core/NEON/kernels/assembly/NEGEMMAssemblyWrapperKernel.h index d612681c41..0e3dd74577 100644 --- a/arm_compute/core/NEON/kernels/assembly/NEGEMMAssemblyWrapperKernel.h +++ b/arm_compute/core/NEON/kernels/assembly/NEGEMMAssemblyWrapperKernel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 ARM Limited. + * Copyright (c) 2018-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -24,6 +24,7 @@ #ifndef ARM_COMPUTE_ASSEMBLY_GEMM_KERNEL_WRAPPER_KERNEL_H #define ARM_COMPUTE_ASSEMBLY_GEMM_KERNEL_WRAPPER_KERNEL_H +#include "arm_compute/core/NEON/kernels/assembly/arm_gemm_compute_iface.hpp" #include "arm_compute/core/NEON/INEKernel.h" #include "arm_compute/core/Utils.h" #include "arm_compute/core/Validate.h" @@ -65,15 +66,33 @@ public: { return _name.c_str(); } - // Inherited methods overridden: + + void run(const Window &window, const ThreadInfo &info) override { ARM_COMPUTE_ERROR_ON_NULLPTR((reinterpret_cast(_kernel))); ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - auto first = window.x().start(); - auto last = window.x().end(); - _kernel->execute(first, last, info.thread_id); + + auto win=arm_gemm::to_ndcoord(window); + + arm_gemm::ndcoord_t thread_locator { }; + + _kernel->execute(win, thread_locator, info.thread_id); } + + // Inherited methods overridden: + void run_nd(const Window &window, const ThreadInfo &info, const Window &thread_locator) override + { + ARM_COMPUTE_ERROR_ON_NULLPTR((reinterpret_cast(_kernel))); + ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); + + //convert between arm_compute and arm_gemm types + auto ndc_win = arm_gemm::to_ndcoord(window); + auto ndc_tlc = arm_gemm::to_ndcoord(thread_locator); + + _kernel->execute(ndc_win, ndc_tlc, info.thread_id); + } + /** Initialise the kernel's input and output. * * @param[in] kernel Pointer to an assembly kernel implementation. @@ -83,9 +102,9 @@ public: { ARM_COMPUTE_ERROR_ON_NULLPTR((reinterpret_cast(kernel))); _kernel = kernel; - auto win_last = _kernel->get_window_size(); - Window win; - win.set(Window::DimX, Window::Dimension(0, win_last, 1)); + + Window win = to_window(kernel->get_window_size()); + INEKernel::configure(win); if(!kernel_name_tag.empty()) -- cgit v1.2.1