diff options
| author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-03-10 16:55:07 +0000 |
|---|---|---|
| committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-03-10 16:55:07 +0000 |
| commit | 0c54129907191f44780af22582da18ea4cf2a57e (patch) | |
| tree | aa3786495c4ea061c1a0db9c9a1a6efaf9d1c103 | |
| parent | 8224241f757c57fcb6696264ca3ae66a9e82de9a (diff) | |
| download | bcm5719-llvm-0c54129907191f44780af22582da18ea4cf2a57e.tar.gz bcm5719-llvm-0c54129907191f44780af22582da18ea4cf2a57e.zip | |
[llvm-mca] Views are now independent from resource masks. NFCI
This change removes method Backend::getProcResourceMasks() and simplifies some
logic in the Views. This effectively removes yet another dependency between the
views and the Backend.
No functional change intended.
llvm-svn: 327214
| -rw-r--r-- | llvm/tools/llvm-mca/Backend.h | 5 | ||||
| -rw-r--r-- | llvm/tools/llvm-mca/BackendStatistics.cpp | 3 | ||||
| -rw-r--r-- | llvm/tools/llvm-mca/ResourcePressureView.cpp | 7 | ||||
| -rw-r--r-- | llvm/tools/llvm-mca/ResourcePressureView.h | 7 | ||||
| -rw-r--r-- | llvm/tools/llvm-mca/Scheduler.cpp | 6 | ||||
| -rw-r--r-- | llvm/tools/llvm-mca/Scheduler.h | 19 | ||||
| -rw-r--r-- | llvm/tools/llvm-mca/llvm-mca.cpp | 3 |
7 files changed, 25 insertions, 25 deletions
diff --git a/llvm/tools/llvm-mca/Backend.h b/llvm/tools/llvm-mca/Backend.h index a000d169ca2..dadab2d24c6 100644 --- a/llvm/tools/llvm-mca/Backend.h +++ b/llvm/tools/llvm-mca/Backend.h @@ -70,7 +70,7 @@ public: this, MRI, Subtarget.getSchedModel().MicroOpBufferSize, RegisterFileSize, MaxRetirePerCycle, DispatchWidth, HWS.get())), SM(Source), Cycles(0) { - IB = llvm::make_unique<InstrBuilder>(MCII, getProcResourceMasks()); + IB = llvm::make_unique<InstrBuilder>(MCII, HWS->getProcResourceMasks()); } void run() { @@ -93,9 +93,6 @@ public: const llvm::MCSchedModel &getSchedModel() const { return STI.getSchedModel(); } - const llvm::ArrayRef<uint64_t> getProcResourceMasks() const { - return HWS->getProcResourceMasks(); - } double getRThroughput(const InstrDesc &ID) const { return HWS->getRThroughput(ID); diff --git a/llvm/tools/llvm-mca/BackendStatistics.cpp b/llvm/tools/llvm-mca/BackendStatistics.cpp index 358ce280886..46981d5fa61 100644 --- a/llvm/tools/llvm-mca/BackendStatistics.cpp +++ b/llvm/tools/llvm-mca/BackendStatistics.cpp @@ -121,14 +121,13 @@ void BackendStatistics::printSchedulerUsage( std::string Buffer; raw_string_ostream TempStream(Buffer); TempStream << "\n\nScheduler's queue usage:\n"; - const ArrayRef<uint64_t> ResourceMasks = B.getProcResourceMasks(); for (unsigned I = 0, E = SM.getNumProcResourceKinds(); I < E; ++I) { const MCProcResourceDesc &ProcResource = *SM.getProcResource(I); if (!ProcResource.BufferSize) continue; for (const BufferUsageEntry &Entry : Usage) - if (ResourceMasks[I] == Entry.first) + if (I == Entry.first) TempStream << ProcResource.Name << ", " << Entry.second << '/' << ProcResource.BufferSize << '\n'; } diff --git a/llvm/tools/llvm-mca/ResourcePressureView.cpp b/llvm/tools/llvm-mca/ResourcePressureView.cpp index 1dd15e0bbd0..1b9620f628c 100644 --- a/llvm/tools/llvm-mca/ResourcePressureView.cpp +++ b/llvm/tools/llvm-mca/ResourcePressureView.cpp @@ -19,8 +19,7 @@ namespace mca { using namespace llvm; -void ResourcePressureView::initialize( - const ArrayRef<uint64_t> ProcResourceMasks) { +void ResourcePressureView::initialize() { // Populate the map of resource descriptors. unsigned R2VIndex = 0; const MCSchedModel &SM = STI.getSchedModel(); @@ -31,9 +30,7 @@ void ResourcePressureView::initialize( if (ProcResource.SubUnitsIdxBegin || !NumUnits) continue; - uint64_t ResourceMask = ProcResourceMasks[I]; - Resource2VecIndex.insert( - std::pair<uint64_t, unsigned>(ResourceMask, R2VIndex)); + Resource2VecIndex.insert(std::pair<uint64_t, unsigned>(I, R2VIndex)); R2VIndex += ProcResource.NumUnits; } diff --git a/llvm/tools/llvm-mca/ResourcePressureView.h b/llvm/tools/llvm-mca/ResourcePressureView.h index 77c07be10dc..105aa408068 100644 --- a/llvm/tools/llvm-mca/ResourcePressureView.h +++ b/llvm/tools/llvm-mca/ResourcePressureView.h @@ -87,14 +87,13 @@ class ResourcePressureView : public View { unsigned Executions) const; void printResourcePressurePerInstruction(llvm::raw_ostream &OS, unsigned Executions) const; - void initialize(const llvm::ArrayRef<uint64_t> ProcResoureMasks); + void initialize(); public: ResourcePressureView(const llvm::MCSubtargetInfo &ST, - llvm::MCInstPrinter &Printer, const SourceMgr &SM, - const llvm::ArrayRef<uint64_t> ProcResourceMasks) + llvm::MCInstPrinter &Printer, const SourceMgr &SM) : STI(ST), MCIP(Printer), Source(SM) { - initialize(ProcResourceMasks); + initialize(); } void onInstructionIssued( diff --git a/llvm/tools/llvm-mca/Scheduler.cpp b/llvm/tools/llvm-mca/Scheduler.cpp index 6c0c44bd4d7..26e806d88c1 100644 --- a/llvm/tools/llvm-mca/Scheduler.cpp +++ b/llvm/tools/llvm-mca/Scheduler.cpp @@ -46,9 +46,10 @@ void ResourceState::dump() const { // ResourceDescriptor. Map 'Resources' allows to quickly obtain ResourceState // objects from resource mask identifiers. void ResourceManager::addResource(const MCProcResourceDesc &Desc, + unsigned Index, uint64_t Mask) { assert(Resources.find(Mask) == Resources.end() && "Resource already added!"); - Resources[Mask] = llvm::make_unique<ResourceState>(Desc, Mask); + Resources[Mask] = llvm::make_unique<ResourceState>(Desc, Index, Mask); } // Populate vector ProcResID2Mask with resource masks. One per each processor @@ -219,6 +220,9 @@ void ResourceManager::issueInstruction( ResourceRef Pipe = selectPipe(R.first); use(Pipe); BusyResources[Pipe] += CS.size(); + // Replace the resource mask with a valid processor resource index. + const ResourceState &RS = *Resources[Pipe.first]; + Pipe.first = RS.getProcResourceID(); Pipes.emplace_back(std::pair<ResourceRef, unsigned>(Pipe, CS.size())); } else { assert((countPopulation(R.first) > 1) && "Expected a group!"); diff --git a/llvm/tools/llvm-mca/Scheduler.h b/llvm/tools/llvm-mca/Scheduler.h index 2b58437404c..7bc28739746 100644 --- a/llvm/tools/llvm-mca/Scheduler.h +++ b/llvm/tools/llvm-mca/Scheduler.h @@ -56,6 +56,8 @@ enum ResourceStateEvent { /// Internally, ResourceState uses a round-robin selector to identify /// which unit of the group shall be used next. class ResourceState { + // Index to the MCProcResourceDesc in the processor Model. + unsigned ProcResourceDescIndex; // A resource unique identifier generated by the tool. // For processor resource groups, the number of number of bits set in this // mask is equivalent to the cardinality of the group plus one. @@ -181,8 +183,9 @@ class ResourceState { } public: - ResourceState(const llvm::MCProcResourceDesc &Desc, uint64_t Mask) - : ResourceMask(Mask) { + ResourceState(const llvm::MCProcResourceDesc &Desc, unsigned Index, + uint64_t Mask) + : ProcResourceDescIndex(Index), ResourceMask(Mask) { bool IsAGroup = llvm::countPopulation(ResourceMask) > 1; ResourceSizeMask = IsAGroup ? computeResourceSizeMaskForGroup(ResourceMask) : ((1ULL << Desc.NumUnits) - 1); @@ -195,6 +198,7 @@ public: Unavailable = false; } + unsigned getProcResourceID() const { return ProcResourceDescIndex; } uint64_t getResourceMask() const { return ResourceMask; } int getBufferSize() const { return BufferSize; } unsigned getMaxUsedSlots() const { return MaxUsedSlots; } @@ -274,9 +278,9 @@ public: /// 'second' index is an index for a "sub-resource" (i.e. unit). typedef std::pair<uint64_t, uint64_t> ResourceRef; -// First: a resource mask identifying a buffered resource. +// First: a MCProcResourceDesc index identifying a buffered resource. // Second: max number of buffer entries used in this resource. -typedef std::pair<uint64_t, unsigned> BufferUsageEntry; +typedef std::pair<unsigned, unsigned> BufferUsageEntry; /// A resource manager for processor resource units and groups. /// @@ -300,7 +304,8 @@ class ResourceManager { // Adds a new resource state in Resources, as well as a new descriptor in // ResourceDescriptor. - void addResource(const llvm::MCProcResourceDesc &Desc, uint64_t Mask); + void addResource(const llvm::MCProcResourceDesc &Desc, unsigned Index, + uint64_t Mask); // Compute processor resource masks for each processor resource declared by // the scheduling model. @@ -310,7 +315,7 @@ class ResourceManager { void initialize(const llvm::MCSchedModel &SM) { computeProcResourceMasks(SM); for (unsigned I = 0, E = SM.getNumProcResourceKinds(); I < E; ++I) - addResource(*SM.getProcResource(I), ProcResID2Mask[I]); + addResource(*SM.getProcResource(I), I, ProcResID2Mask[I]); } // Returns the actual resource unit that will be used. @@ -400,7 +405,7 @@ public: for (const std::pair<uint64_t, UniqueResourceState> &Resource : Resources) { const ResourceState &RS = *Resource.second; if (RS.isBuffered()) - Usage.emplace_back(std::pair<uint64_t, unsigned>(RS.getResourceMask(), + Usage.emplace_back(std::pair<unsigned, unsigned>(RS.getProcResourceID(), RS.getMaxUsedSlots())); } } diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp index 6e14f0b0caa..9492e2d763e 100644 --- a/llvm/tools/llvm-mca/llvm-mca.cpp +++ b/llvm/tools/llvm-mca/llvm-mca.cpp @@ -335,8 +335,7 @@ int main(int argc, char **argv) { } std::unique_ptr<mca::ResourcePressureView> RPV = - llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, *S, - B->getProcResourceMasks()); + llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, *S); Printer->addView(std::move(RPV)); if (PrintTimelineView) { |

