[llvm] r343108 - [llvm-exegesis] Get rid of debug_string.

Clement Courbet via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 26 06:35:11 PDT 2018


Author: courbet
Date: Wed Sep 26 06:35:10 2018
New Revision: 343108

URL: http://llvm.org/viewvc/llvm-project?rev=343108&view=rev
Log:
[llvm-exegesis] Get rid of debug_string.

Summary:
THis is a backwards-compatible change (existing files will work as
expected).

See PR39082.

Reviewers: gchatelet

Subscribers: tschuett, llvm-commits

Differential Revision: https://reviews.llvm.org/D52546

Added:
    llvm/trunk/test/tools/llvm-exegesis/X86/analysis-uops-backwards.test
    llvm/trunk/test/tools/llvm-exegesis/X86/analysis-uops.test
Modified:
    llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp
    llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
    llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h
    llvm/trunk/unittests/tools/llvm-exegesis/ClusteringTest.cpp
    llvm/trunk/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp

Added: llvm/trunk/test/tools/llvm-exegesis/X86/analysis-uops-backwards.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-exegesis/X86/analysis-uops-backwards.test?rev=343108&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-exegesis/X86/analysis-uops-backwards.test (added)
+++ llvm/trunk/test/tools/llvm-exegesis/X86/analysis-uops-backwards.test Wed Sep 26 06:35:10 2018
@@ -0,0 +1,30 @@
+# This tests backwards-compatibility of the yaml schema (see PR39082).
+# RUN: llvm-exegesis -mode=analysis -benchmarks-file=%s -analysis-inconsistencies-output-file="" -analysis-numpoints=1 | FileCheck %s
+
+# CHECK: cluster_id,opcode_name,config,sched_class,HWPort0,HWPort1,HWPort2,HWPort3,HWPort4,HWPort5,HWPort6,HWPort7,NumMicroOps
+# CHECK-NEXT: vzeroall
+
+---
+mode:            uops
+key:
+  instructions:
+    - 'VZEROALL'
+  config:          ''
+  register_initial_values:
+cpu_name:        haswell
+llvm_triple:     x86_64-unknown-linux-gnu
+num_repetitions: 10000
+measurements:
+  - { debug_string: HWPort0, value: 0.0015, per_snippet_value: 0.0015, key: '0' }
+  - { debug_string: HWPort1, value: 0.0011, per_snippet_value: 0.0011, key: '1' }
+  - { debug_string: HWPort2, value: 0.0006, per_snippet_value: 0.0006, key: '2' }
+  - { debug_string: HWPort3, value: 0.0004, per_snippet_value: 0.0004, key: '3' }
+  - { debug_string: HWPort4, value: 0.0002, per_snippet_value: 0.0002, key: '4' }
+  - { debug_string: HWPort5, value: 1.0008, per_snippet_value: 1.0008, key: '5' }
+  - { debug_string: HWPort6, value: 1.0022, per_snippet_value: 1.0022, key: '6' }
+  - { debug_string: HWPort7, value: 0.0001, per_snippet_value: 0.0001, key: '7' }
+  - { debug_string: NumMicroOps, value: 20.0073, per_snippet_value: 20.0073, key: '8' }
+error:           ''
+info:            ''
+assembled_snippet: C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C3
+...

Added: llvm/trunk/test/tools/llvm-exegesis/X86/analysis-uops.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-exegesis/X86/analysis-uops.test?rev=343108&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-exegesis/X86/analysis-uops.test (added)
+++ llvm/trunk/test/tools/llvm-exegesis/X86/analysis-uops.test Wed Sep 26 06:35:10 2018
@@ -0,0 +1,29 @@
+# RUN: llvm-exegesis -mode=analysis -benchmarks-file=%s -analysis-inconsistencies-output-file="" -analysis-numpoints=1 | FileCheck %s
+
+# CHECK: cluster_id,opcode_name,config,sched_class,HWPort0,HWPort1,HWPort2,HWPort3,HWPort4,HWPort5,HWPort6,HWPort7,NumMicroOps
+# CHECK-NEXT: vzeroall
+
+---
+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=343108&r1=343107&r2=343108&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/Analysis.cpp Wed Sep 26 06:35:10 2018
@@ -248,10 +248,7 @@ void Analysis::printSchedClassClustersHt
   for (const auto &Measurement :
        Points[Clusters[0].getPointIds()[0]].Measurements) {
     OS << "<th>";
-    if (Measurement.DebugString.empty())
-      writeEscaped<kEscapeHtml>(OS, Measurement.Key);
-    else
-      writeEscaped<kEscapeHtml>(OS, Measurement.DebugString);
+    writeEscaped<kEscapeHtml>(OS, Measurement.Key);
     OS << "</th>";
   }
   OS << "</tr>";

Modified: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp?rev=343108&r1=343107&r2=343108&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp Wed Sep 26 06:35:10 2018
@@ -164,10 +164,13 @@ template <> struct SequenceElementTraits
 // e.g. { "key": "the key", "value": 0123 }
 template <> struct MappingTraits<exegesis::BenchmarkMeasure> {
   static void mapping(IO &Io, exegesis::BenchmarkMeasure &Obj) {
-    Io.mapOptional("debug_string", Obj.DebugString);
+    Io.mapRequired("key", Obj.Key);
+    if (!Io.outputting()) {
+      // For backward compatibility, interpret debug_string as a key.
+      Io.mapOptional("debug_string", Obj.Key);
+    }
     Io.mapRequired("value", Obj.PerInstructionValue);
     Io.mapOptional("per_snippet_value", Obj.PerSnippetValue);
-    Io.mapRequired("key", Obj.Key);
   }
   static const bool flow = true;
 };

Modified: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h?rev=343108&r1=343107&r2=343108&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h Wed Sep 26 06:35:10 2018
@@ -43,7 +43,7 @@ struct InstructionBenchmarkKey {
 struct BenchmarkMeasure {
   // A helper to create an unscaled BenchmarkMeasure.
   static BenchmarkMeasure Create(std::string Key, double Value) {
-    return {Key, Value, Value, Key};
+    return {Key, Value, Value};
   }
   std::string Key;
   // This is the per-instruction value, i.e. measured quantity scaled per
@@ -52,8 +52,6 @@ struct BenchmarkMeasure {
   // This is the per-snippet value, i.e. measured quantity for one repetition of
   // the whole snippet.
   double PerSnippetValue;
-  // FIXME: remove, use `Key` instead.
-  std::string DebugString;
 };
 
 // The result of an instruction benchmark.

Modified: llvm/trunk/unittests/tools/llvm-exegesis/ClusteringTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/tools/llvm-exegesis/ClusteringTest.cpp?rev=343108&r1=343107&r2=343108&view=diff
==============================================================================
--- llvm/trunk/unittests/tools/llvm-exegesis/ClusteringTest.cpp (original)
+++ llvm/trunk/unittests/tools/llvm-exegesis/ClusteringTest.cpp Wed Sep 26 06:35:10 2018
@@ -27,17 +27,17 @@ TEST(ClusteringTest, Clusters3D) {
 
   // Cluster around (x=0, y=1, z=2): points {0, 3}.
   Points[0].Measurements = {
-      {"x", 0.01, 0.0, ""}, {"y", 1.02, 0.0, ""}, {"z", 1.98, 0.0, "A"}};
+      {"x", 0.01, 0.0}, {"y", 1.02, 0.0}, {"z", 1.98, 0.0}};
   Points[3].Measurements = {
-      {"x", -0.01, 0.0, ""}, {"y", 1.02, 0.0, ""}, {"z", 1.98, 0.0, ""}};
+      {"x", -0.01, 0.0}, {"y", 1.02, 0.0}, {"z", 1.98, 0.0}};
   // Cluster around (x=1, y=1, z=2): points {1, 4}.
   Points[1].Measurements = {
-      {"x", 1.01, 0.0, ""}, {"y", 1.02, 0.0, ""}, {"z", 1.98, 0.0, ""}};
+      {"x", 1.01, 0.0}, {"y", 1.02, 0.0}, {"z", 1.98, 0.0}};
   Points[4].Measurements = {
-      {"x", 0.99, 0.0, ""}, {"y", 1.02, 0.0, ""}, {"z", 1.98, 0.0, ""}};
+      {"x", 0.99, 0.0}, {"y", 1.02, 0.0}, {"z", 1.98, 0.0}};
   // Cluster around (x=0, y=0, z=0): points {5}, marked as noise.
   Points[5].Measurements = {
-      {"x", 0.0, 0.0, ""}, {"y", 0.01, 0.0, ""}, {"z", -0.02, 0.0, ""}};
+      {"x", 0.0, 0.0}, {"y", 0.01, 0.0}, {"z", -0.02, 0.0}};
   // Error cluster: points {2}
   Points[2].Error = "oops";
 
@@ -70,8 +70,8 @@ TEST(ClusteringTest, Clusters3D) {
 TEST(ClusteringTest, Clusters3D_InvalidSize) {
   std::vector<InstructionBenchmark> Points(6);
   Points[0].Measurements = {
-      {"x", 0.01, 0.0, ""}, {"y", 1.02, 0.0, ""}, {"z", 1.98, 0.0, ""}};
-  Points[1].Measurements = {{"y", 1.02, 0.0, ""}, {"z", 1.98, 0.0, ""}};
+      {"x", 0.01, 0.0}, {"y", 1.02, 0.0}, {"z", 1.98, 0.0}};
+  Points[1].Measurements = {{"y", 1.02, 0.0}, {"z", 1.98, 0.0}};
   auto Error =
       InstructionBenchmarkClustering::create(Points, 2, 0.25).takeError();
   ASSERT_TRUE((bool)Error);
@@ -80,8 +80,8 @@ TEST(ClusteringTest, Clusters3D_InvalidS
 
 TEST(ClusteringTest, Clusters3D_InvalidOrder) {
   std::vector<InstructionBenchmark> Points(6);
-  Points[0].Measurements = {{"x", 0.01, 0.0, ""}, {"y", 1.02, 0.0, ""}};
-  Points[1].Measurements = {{"y", 1.02, 0.0, ""}, {"x", 1.98, 0.0, ""}};
+  Points[0].Measurements = {{"x", 0.01, 0.0}, {"y", 1.02, 0.0}};
+  Points[1].Measurements = {{"y", 1.02, 0.0}, {"x", 1.98, 0.0}};
   auto Error =
       InstructionBenchmarkClustering::create(Points, 2, 0.25).takeError();
   ASSERT_TRUE((bool)Error);

Modified: llvm/trunk/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp?rev=343108&r1=343107&r2=343108&view=diff
==============================================================================
--- llvm/trunk/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp (original)
+++ llvm/trunk/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp Wed Sep 26 06:35:10 2018
@@ -76,8 +76,8 @@ TEST(BenchmarkResultTest, WriteToAndRead
   ToDisk.CpuName = "cpu_name";
   ToDisk.LLVMTriple = "llvm_triple";
   ToDisk.NumRepetitions = 1;
-  ToDisk.Measurements.push_back(BenchmarkMeasure{"a", 1, 1, "debug a"});
-  ToDisk.Measurements.push_back(BenchmarkMeasure{"b", 2, 2, ""});
+  ToDisk.Measurements.push_back(BenchmarkMeasure{"a", 1, 1});
+  ToDisk.Measurements.push_back(BenchmarkMeasure{"b", 2, 2});
   ToDisk.Error = "error";
   ToDisk.Info = "info";
 
@@ -126,10 +126,10 @@ TEST(BenchmarkResultTest, WriteToAndRead
 
 TEST(BenchmarkResultTest, PerInstructionStats) {
   PerInstructionStats Stats;
-  Stats.push(BenchmarkMeasure{"a", 0.5, 0.0, "debug a"});
-  Stats.push(BenchmarkMeasure{"a", 1.5, 0.0, "debug a"});
-  Stats.push(BenchmarkMeasure{"a", -1.0, 0.0, "debug a"});
-  Stats.push(BenchmarkMeasure{"a", 0.0, 0.0, "debug a"});
+  Stats.push(BenchmarkMeasure{"a", 0.5, 0.0});
+  Stats.push(BenchmarkMeasure{"a", 1.5, 0.0});
+  Stats.push(BenchmarkMeasure{"a", -1.0, 0.0});
+  Stats.push(BenchmarkMeasure{"a", 0.0, 0.0});
   EXPECT_EQ(Stats.min(), -1.0);
   EXPECT_EQ(Stats.max(), 1.5);
   EXPECT_EQ(Stats.avg(), 0.25); // (0.5+1.5-1.0+0.0) / 4




More information about the llvm-commits mailing list