[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
This commit is contained in:
Clement Courbet 2018-09-26 13:35:10 +00:00
parent 6acaa18afc
commit 28d4f85824
7 changed files with 81 additions and 24 deletions

View File

@ -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
...

View File

@ -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
...

View File

@ -248,10 +248,7 @@ void Analysis::printSchedClassClustersHtml(
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>";

View File

@ -164,10 +164,13 @@ template <> struct SequenceElementTraits<exegesis::BenchmarkMeasure> {
// 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;
};

View File

@ -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.

View File

@ -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_InvalidSize) {
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);

View File

@ -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