From 06e890b1475243145d64c7d56dfb4a262a17b09f Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Thu, 9 Jul 2020 18:38:34 +0100 Subject: COMPMID-3565: Exposes interface to enable thread binding Expose `set_num_threads_with_affinity` as an interface to the `IScheduler` to allow binding of threads to given logical cores. Signed-off-by: Georgios Pinitas Change-Id: I062db7caafb0101972ba45d31ee9e61b26800127 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3481 Comments-Addressed: Arm Jenkins Reviewed-by: Michalis Spyrou Tested-by: Arm Jenkins --- arm_compute/runtime/IScheduler.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'arm_compute/runtime/IScheduler.h') diff --git a/arm_compute/runtime/IScheduler.h b/arm_compute/runtime/IScheduler.h index 9382c20b29..fff77274bd 100644 --- a/arm_compute/runtime/IScheduler.h +++ b/arm_compute/runtime/IScheduler.h @@ -47,6 +47,13 @@ public: DYNAMIC, /**< Split the workload dynamically using a bucket system */ }; + /** Function to be used and map a given thread id to a logical core id + * + * Mapping function expects the thread index and total number of cores as input, + * and returns the logical core index to bind against + */ + using BindFunc = std::function; + /** When arm_compute::ISchedular::Hints::_split_dimension is initialized with this value * then the schedular is free to break down the problem space over as many dimensions * as it wishes @@ -137,6 +144,13 @@ public: */ virtual void set_num_threads(unsigned int num_threads) = 0; + /** Sets the number of threads the scheduler will use to run the kernels but also using a binding function to pin the threads to given logical cores + * + * @param[in] num_threads If set to 0, then one thread per CPU core available on the system will be used, otherwise the number of threads specified. + * @param[in] func Binding function to use. + */ + virtual void set_num_threads_with_affinity(unsigned int num_threads, BindFunc func); + /** Returns the number of threads that the SingleThreadScheduler has in his pool. * * @return Number of threads available in SingleThreadScheduler. -- cgit v1.2.1