aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-exegesis
diff options
context:
space:
mode:
authorClement Courbet <courbet@google.com>2018-06-04 11:43:40 +0000
committerClement Courbet <courbet@google.com>2018-06-04 11:43:40 +0000
commit2d87e5abe5e3121d73e3d559616dfe14817417af (patch)
tree95300c8a88bfcaafdcea594d0ce36eba45af01bf /tools/llvm-exegesis
parentf5872fd35f6c8f6a6592cbd4ad47d3e9a5ceae7f (diff)
[llvm-exegesis][NFC] Use an enum instead of a string for benchmark mode.
Summary: YAML encoding is backwards-compatible. Reviewers: gchatelet Subscribers: tschuett, llvm-commits Differential Revision: https://reviews.llvm.org/D47705 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333886 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-exegesis')
-rw-r--r--tools/llvm-exegesis/lib/Analysis.cpp11
-rw-r--r--tools/llvm-exegesis/lib/BenchmarkResult.cpp10
-rw-r--r--tools/llvm-exegesis/lib/BenchmarkResult.h4
-rw-r--r--tools/llvm-exegesis/lib/BenchmarkRunner.cpp2
-rw-r--r--tools/llvm-exegesis/lib/BenchmarkRunner.h2
-rw-r--r--tools/llvm-exegesis/lib/Latency.cpp4
-rw-r--r--tools/llvm-exegesis/lib/Latency.h2
-rw-r--r--tools/llvm-exegesis/lib/Uops.cpp4
-rw-r--r--tools/llvm-exegesis/lib/Uops.h2
9 files changed, 28 insertions, 13 deletions
diff --git a/tools/llvm-exegesis/lib/Analysis.cpp b/tools/llvm-exegesis/lib/Analysis.cpp
index 0eb9cf20378..bf132724eaa 100644
--- a/tools/llvm-exegesis/lib/Analysis.cpp
+++ b/tools/llvm-exegesis/lib/Analysis.cpp
@@ -319,8 +319,9 @@ bool Analysis::SchedClassCluster::measurementsMatch(
std::vector<BenchmarkMeasure> SchedClassPoint(NumMeasurements);
// Latency case.
assert(!Clustering.getPoints().empty());
- const std::string &Mode = Clustering.getPoints()[0].Key.Mode;
- if (Mode == "latency") { // FIXME: use an enum.
+ const InstructionBenchmarkKey::ModeE Mode =
+ Clustering.getPoints()[0].Key.Mode;
+ if (Mode == InstructionBenchmarkKey::Latency) {
if (NumMeasurements != 1) {
llvm::errs()
<< "invalid number of measurements in latency mode: expected 1, got "
@@ -336,7 +337,7 @@ bool Analysis::SchedClassCluster::measurementsMatch(
std::max<double>(SchedClassPoint[0].Value, WLE->Cycles);
}
ClusterCenterPoint[0].Value = Representative[0].avg();
- } else if (Mode == "uops") {
+ } else if (Mode == InstructionBenchmarkKey::Uops) {
for (int I = 0, E = Representative.size(); I < E; ++I) {
// Find the pressure on ProcResIdx `Key`.
uint16_t ProcResIdx = 0;
@@ -358,8 +359,8 @@ bool Analysis::SchedClassCluster::measurementsMatch(
ClusterCenterPoint[I].Value = Representative[I].avg();
}
} else {
- llvm::errs() << "unimplemented measurement matching for mode ''" << Mode
- << "''\n";
+ llvm::errs() << "unimplemented measurement matching for mode " << Mode
+ << "\n";
return false;
}
return Clustering.isNeighbour(ClusterCenterPoint, SchedClassPoint);
diff --git a/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/tools/llvm-exegesis/lib/BenchmarkResult.cpp
index ed449dbd94e..fd5b3504e1e 100644
--- a/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -34,6 +34,16 @@ template <> struct MappingTraits<exegesis::BenchmarkMeasure> {
static const bool flow = true;
};
+template <>
+struct ScalarEnumerationTraits<exegesis::InstructionBenchmarkKey::ModeE> {
+ static void enumeration(IO &Io,
+ exegesis::InstructionBenchmarkKey::ModeE &Value) {
+ Io.enumCase(Value, "", exegesis::InstructionBenchmarkKey::Unknown);
+ Io.enumCase(Value, "latency", exegesis::InstructionBenchmarkKey::Latency);
+ Io.enumCase(Value, "uops", exegesis::InstructionBenchmarkKey::Uops);
+ }
+};
+
template <> struct MappingTraits<exegesis::InstructionBenchmarkKey> {
static void mapping(IO &Io, exegesis::InstructionBenchmarkKey &Obj) {
Io.mapRequired("opcode_name", Obj.OpcodeName);
diff --git a/tools/llvm-exegesis/lib/BenchmarkResult.h b/tools/llvm-exegesis/lib/BenchmarkResult.h
index 41d631eca4b..b160507afc6 100644
--- a/tools/llvm-exegesis/lib/BenchmarkResult.h
+++ b/tools/llvm-exegesis/lib/BenchmarkResult.h
@@ -27,8 +27,8 @@ namespace exegesis {
struct InstructionBenchmarkKey {
// The LLVM opcode name.
std::string OpcodeName;
- // The benchmark mode.
- std::string Mode;
+ enum ModeE { Unknown, Latency, Uops };
+ ModeE Mode;
// An opaque configuration, that can be used to separate several benchmarks of
// the same instruction under different configurations.
std::string Config;
diff --git a/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 0e2052f82cc..75b2a1dc682 100644
--- a/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -37,7 +37,7 @@ InstructionBenchmark BenchmarkRunner::run(unsigned Opcode,
InstructionBenchmark InstrBenchmark;
InstrBenchmark.Key.OpcodeName = State.getInstrInfo().getName(Opcode);
- InstrBenchmark.Key.Mode = getDisplayName();
+ InstrBenchmark.Key.Mode = getMode();
InstrBenchmark.CpuName = State.getCpuName();
InstrBenchmark.LLVMTriple = State.getTriple();
InstrBenchmark.NumRepetitions = NumRepetitions;
diff --git a/tools/llvm-exegesis/lib/BenchmarkRunner.h b/tools/llvm-exegesis/lib/BenchmarkRunner.h
index 679436a2cf7..1382951716e 100644
--- a/tools/llvm-exegesis/lib/BenchmarkRunner.h
+++ b/tools/llvm-exegesis/lib/BenchmarkRunner.h
@@ -54,7 +54,7 @@ protected:
const llvm::MCRegisterInfo &MCRegisterInfo;
private:
- virtual const char *getDisplayName() const = 0;
+ virtual InstructionBenchmarkKey::ModeE getMode() const = 0;
virtual llvm::Expected<std::vector<llvm::MCInst>>
createSnippet(RegisterAliasingTrackerCache &RATC, unsigned Opcode,
diff --git a/tools/llvm-exegesis/lib/Latency.cpp b/tools/llvm-exegesis/lib/Latency.cpp
index 4233345aba0..633189e110e 100644
--- a/tools/llvm-exegesis/lib/Latency.cpp
+++ b/tools/llvm-exegesis/lib/Latency.cpp
@@ -52,7 +52,9 @@ static llvm::Error makeError(llvm::Twine Msg) {
LatencyBenchmarkRunner::~LatencyBenchmarkRunner() = default;
-const char *LatencyBenchmarkRunner::getDisplayName() const { return "latency"; }
+InstructionBenchmarkKey::ModeE LatencyBenchmarkRunner::getMode() const {
+ return InstructionBenchmarkKey::Latency;
+}
llvm::Expected<std::vector<llvm::MCInst>>
LatencyBenchmarkRunner::createSnippet(RegisterAliasingTrackerCache &RATC,
diff --git a/tools/llvm-exegesis/lib/Latency.h b/tools/llvm-exegesis/lib/Latency.h
index f3963f0f1f9..9dd0039b7c8 100644
--- a/tools/llvm-exegesis/lib/Latency.h
+++ b/tools/llvm-exegesis/lib/Latency.h
@@ -25,7 +25,7 @@ public:
~LatencyBenchmarkRunner() override;
private:
- const char *getDisplayName() const override;
+ InstructionBenchmarkKey::ModeE getMode() const override;
llvm::Expected<std::vector<llvm::MCInst>>
createSnippet(RegisterAliasingTrackerCache &RATC, unsigned OpcodeIndex,
diff --git a/tools/llvm-exegesis/lib/Uops.cpp b/tools/llvm-exegesis/lib/Uops.cpp
index 94282862989..145bfad733b 100644
--- a/tools/llvm-exegesis/lib/Uops.cpp
+++ b/tools/llvm-exegesis/lib/Uops.cpp
@@ -141,7 +141,9 @@ static llvm::Error makeError(llvm::Twine Msg) {
UopsBenchmarkRunner::~UopsBenchmarkRunner() = default;
-const char *UopsBenchmarkRunner::getDisplayName() const { return "uops"; }
+InstructionBenchmarkKey::ModeE UopsBenchmarkRunner::getMode() const {
+ return InstructionBenchmarkKey::Uops;
+}
llvm::Expected<std::vector<llvm::MCInst>>
UopsBenchmarkRunner::createSnippet(RegisterAliasingTrackerCache &RATC,
diff --git a/tools/llvm-exegesis/lib/Uops.h b/tools/llvm-exegesis/lib/Uops.h
index d305d0124f8..4fe7cb42ad2 100644
--- a/tools/llvm-exegesis/lib/Uops.h
+++ b/tools/llvm-exegesis/lib/Uops.h
@@ -25,7 +25,7 @@ public:
~UopsBenchmarkRunner() override;
private:
- const char *getDisplayName() const override;
+ InstructionBenchmarkKey::ModeE getMode() const override;
llvm::Expected<std::vector<llvm::MCInst>>
createSnippet(RegisterAliasingTrackerCache &RATC, unsigned Opcode,