[llvm] r343208 - [llvm-exegesis] Fix PR39096.

Clement Courbet via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 27 06:26:38 PDT 2018


Author: courbet
Date: Thu Sep 27 06:26:37 2018
New Revision: 343208

URL: http://llvm.org/viewvc/llvm-project?rev=343208&view=rev
Log:
[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

Added:
    llvm/trunk/test/tools/llvm-exegesis/X86/analysis-inconsistencies-uops-backwards.test
    llvm/trunk/test/tools/llvm-exegesis/X86/analysis-inconsistencies-uops.test
Modified:
    llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp

Added: llvm/trunk/test/tools/llvm-exegesis/X86/analysis-inconsistencies-uops-backwards.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-exegesis/X86/analysis-inconsistencies-uops-backwards.test?rev=343208&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-exegesis/X86/analysis-inconsistencies-uops-backwards.test (added)
+++ llvm/trunk/test/tools/llvm-exegesis/X86/analysis-inconsistencies-uops-backwards.test Thu Sep 27 06:26:37 2018
@@ -0,0 +1,28 @@
+# This tests backwards-compatibility of the yaml schema (see PR39082).
+# RUN: llvm-exegesis -mode=analysis -benchmarks-file=%s -analysis-inconsistencies-output-file=- -analysis-clusters-output-file="" -analysis-numpoints=1 | FileCheck %s
+
+# CHECK: DOCTYPE
+
+---
+mode:            uops
+key:
+  instructions:
+    - 'VZEROALL'
+  config:          ''
+  register_initial_values:
+cpu_name:        haswell
+llvm_triple:     x86_64-unknown-linux-gnu
+num_repetitions: 10000
+measurements:
+  - { key: '3', value: 0.0015, per_snippet_value: 0.0015 }
+  - { key: '4', value: 0.0011, per_snippet_value: 0.0011 }
+  - { key: '5', value: 0.0006, per_snippet_value: 0.0006 }
+  - { key: '6', value: 0.0004, per_snippet_value: 0.0004 }
+  - { key: '7', value: 0.0002, per_snippet_value: 0.0002 }
+  - { key: '8', value: 1.0008, per_snippet_value: 1.0008 }
+  - { key: '9', value: 1.0022, per_snippet_value: 1.0022 }
+  - { key: '10', value: 0.0001, per_snippet_value: 0.0001 }
+error:           ''
+info:            ''
+assembled_snippet: C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C3
+...

Added: llvm/trunk/test/tools/llvm-exegesis/X86/analysis-inconsistencies-uops.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-exegesis/X86/analysis-inconsistencies-uops.test?rev=343208&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-exegesis/X86/analysis-inconsistencies-uops.test (added)
+++ llvm/trunk/test/tools/llvm-exegesis/X86/analysis-inconsistencies-uops.test Thu Sep 27 06:26:37 2018
@@ -0,0 +1,28 @@
+# RUN: llvm-exegesis -mode=analysis -benchmarks-file=%s -analysis-inconsistencies-output-file=- -analysis-clusters-output-file="" -analysis-numpoints=1 | FileCheck %s
+
+# CHECK: DOCTYPE
+
+---
+mode:            uops
+key:
+  instructions:
+    - 'VZEROALL'
+  config:          ''
+  register_initial_values:
+cpu_name:        haswell
+llvm_triple:     x86_64-unknown-linux-gnu
+num_repetitions: 10000
+measurements:
+  - { key: HWPort0, value: 0.0015, per_snippet_value: 0.0015 }
+  - { key: HWPort1, value: 0.0011, per_snippet_value: 0.0011 }
+  - { key: HWPort2, value: 0.0006, per_snippet_value: 0.0006 }
+  - { key: HWPort3, value: 0.0004, per_snippet_value: 0.0004 }
+  - { key: HWPort4, value: 0.0002, per_snippet_value: 0.0002 }
+  - { key: HWPort5, value: 1.0008, per_snippet_value: 1.0008 }
+  - { key: HWPort6, value: 1.0022, per_snippet_value: 1.0022 }
+  - { key: HWPort7, value: 0.0001, per_snippet_value: 0.0001 }
+  - { key: NumMicroOps, value: 20.0073, per_snippet_value: 20.0073 }
+error:           ''
+info:            ''
+assembled_snippet: C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C3
+...

Modified: llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp?rev=343208&r1=343207&r2=343208&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp Thu Sep 27 06:26:37 2018
@@ -390,6 +390,22 @@ void Analysis::SchedClassCluster::addPoi
   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::measur
     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<uint16_t, float> &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<uint16_t, float> &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::measur
 void Analysis::printSchedClassDescHtml(const SchedClass &SC,
                                        llvm::raw_ostream &OS) const {
   OS << "<table class=\"sched-class-desc\">";
-  OS << "<tr><th>Valid</th><th>Variant</th><th>uOps</th><th>Latency</"
+  OS << "<tr><th>Valid</th><th>Variant</th><th>NumMicroOps</th><th>Latency</"
         "th><th>WriteProcRes</th><th title=\"This is the idealized unit "
         "resource (port) pressure assuming ideal distribution\">Idealized "
         "Resource Pressure</th></tr>";




More information about the llvm-commits mailing list