Index: test/tools/llvm-exegesis/X86/analysis-uops-backwards.test
===================================================================
--- /dev/null
+++ test/tools/llvm-exegesis/X86/analysis-uops-backwards.test
@@ -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
+...
Index: test/tools/llvm-exegesis/X86/analysis-uops.test
===================================================================
--- /dev/null
+++ test/tools/llvm-exegesis/X86/analysis-uops.test
@@ -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
+...
Index: tools/llvm-exegesis/lib/Analysis.cpp
===================================================================
--- tools/llvm-exegesis/lib/Analysis.cpp
+++ tools/llvm-exegesis/lib/Analysis.cpp
@@ -248,10 +248,7 @@
for (const auto &Measurement :
Points[Clusters[0].getPointIds()[0]].Measurements) {
OS << "
";
- if (Measurement.DebugString.empty())
- writeEscaped(OS, Measurement.Key);
- else
- writeEscaped(OS, Measurement.DebugString);
+ writeEscaped(OS, Measurement.Key);
OS << " | ";
}
OS << "";
Index: tools/llvm-exegesis/lib/BenchmarkResult.h
===================================================================
--- tools/llvm-exegesis/lib/BenchmarkResult.h
+++ tools/llvm-exegesis/lib/BenchmarkResult.h
@@ -43,7 +43,7 @@
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 @@
// 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.
Index: tools/llvm-exegesis/lib/BenchmarkResult.cpp
===================================================================
--- tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -164,10 +164,13 @@
// e.g. { "key": "the key", "value": 0123 }
template <> struct MappingTraits {
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;
};
Index: unittests/tools/llvm-exegesis/ClusteringTest.cpp
===================================================================
--- unittests/tools/llvm-exegesis/ClusteringTest.cpp
+++ unittests/tools/llvm-exegesis/ClusteringTest.cpp
@@ -27,17 +27,17 @@
// 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_InvalidSize) {
std::vector 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_InvalidOrder) {
std::vector 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);
Index: unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
===================================================================
--- unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
+++ unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
@@ -76,8 +76,8 @@
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, 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