blob: d8dd01bd6c4034d51e7bf9d54e01eb700760c26f [file] [log] [blame]
telsoa01c577f2c2018-08-31 09:22:23 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa01c577f2c2018-08-31 09:22:23 +01004//
5
6#include "NeonInterceptorScheduler.hpp"
7
8#include <boost/assert.hpp>
9
10namespace armnn{
11
Derek Lambertie4ba53a2018-10-01 09:28:57 +010012NeonInterceptorScheduler::NeonInterceptorScheduler(arm_compute::IScheduler &realScheduler)
Derek Lamberti57dca8e2018-10-01 17:10:05 +010013 : m_Kernels(nullptr), m_RealScheduler(realScheduler)
telsoa01c577f2c2018-08-31 09:22:23 +010014{
15}
16
17void NeonInterceptorScheduler::set_num_threads(unsigned int numThreads)
18{
19 m_RealScheduler.set_num_threads(numThreads);
20}
21
22unsigned int NeonInterceptorScheduler::num_threads() const
23{
24 return m_RealScheduler.num_threads();
25}
26
27void NeonInterceptorScheduler::schedule(arm_compute::ICPPKernel* kernel, const Hints& hints)
28{
Derek Lambertie4ba53a2018-10-01 09:28:57 +010029 WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
telsoa01c577f2c2018-08-31 09:22:23 +010030 m_RealScheduler.schedule(kernel, hints.split_dimension());
Derek Lambertie4ba53a2018-10-01 09:28:57 +010031 WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();
telsoa01c577f2c2018-08-31 09:22:23 +010032
Derek Lambertie4ba53a2018-10-01 09:28:57 +010033 const auto delta = std::chrono::duration<double, std::micro>(stopTime - startTime);
34 m_Kernels->emplace_back(kernel->name(), delta.count(), Measurement::Unit::TIME_US);
telsoa01c577f2c2018-08-31 09:22:23 +010035}
36
37void NeonInterceptorScheduler::run_workloads(std::vector <Workload>& workloads)
38{
Derek Lambertie4ba53a2018-10-01 09:28:57 +010039 WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
jimfly019fc824a2018-09-24 12:47:14 +010040 m_RealScheduler.run_tagged_workloads(workloads, nullptr);
Derek Lambertie4ba53a2018-10-01 09:28:57 +010041 WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();
telsoa01c577f2c2018-08-31 09:22:23 +010042
Derek Lambertie4ba53a2018-10-01 09:28:57 +010043 const auto delta = std::chrono::duration<double, std::micro>(stopTime - startTime);
44 m_Kernels->emplace_back(std::string("Workload"), delta.count(), Measurement::Unit::TIME_US);
telsoa01c577f2c2018-08-31 09:22:23 +010045}
46
saoste0119bd47d2019-01-24 12:31:58 +000047void NeonInterceptorScheduler::run_tagged_workloads(std::vector<Workload> &workloads, const char *tag)
48{
49 WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
50 m_RealScheduler.run_tagged_workloads(workloads, tag);
51 WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();
52
53 const auto delta = std::chrono::duration<double, std::micro>(stopTime - startTime);
54 m_Kernels->emplace_back(std::string(tag != nullptr ? tag : "Unknown"), delta.count(), Measurement::Unit::TIME_US);
55}
56
telsoa01c577f2c2018-08-31 09:22:23 +010057} // namespace armnn