aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNina Drozd <nina.drozd@arm.com>2018-09-21 18:42:09 +0100
committerMatthew Bentham <matthew.bentham@arm.com>2018-10-10 16:16:57 +0100
commit69851b525b9040ee7bf4b796efe74d473bc4e321 (patch)
tree1a3b0ae764a6bc4c4249c69df198fef3bb92c833
parente448be3ac55897a3eabe85962891f8414f8e3cf9 (diff)
downloadarmnn-69851b525b9040ee7bf4b796efe74d473bc4e321.tar.gz
IVGCVSW-1821 - update NEON workload utils to use timers in correct order, updated units used in NeonTimer
Change-Id: I593af42bd2930dd9d147354b706087e3ac260fe9
-rw-r--r--src/armnn/NeonInterceptorScheduler.cpp2
-rw-r--r--src/armnn/WallClockTimer.cpp26
-rw-r--r--src/armnn/WallClockTimer.hpp4
-rw-r--r--src/armnn/test/JsonPrinterTests.cpp6
-rw-r--r--src/backends/NeonWorkloadUtils.hpp4
5 files changed, 34 insertions, 8 deletions
diff --git a/src/armnn/NeonInterceptorScheduler.cpp b/src/armnn/NeonInterceptorScheduler.cpp
index 8363def68e..7e2737e89e 100644
--- a/src/armnn/NeonInterceptorScheduler.cpp
+++ b/src/armnn/NeonInterceptorScheduler.cpp
@@ -31,6 +31,7 @@ void NeonInterceptorScheduler::schedule(arm_compute::ICPPKernel* kernel, const H
m_RealScheduler.schedule(kernel, hints.split_dimension());
m_Timer.Stop();
+ m_Timer.SetScaleFactor(Measurement::Unit::TIME_US);
std::vector<Measurement> measurements = m_Timer.GetMeasurements();
BOOST_ASSERT(!measurements.empty());
@@ -46,6 +47,7 @@ void NeonInterceptorScheduler::run_workloads(std::vector <Workload>& workloads)
m_RealScheduler.run_tagged_workloads(workloads, nullptr);
m_Timer.Stop();
+ m_Timer.SetScaleFactor(Measurement::Unit::TIME_US);
std::vector<Measurement> measurements = m_Timer.GetMeasurements();
BOOST_ASSERT_MSG(measurements.size() == 3, "WallClockTimer does not have correct amount of measurements.");
diff --git a/src/armnn/WallClockTimer.cpp b/src/armnn/WallClockTimer.cpp
index 882b7eb6ef..911b0147e0 100644
--- a/src/armnn/WallClockTimer.cpp
+++ b/src/armnn/WallClockTimer.cpp
@@ -4,6 +4,7 @@
//
#include "WallClockTimer.hpp"
+#include "armnn/Exceptions.hpp"
namespace armnn
{
@@ -27,15 +28,34 @@ void WallClockTimer::Stop()
m_Stop = clock::now();
}
+void WallClockTimer::SetScaleFactor(Measurement::Unit measurementUnit)
+{
+ switch(measurementUnit)
+ {
+ case Measurement::TIME_MS:
+ m_ScaleFactor = 1.f;
+ break;
+ case Measurement::TIME_US:
+ m_ScaleFactor = 1000.f;
+ break;
+ case Measurement::TIME_NS:
+ m_ScaleFactor = 1000000.f;
+ break;
+ default:
+ throw InvalidArgumentException("Invalid scale used");
+ }
+ m_Unit = measurementUnit;
+}
+
std::vector<Measurement> WallClockTimer::GetMeasurements() const
{
const auto delta = std::chrono::duration<double, std::milli>(m_Stop - m_Start);
const auto startTimeMs = std::chrono::duration<double, std::milli>(m_Start.time_since_epoch());
const auto stopTimeMs = std::chrono::duration<double, std::milli>(m_Stop.time_since_epoch());
- return { { WALL_CLOCK_TIME, delta.count(), Measurement::Unit::TIME_MS },
- { WALL_CLOCK_TIME_START, startTimeMs.count(), Measurement::Unit::TIME_MS },
- { WALL_CLOCK_TIME_STOP, stopTimeMs.count(), Measurement::Unit::TIME_MS } };
+ return { { WALL_CLOCK_TIME, delta.count() * m_ScaleFactor, m_Unit },
+ { WALL_CLOCK_TIME_START, startTimeMs.count() * m_ScaleFactor, m_Unit },
+ { WALL_CLOCK_TIME_STOP, stopTimeMs.count() * m_ScaleFactor, m_Unit } };
}
} //namespace armnn
diff --git a/src/armnn/WallClockTimer.hpp b/src/armnn/WallClockTimer.hpp
index 5e88382015..09cc514eae 100644
--- a/src/armnn/WallClockTimer.hpp
+++ b/src/armnn/WallClockTimer.hpp
@@ -42,6 +42,8 @@ public:
// Get the name of the timer
const char* GetName() const override;
+ void SetScaleFactor(Measurement::Unit measurementUnit);
+
// Get the recorded measurements
std::vector<Measurement> GetMeasurements() const override;
@@ -58,6 +60,8 @@ public:
private:
clock::time_point m_Start;
clock::time_point m_Stop;
+ float m_ScaleFactor = 1.f;
+ Measurement::Unit m_Unit = Measurement::Unit::TIME_MS;
};
} //namespace armnn
diff --git a/src/armnn/test/JsonPrinterTests.cpp b/src/armnn/test/JsonPrinterTests.cpp
index 18adfc258d..01078e3666 100644
--- a/src/armnn/test/JsonPrinterTests.cpp
+++ b/src/armnn/test/JsonPrinterTests.cpp
@@ -276,7 +276,7 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult(
break;
case armnn::Compute::CpuAcc: backend = "Neon";
changeLine31 = ",\n\"NeonKernelTimer/: NEFillBorderKernel\": {";
- changeLine39 = R"(ms"
+ changeLine39 = R"(us"
},
"NeonKernelTimer/: NELogitsDMaxKernel": {
"raw": [
@@ -284,7 +284,7 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult(
,
],
-"unit": "ms"
+"unit": "us"
},
"NeonKernelTimer/: NELogitsDSoftmaxKernel": {
"raw": [
@@ -292,7 +292,7 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult(
,
],
-"unit": "ms")";
+"unit": "us")";
changeLine40 = R"(
},
"CopyMemGeneric_Execute": {
diff --git a/src/backends/NeonWorkloadUtils.hpp b/src/backends/NeonWorkloadUtils.hpp
index 15f9e3badf..f3c8866f6d 100644
--- a/src/backends/NeonWorkloadUtils.hpp
+++ b/src/backends/NeonWorkloadUtils.hpp
@@ -30,5 +30,5 @@ void InitializeArmComputeTensorDataForFloatTypes(arm_compute::Tensor& tensor, co
#define ARMNN_SCOPED_PROFILING_EVENT_NEON(name) \
ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS(armnn::Compute::CpuAcc, \
name, \
- armnn::WallClockTimer(), \
- armnn::NeonTimer())
+ armnn::NeonTimer(), \
+ armnn::WallClockTimer())