diff options
Diffstat (limited to 'llvm/tools/llvm-mca/lib')
4 files changed, 16 insertions, 15 deletions
diff --git a/llvm/tools/llvm-mca/lib/HardwareUnits/ResourceManager.cpp b/llvm/tools/llvm-mca/lib/HardwareUnits/ResourceManager.cpp index 18d0e74a774..b3dcfa7b498 100644 --- a/llvm/tools/llvm-mca/lib/HardwareUnits/ResourceManager.cpp +++ b/llvm/tools/llvm-mca/lib/HardwareUnits/ResourceManager.cpp @@ -247,7 +247,7 @@ bool ResourceManager::mustIssueImmediately(const InstrDesc &Desc) const { void ResourceManager::issueInstruction( const InstrDesc &Desc, - SmallVectorImpl<std::pair<ResourceRef, double>> &Pipes) { + SmallVectorImpl<std::pair<ResourceRef, ResourceCycles>> &Pipes) { for (const std::pair<uint64_t, ResourceUsage> &R : Desc.Resources) { const CycleSegment &CS = R.second.CS; if (!CS.size()) { @@ -263,8 +263,8 @@ void ResourceManager::issueInstruction( // Replace the resource mask with a valid processor resource index. const ResourceState &RS = *Resources[getResourceStateIndex(Pipe.first)]; Pipe.first = RS.getProcResourceID(); - Pipes.emplace_back( - std::pair<ResourceRef, double>(Pipe, static_cast<double>(CS.size()))); + Pipes.emplace_back(std::pair<ResourceRef, ResourceCycles>( + Pipe, ResourceCycles(CS.size()))); } else { assert((countPopulation(R.first) > 1) && "Expected a group!"); // Mark this group as reserved. diff --git a/llvm/tools/llvm-mca/lib/HardwareUnits/Scheduler.cpp b/llvm/tools/llvm-mca/lib/HardwareUnits/Scheduler.cpp index 151af2333f6..8bfa761c8a1 100644 --- a/llvm/tools/llvm-mca/lib/HardwareUnits/Scheduler.cpp +++ b/llvm/tools/llvm-mca/lib/HardwareUnits/Scheduler.cpp @@ -66,7 +66,7 @@ Scheduler::Status Scheduler::isAvailable(const InstRef &IR) const { void Scheduler::issueInstructionImpl( InstRef &IR, - SmallVectorImpl<std::pair<ResourceRef, double>> &UsedResources) { + SmallVectorImpl<std::pair<ResourceRef, ResourceCycles>> &UsedResources) { Instruction *IS = IR.getInstruction(); const InstrDesc &D = IS->getDesc(); @@ -86,7 +86,8 @@ void Scheduler::issueInstructionImpl( // Release the buffered resources and issue the instruction. void Scheduler::issueInstruction( - InstRef &IR, SmallVectorImpl<std::pair<ResourceRef, double>> &UsedResources, + InstRef &IR, + SmallVectorImpl<std::pair<ResourceRef, ResourceCycles>> &UsedResources, SmallVectorImpl<InstRef> &ReadyInstructions) { const Instruction &Inst = *IR.getInstruction(); bool HasDependentUsers = Inst.hasDependentUsers(); diff --git a/llvm/tools/llvm-mca/lib/Stages/ExecuteStage.cpp b/llvm/tools/llvm-mca/lib/Stages/ExecuteStage.cpp index 3f040bc2064..d280e63cdc6 100644 --- a/llvm/tools/llvm-mca/lib/Stages/ExecuteStage.cpp +++ b/llvm/tools/llvm-mca/lib/Stages/ExecuteStage.cpp @@ -53,11 +53,11 @@ bool ExecuteStage::isAvailable(const InstRef &IR) const { } Error ExecuteStage::issueInstruction(InstRef &IR) { - SmallVector<std::pair<ResourceRef, double>, 4> Used; + SmallVector<std::pair<ResourceRef, ResourceCycles>, 4> Used; SmallVector<InstRef, 4> Ready; HWS.issueInstruction(IR, Used, Ready); - notifyReservedOrReleasedBuffers(IR, /* Reserved */false); + notifyReservedOrReleasedBuffers(IR, /* Reserved */ false); notifyInstructionIssued(IR, Used); if (IR.getInstruction()->isExecuted()) { notifyInstructionExecuted(IR); @@ -120,7 +120,7 @@ Error ExecuteStage::execute(InstRef &IR) { // be released after MCIS is issued, and all the ResourceCycles for those // units have been consumed. HWS.dispatch(IR); - notifyReservedOrReleasedBuffers(IR, /* Reserved */true); + notifyReservedOrReleasedBuffers(IR, /* Reserved */ true); if (!HWS.isReady(IR)) return ErrorSuccess(); @@ -156,10 +156,10 @@ void ExecuteStage::notifyResourceAvailable(const ResourceRef &RR) { } void ExecuteStage::notifyInstructionIssued( - const InstRef &IR, ArrayRef<std::pair<ResourceRef, double>> Used) { + const InstRef &IR, ArrayRef<std::pair<ResourceRef, ResourceCycles>> Used) { LLVM_DEBUG({ dbgs() << "[E] Instruction Issued: #" << IR << '\n'; - for (const std::pair<ResourceRef, unsigned> &Resource : Used) { + for (const std::pair<ResourceRef, ResourceCycles> &Resource : Used) { dbgs() << "[E] Resource Used: [" << Resource.first.first << '.' << Resource.first.second << "], "; dbgs() << "cycles: " << Resource.second << '\n'; diff --git a/llvm/tools/llvm-mca/lib/Stages/InstructionTables.cpp b/llvm/tools/llvm-mca/lib/Stages/InstructionTables.cpp index 1fdeefa2350..e49eb446062 100644 --- a/llvm/tools/llvm-mca/lib/Stages/InstructionTables.cpp +++ b/llvm/tools/llvm-mca/lib/Stages/InstructionTables.cpp @@ -31,17 +31,17 @@ Error InstructionTables::execute(InstRef &IR) { // Skip zero-cycle resources (i.e., unused resources). if (!Resource.second.size()) continue; - double Cycles = static_cast<double>(Resource.second.size()); + unsigned Cycles = Resource.second.size(); unsigned Index = std::distance( Masks.begin(), std::find(Masks.begin(), Masks.end(), Resource.first)); const MCProcResourceDesc &ProcResource = *SM.getProcResource(Index); unsigned NumUnits = ProcResource.NumUnits; if (!ProcResource.SubUnitsIdxBegin) { // The number of cycles consumed by each unit. - Cycles /= NumUnits; for (unsigned I = 0, E = NumUnits; I < E; ++I) { ResourceRef ResourceUnit = std::make_pair(Index, 1U << I); - UsedResources.emplace_back(std::make_pair(ResourceUnit, Cycles)); + UsedResources.emplace_back( + std::make_pair(ResourceUnit, ResourceCycles(Cycles, NumUnits))); } continue; } @@ -53,10 +53,10 @@ Error InstructionTables::execute(InstRef &IR) { unsigned SubUnitIdx = ProcResource.SubUnitsIdxBegin[I1]; const MCProcResourceDesc &SubUnit = *SM.getProcResource(SubUnitIdx); // Compute the number of cycles consumed by each resource unit. - double RUCycles = Cycles / (NumUnits * SubUnit.NumUnits); for (unsigned I2 = 0, E2 = SubUnit.NumUnits; I2 < E2; ++I2) { ResourceRef ResourceUnit = std::make_pair(SubUnitIdx, 1U << I2); - UsedResources.emplace_back(std::make_pair(ResourceUnit, RUCycles)); + UsedResources.emplace_back(std::make_pair( + ResourceUnit, ResourceCycles(Cycles, NumUnits * SubUnit.NumUnits))); } } } |