telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #include "NeonInterceptorScheduler.hpp" |
| 7 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 8 | namespace armnn{ |
| 9 | |
Derek Lamberti | e4ba53a | 2018-10-01 09:28:57 +0100 | [diff] [blame] | 10 | NeonInterceptorScheduler::NeonInterceptorScheduler(arm_compute::IScheduler &realScheduler) |
Derek Lamberti | 57dca8e | 2018-10-01 17:10:05 +0100 | [diff] [blame] | 11 | : m_Kernels(nullptr), m_RealScheduler(realScheduler) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 12 | { |
| 13 | } |
| 14 | |
| 15 | void NeonInterceptorScheduler::set_num_threads(unsigned int numThreads) |
| 16 | { |
| 17 | m_RealScheduler.set_num_threads(numThreads); |
| 18 | } |
| 19 | |
| 20 | unsigned int NeonInterceptorScheduler::num_threads() const |
| 21 | { |
| 22 | return m_RealScheduler.num_threads(); |
| 23 | } |
| 24 | |
| 25 | void NeonInterceptorScheduler::schedule(arm_compute::ICPPKernel* kernel, const Hints& hints) |
| 26 | { |
Derek Lamberti | e4ba53a | 2018-10-01 09:28:57 +0100 | [diff] [blame] | 27 | WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 28 | m_RealScheduler.schedule(kernel, hints.split_dimension()); |
Derek Lamberti | e4ba53a | 2018-10-01 09:28:57 +0100 | [diff] [blame] | 29 | WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 30 | |
Derek Lamberti | e4ba53a | 2018-10-01 09:28:57 +0100 | [diff] [blame] | 31 | const auto delta = std::chrono::duration<double, std::micro>(stopTime - startTime); |
| 32 | m_Kernels->emplace_back(kernel->name(), delta.count(), Measurement::Unit::TIME_US); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | void NeonInterceptorScheduler::run_workloads(std::vector <Workload>& workloads) |
| 36 | { |
Derek Lamberti | e4ba53a | 2018-10-01 09:28:57 +0100 | [diff] [blame] | 37 | WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now(); |
jimfly01 | 9fc824a | 2018-09-24 12:47:14 +0100 | [diff] [blame] | 38 | m_RealScheduler.run_tagged_workloads(workloads, nullptr); |
Derek Lamberti | e4ba53a | 2018-10-01 09:28:57 +0100 | [diff] [blame] | 39 | WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 40 | |
Derek Lamberti | e4ba53a | 2018-10-01 09:28:57 +0100 | [diff] [blame] | 41 | 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); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 43 | } |
| 44 | |
saoste01 | 19bd47d | 2019-01-24 12:31:58 +0000 | [diff] [blame] | 45 | void 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 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 55 | } // namespace armnn |