OSDN Git Service

[llvm-mca] Return the total number of cycles from method Pipeline::run().
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Wed, 28 Nov 2018 16:24:51 +0000 (16:24 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Wed, 28 Nov 2018 16:24:51 +0000 (16:24 +0000)
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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347767 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-mca/include/Pipeline.h
tools/llvm-mca/lib/Pipeline.cpp
tools/llvm-mca/llvm-mca.cpp

index 47ff07b..0fd4026 100644 (file)
@@ -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
index 309f415..0f91060 100644 (file)
@@ -35,7 +35,7 @@ bool Pipeline::hasWorkToProcess() {
   });
 }
 
-Error Pipeline::run() {
+Expected<unsigned> Pipeline::run() {
   assert(!Stages.empty() && "Unexpected empty pipeline found!");
 
   do {
@@ -46,7 +46,7 @@ Error Pipeline::run() {
     ++Cycles;
   } while (hasWorkToProcess());
 
-  return ErrorSuccess();
+  return Cycles;
 }
 
 Error Pipeline::runCycle() {
index 8b792be..9858896 100644 (file)
@@ -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;