IVGCVSW-1821 - taking out scale factor again as it's polluting the WallClockTimer...
authorNina Drozd <nina.drozd@arm.com>
Thu, 27 Sep 2018 10:53:34 +0000 (11:53 +0100)
committerMatthew Bentham <matthew.bentham@arm.com>
Wed, 10 Oct 2018 15:16:57 +0000 (16:16 +0100)
Change-Id: Ia90b709ddfff321dbc218add4ab19737f68a44bf

src/armnn/NeonInterceptorScheduler.cpp
src/armnn/WallClockTimer.cpp
src/armnn/WallClockTimer.hpp
src/armnn/test/InstrumentTests.cpp
src/armnn/test/JsonPrinterTests.cpp
src/armnn/test/ProfilingEventTest.cpp

index 7e2737e89e9799e12163374a5696b2368b379ebf..8363def68ef8d803b7bfa1798ec82937ac15c500 100644 (file)
@@ -31,7 +31,6 @@ 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());
 
@@ -47,7 +46,6 @@ 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.");
 
index 911b0147e011d09ebacbf1d0af8a534c19bf5f7d..570b69077ab6ec0b15e7d5c4e27d5556656fca83 100644 (file)
@@ -4,7 +4,6 @@
 //
 
 #include "WallClockTimer.hpp"
-#include "armnn/Exceptions.hpp"
 
 namespace armnn
 {
@@ -28,34 +27,15 @@ 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());
+    const auto delta       = std::chrono::duration<double, std::micro>(m_Stop - m_Start);
+    const auto startTimeMs = std::chrono::duration<double, std::micro>(m_Start.time_since_epoch());
+    const auto stopTimeMs  = std::chrono::duration<double, std::micro>(m_Stop.time_since_epoch());
 
-    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 } };
+    return { { WALL_CLOCK_TIME,       delta.count(),       Measurement::Unit::TIME_US },
+             { WALL_CLOCK_TIME_START, startTimeMs.count(), Measurement::Unit::TIME_US },
+             { WALL_CLOCK_TIME_STOP,  stopTimeMs.count(),  Measurement::Unit::TIME_US } };
 }
 
 } //namespace armnn
index 09cc514eae081d350d30628409a9790cbf1b9045..88cbb4d50de75e61d7584bfc3ffbaf0768b88562 100644 (file)
@@ -25,7 +25,7 @@ public:
     }
 };
 
-// Implementation of an instrument to measure elapsed wall-clock time in milliseconds.
+// Implementation of an instrument to measure elapsed wall-clock time in microseconds.
 class WallClockTimer : public Instrument
 {
 public:
@@ -42,8 +42,6 @@ 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;
 
@@ -60,8 +58,6 @@ 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
index 11d8414296fe41dd118ee491a8b7b24ae42bed60..40ffde8801b86c36b9affc3fee67dbf349af7e35 100644 (file)
@@ -13,7 +13,7 @@ using namespace armnn;
 
 BOOST_AUTO_TEST_SUITE(Instruments)
 
-BOOST_AUTO_TEST_CASE(WallClockTimerInMilliseconds)
+BOOST_AUTO_TEST_CASE(WallClockTimerInMicroseconds)
 {
     WallClockTimer wallClockTimer;
 
@@ -22,16 +22,16 @@ BOOST_AUTO_TEST_CASE(WallClockTimerInMilliseconds)
     // start the timer
     wallClockTimer.Start();
 
-    // wait for 10 milliseconds
-    std::this_thread::sleep_for(std::chrono::milliseconds(10));
+    // wait for 10 microseconds
+    std::this_thread::sleep_for(std::chrono::microseconds(10));
 
    // stop the timer
     wallClockTimer.Stop();
 
     BOOST_CHECK_EQUAL(wallClockTimer.GetMeasurements().front().m_Name, WallClockTimer::WALL_CLOCK_TIME);
 
-    // check that WallClockTimer measurement should be >= 10 milliseconds
-    BOOST_CHECK_GE(wallClockTimer.GetMeasurements().front().m_Value, std::chrono::milliseconds(10).count());
+    // check that WallClockTimer measurement should be >= 10 microseconds
+    BOOST_CHECK_GE(wallClockTimer.GetMeasurements().front().m_Value, std::chrono::microseconds(10).count());
 }
 
 BOOST_AUTO_TEST_CASE(WallClockTimerInNanoseconds)
@@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(WallClockTimerInNanoseconds)
     // start the timer
     wallClockTimer.Start();
 
-    // wait for 500 nanoseconds - 0.0005 milliseconds
+    // wait for 500 nanoseconds - 0.5 microseconds
     std::this_thread::sleep_for(std::chrono::nanoseconds(500));
 
     // stop the timer
@@ -51,11 +51,11 @@ BOOST_AUTO_TEST_CASE(WallClockTimerInNanoseconds)
 
     BOOST_CHECK_EQUAL(wallClockTimer.GetMeasurements().front().m_Name, WallClockTimer::WALL_CLOCK_TIME);
 
-    // delta is 0.0005 milliseconds
+    // delta is 0.5 microseconds
     const auto delta =
-        std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(std::chrono::nanoseconds(500));
+        std::chrono::duration_cast<std::chrono::duration<double, std::micro>>(std::chrono::nanoseconds(500));
 
-    // check that WallClockTimer measurement should be >= 0.0005 milliseconds
+    // check that WallClockTimer measurement should be >= 0.5 microseconds
     BOOST_CHECK_GE(wallClockTimer.GetMeasurements().front().m_Value, delta.count());
 }
 
index 01078e366687c510d2d5450f921ee9dd78e6b141..aae7dba0f50f4f4455e935f928675f4503b897b3 100644 (file)
@@ -246,7 +246,7 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult(
 
     std::string backend = "Ref";
     std::string changeLine31 = "\n},\n\"CopyMemGeneric_Execute\": {";
-    std::string changeLine39 = "ms\"";
+    std::string changeLine39 = "us\"";
     std::string changeLine40;
     std::string changeLine45;
 
@@ -271,7 +271,7 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult(
 ,
 
 ],
-"unit": "ms")";
+"unit": "us")";
             changeLine45 = "}\n";
             break;
         case armnn::Compute::CpuAcc: backend = "Neon";
@@ -301,7 +301,7 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult(
 ,
 
 ],
-"unit": "ms")";
+"unit": "us")";
             changeLine45 = "}\n";
             break;
         default:
@@ -315,21 +315,21 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult(
 ,
 
 ],
-"unit": "ms",
+"unit": "us",
 "layer_measurements": {
 "raw": [
 ,
 ,
 
 ],
-"unit": "ms",
+"unit": "us",
 "CopyMemGeneric_Execute": {
 "raw": [
 ,
 ,
 
 ],
-"unit": "ms"
+"unit": "us"
 },
 ")" + backend + R"(SoftmaxUintWorkload_Execute": {
 "raw": [
@@ -337,7 +337,7 @@ void SetupSoftmaxProfilerWithSpecifiedBackendsAndValidateJSONPrinterResult(
 ,
 
 ],
-"unit": "ms")" + changeLine31 + R"(
+"unit": "us")" + changeLine31 + R"(
 "raw": [
 ,
 ,
index 33396b1a1967602368b22e86a34ab767b3f88b6d..9e31ccb3238a23e641998ecb3d58eb6c8965193f 100644 (file)
@@ -32,8 +32,8 @@ BOOST_AUTO_TEST_CASE(ProfilingEventTest)
     // start the timer - outer
     testEvent.Start();
 
-    // wait for 10 milliseconds
-    std::this_thread::sleep_for(std::chrono::milliseconds(10));
+    // wait for 10 microseconds
+    std::this_thread::sleep_for(std::chrono::microseconds(10));
 
     // stop the timer - outer
     testEvent.Stop();
@@ -74,8 +74,8 @@ BOOST_AUTO_TEST_CASE(ProfilingEventTestOnGpuAcc)
     // start the timer - outer
     testEvent.Start();
 
-    // wait for 10 milliseconds
-    std::this_thread::sleep_for(std::chrono::milliseconds(10));
+    // wait for 10 microseconds
+    std::this_thread::sleep_for(std::chrono::microseconds(10));
 
     // stop the timer - outer
     testEvent.Stop();