llvm.org GIT mirror llvm / 3d1a12c
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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347795 91177308-0d34-0410-b5e6-96231b3b80d8 Andrea Di Biagio 9 months ago
3 changed file(s) with 10 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
6666 public:
6767 Pipeline() : Cycles(0) {}
6868 void appendStage(std::unique_ptr S);
69 Error run();
69
70 /// Returns the total number of simulated cycles.
71 Expected run();
72
7073 void addEventListener(HWEventListener *Listener);
7174 };
7275 } // namespace mca
3434 });
3535 }
3636
37 Error Pipeline::run() {
37 Expected Pipeline::run() {
3838 assert(!Stages.empty() && "Unexpected empty pipeline found!");
3939
4040 do {
4141 notifyCycleBegin();
4242 if (Error Err = runCycle())
43 return Err;
43 return std::move(Err);
4444 notifyCycleEnd();
4545 ++Cycles;
4646 } while (hasWorkToProcess());
4747
48 return ErrorSuccess();
48 return Cycles;
4949 }
5050
5151 Error Pipeline::runCycle() {
239239 // Returns true on success.
240240 static bool runPipeline(mca::Pipeline &P) {
241241 // Handle pipeline errors here.
242 if (auto Err = P.run()) {
243 WithColor::error() << toString(std::move(Err));
242 Expected Cycles = P.run();
243 if (!Cycles) {
244 WithColor::error() << toString(Cycles.takeError());
244245 return false;
245246 }
246247 return true;