From 91ab2ee9542c398ac5b2a322a72f2803202bd9e2 Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Mon, 19 Mar 2018 13:23:07 +0000 Subject: [llvm-mca] Add pipeline stall events. This patch introduces a new class named HWStallEvent (see HWEventListener.h), and updates the event listener interface. A HWStallEvent represents a pipeline stall caused by the lack of hardware resources. Similarly to HWInstructionEvent, the event type is an unsigned, and the exact meaning depends on the subtarget. At the moment, HWStallEvent supports a few generic dispatch events. The main goals of this patch is to remove the logic that counts dispatch stalls from the DispatchUnit to the BackendStatistics view. Previously, DispatchUnit was responsible for counting and classifying dispatch stall events. With this patch, we delegate the task of counting and classifying stall events to the listeners (i.e. in our case, it is view "BackendStatistics"). So, the DispatchUnit doesn't have to do extra (unnecessary) bookkeeping. This patch also helps futher simplifying the Backend interface. Now class BackendStatistics no longer has to query the Backend interface to obtain the number of dispatch stalls. As a consequence, we can get rid of all the 'getNumXXX()' methods from class Backend. The long term goal is to remove all the remaining dependencies between the Backend and the BackendStatistics interface. Differential Revision: https://reviews.llvm.org/D44621 llvm-svn: 327837 --- llvm/tools/llvm-mca/Backend.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'llvm/tools/llvm-mca/Backend.cpp') diff --git a/llvm/tools/llvm-mca/Backend.cpp b/llvm/tools/llvm-mca/Backend.cpp index 46c7a735e9e..a45fd342aef 100644 --- a/llvm/tools/llvm-mca/Backend.cpp +++ b/llvm/tools/llvm-mca/Backend.cpp @@ -36,7 +36,8 @@ void Backend::runCycle(unsigned Cycle) { std::unique_ptr NewIS( IB->createInstruction(STI, IR.first, *IR.second)); const InstrDesc &Desc = NewIS->getDesc(); - if (!DU->isAvailable(Desc.NumMicroOps) || !DU->canDispatch(*NewIS)) + if (!DU->isAvailable(Desc.NumMicroOps) || + !DU->canDispatch(IR.first, *NewIS)) break; Instruction *IS = NewIS.get(); @@ -62,6 +63,11 @@ void Backend::notifyInstructionEvent(const HWInstructionEvent &Event) { Listener->onInstructionEvent(Event); } +void Backend::notifyStallEvent(const HWStallEvent &Event) { + for (HWEventListener *Listener : Listeners) + Listener->onStallEvent(Event); +} + void Backend::notifyResourceAvailable(const ResourceRef &RR) { DEBUG(dbgs() << "[E] Resource Available: [" << RR.first << '.' << RR.second << "]\n"); -- cgit v1.2.3