mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[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 llvm-svn: 333886
This commit is contained in:
parent
cb47ea5624
commit
70b9b7a120
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -28,7 +28,7 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
|
||||
InstructionBenchmark ToDisk;
|
||||
|
||||
ToDisk.Key.OpcodeName = "name";
|
||||
ToDisk.Key.Mode = "mode";
|
||||
ToDisk.Key.Mode = InstructionBenchmarkKey::Latency;
|
||||
ToDisk.Key.Config = "config";
|
||||
ToDisk.CpuName = "cpu_name";
|
||||
ToDisk.LLVMTriple = "llvm_triple";
|
||||
|
Loading…
Reference in New Issue
Block a user