diff options
author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-03-20 18:20:39 +0000 |
---|---|---|
committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-03-20 18:20:39 +0000 |
commit | a3f2e483dda162cb5cd284c87bc09d72812b4dd4 (patch) | |
tree | d517050ae860bf612c4642f5d3105cfe396b3538 /llvm/tools/llvm-mca/Scheduler.h | |
parent | 7baac21bce17ece1f4ca7e68a0bc2fb19dd6c99a (diff) | |
download | bcm5719-llvm-a3f2e483dda162cb5cd284c87bc09d72812b4dd4.tar.gz bcm5719-llvm-a3f2e483dda162cb5cd284c87bc09d72812b4dd4.zip |
[llvm-mca] Move the logic that computes the scheduler's queue usage to the BackendStatistics view.
This patch introduces two new callbacks in the event listener interface to
handle the "buffered resource reserved" event and the "buffered resource
released" event. Every time a buffered resource is used, an event is generated.
Before this patch, the Scheduler (with the help of the ResourceManager) was
responsible for tracking the scheduler's queue usage. However, that design
forced the Scheduler to 'publish' scheduler's queue pressure information through
the Backend interface.
The goal of this patch is to break the dependency between the BackendStatistics
view, and the Backend. Now the Scheduler knows how to notify "buffer
reserved/released" events. The scheduler's queue usage analysis has been moved
to the BackendStatistics.
Differential Revision: https://reviews.llvm.org/D44686
llvm-svn: 328011
Diffstat (limited to 'llvm/tools/llvm-mca/Scheduler.h')
-rw-r--r-- | llvm/tools/llvm-mca/Scheduler.h | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/llvm/tools/llvm-mca/Scheduler.h b/llvm/tools/llvm-mca/Scheduler.h index c74d3f1e196..93c5295e8d5 100644 --- a/llvm/tools/llvm-mca/Scheduler.h +++ b/llvm/tools/llvm-mca/Scheduler.h @@ -138,11 +138,6 @@ class ResourceState { // Available slots in the buffer (zero, if this is not a buffered resource). unsigned AvailableSlots; - // Maximum number of buffer slots seen used during one cycle. - // This helps tracking dynamic dispatch stalls caused by the lack of - // entries in the scheduler's queue. - unsigned MaxUsedSlots; - // True if this is resource is currently unavailable. // An instruction may "reserve" a resource for a number of cycles. // During those cycles, the reserved resource cannot be used for other @@ -182,14 +177,12 @@ public: ReadyMask = ResourceSizeMask; BufferSize = Desc.BufferSize; AvailableSlots = BufferSize == -1 ? 0U : static_cast<unsigned>(BufferSize); - MaxUsedSlots = 0; Unavailable = false; } unsigned getProcResourceID() const { return ProcResourceDescIndex; } uint64_t getResourceMask() const { return ResourceMask; } int getBufferSize() const { return BufferSize; } - unsigned getMaxUsedSlots() const { return MaxUsedSlots; } bool isBuffered() const { return BufferSize > 0; } bool isInOrder() const { return BufferSize == 1; } @@ -244,8 +237,6 @@ public: void reserveBuffer() { if (AvailableSlots) AvailableSlots--; - unsigned UsedSlots = static_cast<unsigned>(BufferSize) - AvailableSlots; - MaxUsedSlots = std::max(MaxUsedSlots, UsedSlots); } void releaseBuffer() { @@ -339,8 +330,12 @@ public: // Returns RS_BUFFER_AVAILABLE if buffered resources are not reserved, and if // there are enough available slots in the buffers. - ResourceStateEvent - canBeDispatched(const llvm::ArrayRef<uint64_t> Buffers) const; + ResourceStateEvent canBeDispatched(llvm::ArrayRef<uint64_t> Buffers) const; + + // Return the processor resource identifier associated to this Mask. + unsigned resolveResourceMask(uint64_t Mask) const { + return Resources.find(Mask)->second->getProcResourceID(); + } // Consume a slot in every buffered resource from array 'Buffers'. Resource // units that are dispatch hazards (i.e. BufferSize=0) are marked as reserved. @@ -372,15 +367,6 @@ public: void cycleEvent(llvm::SmallVectorImpl<ResourceRef> &ResourcesFreed); - void getBuffersUsage(std::vector<BufferUsageEntry> &Usage) const { - for (const std::pair<uint64_t, UniqueResourceState> &Resource : Resources) { - const ResourceState &RS = *Resource.second; - if (RS.isBuffered()) - Usage.emplace_back(std::pair<unsigned, unsigned>(RS.getProcResourceID(), - RS.getMaxUsedSlots())); - } - } - #ifndef NDEBUG void dump() const { for (const std::pair<uint64_t, UniqueResourceState> &Resource : Resources) @@ -439,6 +425,11 @@ class Scheduler { void notifyInstructionReady(unsigned Index); void notifyResourceAvailable(const ResourceRef &RR); + // Notify the Backend that buffered resources were consumed. + void notifyReservedBuffers(llvm::ArrayRef<uint64_t> Buffers); + // Notify the Backend that buffered resources were freed. + void notifyReleasedBuffers(llvm::ArrayRef<uint64_t> Buffers); + /// Issue instructions from the ready queue by giving priority to older /// instructions. void issue(); @@ -498,10 +489,6 @@ public: void cycleEvent(unsigned Cycle); - void getBuffersUsage(std::vector<BufferUsageEntry> &Usage) const { - Resources->getBuffersUsage(Usage); - } - #ifndef NDEBUG void dump() const; #endif |