[Mlir-commits] [mlir] 1dd3797 - [mlir] Fix various issues in TimerImpl.

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jul 21 20:44:59 PDT 2021


Author: rdzhabarov
Date: 2021-07-22T03:44:48Z
New Revision: 1dd37975b56eaff210a37e078927f7ea0ffac7ad

URL: https://github.com/llvm/llvm-project/commit/1dd37975b56eaff210a37e078927f7ea0ffac7ad
DIFF: https://github.com/llvm/llvm-project/commit/1dd37975b56eaff210a37e078927f7ea0ffac7ad.diff

LOG: [mlir] Fix various issues in TimerImpl.

More specifically:
1) Use variable after move.
2) steady_clock needs to be used for measuring time intervals, but not the system_clock.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D106513

Added: 
    

Modified: 
    mlir/lib/Support/Timing.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Support/Timing.cpp b/mlir/lib/Support/Timing.cpp
index d2a05edeced10..11afe1e717422 100644
--- a/mlir/lib/Support/Timing.cpp
+++ b/mlir/lib/Support/Timing.cpp
@@ -178,11 +178,11 @@ class TimerImpl {
   TimerImpl(std::string &&name) : threadId(llvm::get_threadid()), name(name) {}
 
   /// Start the timer.
-  void start() { startTime = std::chrono::system_clock::now(); }
+  void start() { startTime = std::chrono::steady_clock::now(); }
 
   /// Stop the timer.
   void stop() {
-    auto newTime = std::chrono::system_clock::now() - startTime;
+    auto newTime = std::chrono::steady_clock::now() - startTime;
     wallTime += newTime;
     userTime += newTime;
   }
@@ -256,7 +256,7 @@ class TimerImpl {
   void mergeChildren(ChildrenMap &&other) {
     if (children.empty()) {
       children = std::move(other);
-      for (auto &child : other)
+      for (auto &child : children)
         child.second->mergeAsyncChildren();
     } else {
       for (auto &child : other)
@@ -384,7 +384,7 @@ class TimerImpl {
   }
 
   /// The last time instant at which the timer was started.
-  std::chrono::time_point<std::chrono::system_clock> startTime;
+  std::chrono::time_point<std::chrono::steady_clock> startTime;
 
   /// Accumulated wall time. If multiple threads of execution are merged into
   /// this timer, the wall time will hold the maximum wall time of each thread


        


More information about the Mlir-commits mailing list