[llvm] r347795 - Reapply "[llvm-mca] Return the total number of cycles from method Pipeline::run()."

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 28 11:31:19 PST 2018


Author: adibiagio
Date: Wed Nov 28 11:31:19 2018
New Revision: 347795

URL: http://llvm.org/viewvc/llvm-project?rev=347795&view=rev
Log:
Reapply "[llvm-mca] Return the total number of cycles from method Pipeline::run()."

This reapplies r347767 (originally reviewed at: https://reviews.llvm.org/D55000)
with a fix for the missing std::move of the Error returned by the call to
Pipeline::runCycle().

Below is the original commit message from r347767.

If a user only cares about the overall latency, then the best/quickest way is to
change method Pipeline::run() so that it returns the total number of cycles to
the caller.

When the simulation pipeline is run, the number of cycles (or an error) is
returned from method Pipeline::run().
The advantage is that no hardware event listener is needed for computing that
latency. So, the whole process should be faster (and simpler - at least for that
particular use case).

Modified:
    llvm/trunk/tools/llvm-mca/include/Pipeline.h
    llvm/trunk/tools/llvm-mca/lib/Pipeline.cpp
    llvm/trunk/tools/llvm-mca/llvm-mca.cpp

Modified: llvm/trunk/tools/llvm-mca/include/Pipeline.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/include/Pipeline.h?rev=347795&r1=347794&r2=347795&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/include/Pipeline.h (original)
+++ llvm/trunk/tools/llvm-mca/include/Pipeline.h Wed Nov 28 11:31:19 2018
@@ -67,7 +67,10 @@ class Pipeline {
 public:
   Pipeline() : Cycles(0) {}
   void appendStage(std::unique_ptr<Stage> S);
-  Error run();
+
+  /// Returns the total number of simulated cycles.
+  Expected<unsigned> run();
+
   void addEventListener(HWEventListener *Listener);
 };
 } // namespace mca

Modified: llvm/trunk/tools/llvm-mca/lib/Pipeline.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/lib/Pipeline.cpp?rev=347795&r1=347794&r2=347795&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/lib/Pipeline.cpp (original)
+++ llvm/trunk/tools/llvm-mca/lib/Pipeline.cpp Wed Nov 28 11:31:19 2018
@@ -35,18 +35,18 @@ bool Pipeline::hasWorkToProcess() {
   });
 }
 
-Error Pipeline::run() {
+Expected<unsigned> Pipeline::run() {
   assert(!Stages.empty() && "Unexpected empty pipeline found!");
 
   do {
     notifyCycleBegin();
     if (Error Err = runCycle())
-      return Err;
+      return std::move(Err);
     notifyCycleEnd();
     ++Cycles;
   } while (hasWorkToProcess());
 
-  return ErrorSuccess();
+  return Cycles;
 }
 
 Error Pipeline::runCycle() {

Modified: llvm/trunk/tools/llvm-mca/llvm-mca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/llvm-mca.cpp?rev=347795&r1=347794&r2=347795&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/llvm-mca.cpp (original)
+++ llvm/trunk/tools/llvm-mca/llvm-mca.cpp Wed Nov 28 11:31:19 2018
@@ -240,8 +240,9 @@ static void processViewOptions() {
 // Returns true on success.
 static bool runPipeline(mca::Pipeline &P) {
   // Handle pipeline errors here.
-  if (auto Err = P.run()) {
-    WithColor::error() << toString(std::move(Err));
+  Expected<unsigned> Cycles = P.run();
+  if (!Cycles) {
+    WithColor::error() << toString(Cycles.takeError());
     return false;
   }
   return true;




More information about the llvm-commits mailing list