From 30183093abf2b7d563c1c233a89aa3e115e4109c Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Thu, 27 Sep 2018 13:26:37 +0000 Subject: [llvm-exegesis] Fix PR39096. Summary: The key is now the resource name, not the resource id. Reviewers: gchatelet Subscribers: tschuett, RKSimon, llvm-commits Differential Revision: https://reviews.llvm.org/D52607 llvm-svn: 343208 --- llvm/tools/llvm-exegesis/lib/Analysis.cpp | 53 +++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 16 deletions(-) (limited to 'llvm/tools/llvm-exegesis/lib/Analysis.cpp') diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp index 805bd52daf1..d852f24be33 100644 --- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp +++ b/llvm/tools/llvm-exegesis/lib/Analysis.cpp @@ -390,6 +390,22 @@ void Analysis::SchedClassCluster::addPoint( assert(ClusterId == Clustering.getClusterIdForPoint(PointId)); } +// Returns a ProxResIdx by id or name. +static unsigned findProcResIdx(const llvm::MCSubtargetInfo &STI, + const llvm::StringRef NameOrId) { + // Interpret the key as an ProcResIdx. + unsigned ProcResIdx = 0; + if (llvm::to_integer(NameOrId, ProcResIdx, 10)) + return ProcResIdx; + // Interpret the key as a ProcRes name. + const auto &SchedModel = STI.getSchedModel(); + for (int I = 0, E = SchedModel.getNumProcResourceKinds(); I < E; ++I) { + if (NameOrId == SchedModel.getProcResource(I)->Name) + return I; + } + return 0; +} + bool Analysis::SchedClassCluster::measurementsMatch( const llvm::MCSubtargetInfo &STI, const SchedClass &SC, const InstructionBenchmarkClustering &Clustering) const { @@ -417,23 +433,28 @@ bool Analysis::SchedClassCluster::measurementsMatch( ClusterCenterPoint[0].PerInstructionValue = Representative[0].avg(); } else if (Mode == InstructionBenchmark::Uops) { for (int I = 0, E = Representative.size(); I < E; ++I) { - // Find the pressure on ProcResIdx `Key`. - uint16_t ProcResIdx = 0; - if (!llvm::to_integer(Representative[I].key(), ProcResIdx, 10)) { - llvm::errs() << "expected ProcResIdx key, got " - << Representative[I].key() << "\n"; + const auto Key = Representative[I].key(); + uint16_t ProcResIdx = findProcResIdx(STI, Key); + if (ProcResIdx > 0) { + // Find the pressure on ProcResIdx `Key`. + const auto ProcResPressureIt = + std::find_if(SC.IdealizedProcResPressure.begin(), + SC.IdealizedProcResPressure.end(), + [ProcResIdx](const std::pair &WPR) { + return WPR.first == ProcResIdx; + }); + SchedClassPoint[I].PerInstructionValue = + ProcResPressureIt == SC.IdealizedProcResPressure.end() + ? 0.0 + : ProcResPressureIt->second; + } else if (Key == "NumMicroOps") { + SchedClassPoint[I].PerInstructionValue = SC.SCDesc->NumMicroOps; + } else { + llvm::errs() << "expected `key` to be either a ProcResIdx or a ProcRes " + "name, got " + << Key << "\n"; return false; } - const auto ProcResPressureIt = - std::find_if(SC.IdealizedProcResPressure.begin(), - SC.IdealizedProcResPressure.end(), - [ProcResIdx](const std::pair &WPR) { - return WPR.first == ProcResIdx; - }); - SchedClassPoint[I].PerInstructionValue = - ProcResPressureIt == SC.IdealizedProcResPressure.end() - ? 0.0 - : ProcResPressureIt->second; ClusterCenterPoint[I].PerInstructionValue = Representative[I].avg(); } } else { @@ -447,7 +468,7 @@ bool Analysis::SchedClassCluster::measurementsMatch( void Analysis::printSchedClassDescHtml(const SchedClass &SC, llvm::raw_ostream &OS) const { OS << ""; - OS << ""; -- cgit v1.2.3
ValidVariantuOpsLatencyValidVariantNumMicroOpsLatencyWriteProcResIdealized " "Resource Pressure