From 729099c5d134c2c34459a2bdbd5453ad4ca68cac Mon Sep 17 00:00:00 2001 From: Anitha Raj Date: Tue, 26 Sep 2023 14:24:54 +0100 Subject: Enable job-chaining with incremental job_chaining_size. Resolves COMPMID-6458 Change-Id: I1068da3dee6b6f58e4179f5a92521a6d6457e6c4 Signed-off-by: Anitha Raj Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10380 Benchmark: Arm Jenkins Reviewed-by: Jakub Sujak Reviewed-by: Viet-Hoa Do Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- src/runtime/CL/CLScheduler.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/CL/CLScheduler.cpp b/src/runtime/CL/CLScheduler.cpp index 49fb724cdb..b7a4dff45d 100644 --- a/src/runtime/CL/CLScheduler.cpp +++ b/src/runtime/CL/CLScheduler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2022 Arm Limited. + * Copyright (c) 2016-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -95,8 +95,8 @@ bool CLScheduler::is_initialised() const std::once_flag CLScheduler::_initialize_symbols; CLScheduler::CLScheduler() - : _context(), _queue(), _target(GPUTarget::MIDGARD), _is_initialised(false), _cl_tuner(nullptr), _gemm_heuristics(nullptr), _backend_type(CLBackendType::Native), _job_chaining_enabled(false), - _job_chaining_size(), _job_chaining_count(0) + : _context(), _queue(), _target(GPUTarget::MIDGARD), _is_initialised(false), _cl_tuner(nullptr), _gemm_heuristics(nullptr), _backend_type(CLBackendType::Native), _job_chaining_enabled(true), + _job_chaining_size(1), _job_chaining_count(0) { } @@ -193,6 +193,16 @@ void CLScheduler::flush_queue(bool flush) if(_job_chaining_count >= _job_chaining_size) { _job_chaining_count = 0; + /* + Optimisation note: Flush the queue at the first enqueue to start the GPU + execution and then incrementally saturate the clFlush calls to minimize + the CPU activity for job-scheduling. + For eg. job-chain size goes from 1, 2, 4, 8 and 16 + */ + if(_job_chaining_size < 16) + { + _job_chaining_size <<= 1; + } _queue.flush(); } } -- cgit v1.2.1