From 28d4f858243e404a08a905d6e764b74a6824d2d1 Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Wed, 26 Sep 2018 13:35:10 +0000 Subject: [PATCH] [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 llvm-svn: 343108 --- .../llvm-exegesis/X86/analysis-uops-backwards.test | 30 ++++++++++++++++++++++ .../tools/llvm-exegesis/X86/analysis-uops.test | 29 +++++++++++++++++++++ llvm/tools/llvm-exegesis/lib/Analysis.cpp | 5 +--- llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp | 7 +++-- llvm/tools/llvm-exegesis/lib/BenchmarkResult.h | 4 +-- .../tools/llvm-exegesis/ClusteringTest.cpp | 18 ++++++------- .../llvm-exegesis/X86/BenchmarkResultTest.cpp | 12 ++++----- 7 files changed, 81 insertions(+), 24 deletions(-) create mode 100644 llvm/test/tools/llvm-exegesis/X86/analysis-uops-backwards.test create mode 100644 llvm/test/tools/llvm-exegesis/X86/analysis-uops.test diff --git a/llvm/test/tools/llvm-exegesis/X86/analysis-uops-backwards.test b/llvm/test/tools/llvm-exegesis/X86/analysis-uops-backwards.test new file mode 100644 index 0000000..4c758ba --- /dev/null +++ b/llvm/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 +... diff --git a/llvm/test/tools/llvm-exegesis/X86/analysis-uops.test b/llvm/test/tools/llvm-exegesis/X86/analysis-uops.test new file mode 100644 index 0000000..f1aae97 --- /dev/null +++ b/llvm/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 +... diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp index 54dc4be..1da36b2 100644 --- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp +++ b/llvm/tools/llvm-exegesis/lib/Analysis.cpp @@ -248,10 +248,7 @@ void Analysis::printSchedClassClustersHtml( 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 << ""; diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp index 1748c53..a3dd56c 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -164,10 +164,13 @@ template <> struct SequenceElementTraits { // 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; }; diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h index 0fcf4e9..961c07b 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h @@ -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. diff --git a/llvm/unittests/tools/llvm-exegesis/ClusteringTest.cpp b/llvm/unittests/tools/llvm-exegesis/ClusteringTest.cpp index 5d583a0..e1bffd6 100644 --- a/llvm/unittests/tools/llvm-exegesis/ClusteringTest.cpp +++ b/llvm/unittests/tools/llvm-exegesis/ClusteringTest.cpp @@ -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 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_InvalidSize) { 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); diff --git a/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp b/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp index 67e8d2c..b17ae1c 100644 --- a/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp +++ b/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp @@ -76,8 +76,8 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) { 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, WriteToAndReadFromDisk) { 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 -- 2.7.4