blob: 932fdb5433489cf1b092db860d21619abdb03815 [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
telsoa01c577f2c2018-08-31 09:22:23 +01008namespace armnn{
9
Derek Lambertie4ba53a2018-10-01 09:28:57 +010010NeonInterceptorScheduler::NeonInterceptorScheduler(arm_compute::IScheduler &realScheduler)
Derek Lamberti57dca8e2018-10-01 17:10:05 +010011 : m_Kernels(nullptr), m_RealScheduler(realScheduler)
telsoa01c577f2c2018-08-31 09:22:23 +010012{
13}
14
15void NeonInterceptorScheduler::set_num_threads(unsigned int numThreads)
16{
17 m_RealScheduler.set_num_threads(numThreads);
18}
19
20unsigned int NeonInterceptorScheduler::num_threads() const
21{
22 return m_RealScheduler.num_threads();
23}
24
25void NeonInterceptorScheduler::schedule(arm_compute::ICPPKernel* kernel, const Hints& hints)
26{
Derek Lambertie4ba53a2018-10-01 09:28:57 +010027 WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
telsoa01c577f2c2018-08-31 09:22:23 +010028 m_RealScheduler.schedule(kernel, hints.split_dimension());
Derek Lambertie4ba53a2018-10-01 09:28:57 +010029 WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();
telsoa01c577f2c2018-08-31 09:22:23 +010030
Derek Lambertie4ba53a2018-10-01 09:28:57 +010031 const auto delta = std::chrono::duration<double, std::micro>(stopTime - startTime);
32 m_Kernels->emplace_back(kernel->name(), delta.count(), Measurement::Unit::TIME_US);
telsoa01c577f2c2018-08-31 09:22:23 +010033}
34
35void NeonInterceptorScheduler::run_workloads(std::vector <Workload>& workloads)
36{
Derek Lambertie4ba53a2018-10-01 09:28:57 +010037 WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
jimfly019fc824a2018-09-24 12:47:14 +010038 m_RealScheduler.run_tagged_workloads(workloads, nullptr);
Derek Lambertie4ba53a2018-10-01 09:28:57 +010039 WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();
telsoa01c577f2c2018-08-31 09:22:23 +010040
Derek Lambertie4ba53a2018-10-01 09:28:57 +010041 const auto delta = std::chrono::duration<double, std::micro>(stopTime - startTime);
42 m_Kernels->emplace_back(std::string("Workload"), delta.count(), Measurement::Unit::TIME_US);
telsoa01c577f2c2018-08-31 09:22:23 +010043}
44
saoste0119bd47d2019-01-24 12:31:58 +000045void NeonInterceptorScheduler::run_tagged_workloads(std::vector<Workload> &workloads, const char *tag)
46{
47 WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
48 m_RealScheduler.run_tagged_workloads(workloads, tag);
49 WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();
50
51 const auto delta = std::chrono::duration<double, std::micro>(stopTime - startTime);
52 m_Kernels->emplace_back(std::string(tag != nullptr ? tag : "Unknown"), delta.count(), Measurement::Unit::TIME_US);
53}
54
Nikhil Raje5617952021-01-22 10:02:38 +000055void NeonInterceptorScheduler::schedule_op(arm_compute::ICPPKernel* kernel,
56 const Hints& hints,
57 const arm_compute::Window& window,
58 arm_compute::ITensorPack& tensors )
David Monahan9b14bfc2020-06-30 15:57:56 +010059{
60
61 WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
Nikhil Raje5617952021-01-22 10:02:38 +000062 m_RealScheduler.schedule_op(kernel, hints, window, tensors);
David Monahan9b14bfc2020-06-30 15:57:56 +010063 WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();
64
65 const auto delta = std::chrono::duration<double, std::micro>(stopTime - startTime);
66 m_Kernels->emplace_back(kernel->name(), delta.count(), Measurement::Unit::TIME_US);
67}
68
telsoa01c577f2c2018-08-31 09:22:23 +010069} // namespace armnn