aboutsummaryrefslogtreecommitdiff
path: root/arm_compute
diff options
context:
space:
mode:
authorDavid Svantesson <david.svantesson@arm.com>2023-08-02 14:23:00 +0000
committerDavid Svantesson <david.svantesson-yeung@arm.com>2023-11-24 15:03:05 +0000
commitded5b182675e3166e947a8eb637b5b1e925816ab (patch)
treec7bc082e7e8d80f0d33c69fc903be9dcb342e7f3 /arm_compute
parente30c8740d2da7af52ae1320f4d597ffc73d41c5e (diff)
downloadComputeLibrary-ded5b182675e3166e947a8eb637b5b1e925816ab.tar.gz
thread_local _custom_scheduler
Resolves ONCPUML-1331 This patch adds an option to make _custom_scheduler thread_local to support usage of multiple schedulers handled outside of ACL. It also adds num_threads() function to Scheduler which reverts to querying CPUInfo if no scheduler has been set. Change-Id: Iff706165d8d091895331a5bb3a76f6cabe048912 Signed-off-by: David Svantesson-Yeung <david.svantesson-yeung@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10748 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: SiCong Li <sicong.li@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute')
-rw-r--r--arm_compute/runtime/Scheduler.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/arm_compute/runtime/Scheduler.h b/arm_compute/runtime/Scheduler.h
index bd29cbb31f..481e5e9b60 100644
--- a/arm_compute/runtime/Scheduler.h
+++ b/arm_compute/runtime/Scheduler.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Arm Limited.
+* Copyright (c) 2017-2019, 2023 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -21,8 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef ARM_COMPUTE_SCHEDULER_H
-#define ARM_COMPUTE_SCHEDULER_H
+#ifndef ACL_ARM_COMPUTE_RUNTIME_SCHEDULER_H
+#define ACL_ARM_COMPUTE_RUNTIME_SCHEDULER_H
#include "arm_compute/runtime/IScheduler.h"
@@ -72,13 +72,27 @@ public:
* @return true if the given scheduler type is supported. False otherwise.
*/
static bool is_available(Type t);
+ /** Returns true if a scheduler has been set.
+ *
+ * @return true if a scheduler has been set. False otherwise.
+ */
+ static bool is_set();
+ /** Returns number of threads from scheduler if scheduler is set, otherwise queries CPUInfo.
+ *
+ * @return number of threads from scheduler if scheduler is set, otherwise queries CPUInfo.
+ */
+ static unsigned int num_threads();
private:
- static Type _scheduler_type;
- static std::shared_ptr<IScheduler> _custom_scheduler;
+ static Type _scheduler_type;
+#ifndef ARM_COMPUTE_THREAD_LOCAL_SCHEDULER
+ static std::shared_ptr<IScheduler> _custom_scheduler;
+#else // ARM_COMPUTE_THREAD_LOCAL_SCHEDULER
+ static std::shared_ptr<IScheduler> thread_local _custom_scheduler;
+#endif // ARM_COMPUTE_THREAD_LOCAL_SCHEDULER
static std::map<Type, std::unique_ptr<IScheduler>> _schedulers;
Scheduler();
};
} // namespace arm_compute
-#endif /* ARM_COMPUTE_SCHEDULER_H */
+#endif // ACL_ARM_COMPUTE_RUNTIME_SCHEDULER_H