mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +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);
|
std::vector<BenchmarkMeasure> SchedClassPoint(NumMeasurements);
|
||||||
// Latency case.
|
// Latency case.
|
||||||
assert(!Clustering.getPoints().empty());
|
assert(!Clustering.getPoints().empty());
|
||||||
const std::string &Mode = Clustering.getPoints()[0].Key.Mode;
|
const InstructionBenchmarkKey::ModeE Mode =
|
||||||
if (Mode == "latency") { // FIXME: use an enum.
|
Clustering.getPoints()[0].Key.Mode;
|
||||||
|
if (Mode == InstructionBenchmarkKey::Latency) {
|
||||||
if (NumMeasurements != 1) {
|
if (NumMeasurements != 1) {
|
||||||
llvm::errs()
|
llvm::errs()
|
||||||
<< "invalid number of measurements in latency mode: expected 1, got "
|
<< "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);
|
std::max<double>(SchedClassPoint[0].Value, WLE->Cycles);
|
||||||
}
|
}
|
||||||
ClusterCenterPoint[0].Value = Representative[0].avg();
|
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) {
|
for (int I = 0, E = Representative.size(); I < E; ++I) {
|
||||||
// Find the pressure on ProcResIdx `Key`.
|
// Find the pressure on ProcResIdx `Key`.
|
||||||
uint16_t ProcResIdx = 0;
|
uint16_t ProcResIdx = 0;
|
||||||
@ -358,8 +359,8 @@ bool Analysis::SchedClassCluster::measurementsMatch(
|
|||||||
ClusterCenterPoint[I].Value = Representative[I].avg();
|
ClusterCenterPoint[I].Value = Representative[I].avg();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
llvm::errs() << "unimplemented measurement matching for mode ''" << Mode
|
llvm::errs() << "unimplemented measurement matching for mode " << Mode
|
||||||
<< "''\n";
|
<< "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Clustering.isNeighbour(ClusterCenterPoint, SchedClassPoint);
|
return Clustering.isNeighbour(ClusterCenterPoint, SchedClassPoint);
|
||||||
|
@ -34,6 +34,16 @@ template <> struct MappingTraits<exegesis::BenchmarkMeasure> {
|
|||||||
static const bool flow = true;
|
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> {
|
template <> struct MappingTraits<exegesis::InstructionBenchmarkKey> {
|
||||||
static void mapping(IO &Io, exegesis::InstructionBenchmarkKey &Obj) {
|
static void mapping(IO &Io, exegesis::InstructionBenchmarkKey &Obj) {
|
||||||
Io.mapRequired("opcode_name", Obj.OpcodeName);
|
Io.mapRequired("opcode_name", Obj.OpcodeName);
|
||||||
|
@ -27,8 +27,8 @@ namespace exegesis {
|
|||||||
struct InstructionBenchmarkKey {
|
struct InstructionBenchmarkKey {
|
||||||
// The LLVM opcode name.
|
// The LLVM opcode name.
|
||||||
std::string OpcodeName;
|
std::string OpcodeName;
|
||||||
// The benchmark mode.
|
enum ModeE { Unknown, Latency, Uops };
|
||||||
std::string Mode;
|
ModeE Mode;
|
||||||
// An opaque configuration, that can be used to separate several benchmarks of
|
// An opaque configuration, that can be used to separate several benchmarks of
|
||||||
// the same instruction under different configurations.
|
// the same instruction under different configurations.
|
||||||
std::string Config;
|
std::string Config;
|
||||||
|
@ -37,7 +37,7 @@ InstructionBenchmark BenchmarkRunner::run(unsigned Opcode,
|
|||||||
InstructionBenchmark InstrBenchmark;
|
InstructionBenchmark InstrBenchmark;
|
||||||
|
|
||||||
InstrBenchmark.Key.OpcodeName = State.getInstrInfo().getName(Opcode);
|
InstrBenchmark.Key.OpcodeName = State.getInstrInfo().getName(Opcode);
|
||||||
InstrBenchmark.Key.Mode = getDisplayName();
|
InstrBenchmark.Key.Mode = getMode();
|
||||||
InstrBenchmark.CpuName = State.getCpuName();
|
InstrBenchmark.CpuName = State.getCpuName();
|
||||||
InstrBenchmark.LLVMTriple = State.getTriple();
|
InstrBenchmark.LLVMTriple = State.getTriple();
|
||||||
InstrBenchmark.NumRepetitions = NumRepetitions;
|
InstrBenchmark.NumRepetitions = NumRepetitions;
|
||||||
|
@ -54,7 +54,7 @@ protected:
|
|||||||
const llvm::MCRegisterInfo &MCRegisterInfo;
|
const llvm::MCRegisterInfo &MCRegisterInfo;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual const char *getDisplayName() const = 0;
|
virtual InstructionBenchmarkKey::ModeE getMode() const = 0;
|
||||||
|
|
||||||
virtual llvm::Expected<std::vector<llvm::MCInst>>
|
virtual llvm::Expected<std::vector<llvm::MCInst>>
|
||||||
createSnippet(RegisterAliasingTrackerCache &RATC, unsigned Opcode,
|
createSnippet(RegisterAliasingTrackerCache &RATC, unsigned Opcode,
|
||||||
|
@ -52,7 +52,9 @@ static llvm::Error makeError(llvm::Twine Msg) {
|
|||||||
|
|
||||||
LatencyBenchmarkRunner::~LatencyBenchmarkRunner() = default;
|
LatencyBenchmarkRunner::~LatencyBenchmarkRunner() = default;
|
||||||
|
|
||||||
const char *LatencyBenchmarkRunner::getDisplayName() const { return "latency"; }
|
InstructionBenchmarkKey::ModeE LatencyBenchmarkRunner::getMode() const {
|
||||||
|
return InstructionBenchmarkKey::Latency;
|
||||||
|
}
|
||||||
|
|
||||||
llvm::Expected<std::vector<llvm::MCInst>>
|
llvm::Expected<std::vector<llvm::MCInst>>
|
||||||
LatencyBenchmarkRunner::createSnippet(RegisterAliasingTrackerCache &RATC,
|
LatencyBenchmarkRunner::createSnippet(RegisterAliasingTrackerCache &RATC,
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
~LatencyBenchmarkRunner() override;
|
~LatencyBenchmarkRunner() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *getDisplayName() const override;
|
InstructionBenchmarkKey::ModeE getMode() const override;
|
||||||
|
|
||||||
llvm::Expected<std::vector<llvm::MCInst>>
|
llvm::Expected<std::vector<llvm::MCInst>>
|
||||||
createSnippet(RegisterAliasingTrackerCache &RATC, unsigned OpcodeIndex,
|
createSnippet(RegisterAliasingTrackerCache &RATC, unsigned OpcodeIndex,
|
||||||
|
@ -141,7 +141,9 @@ static llvm::Error makeError(llvm::Twine Msg) {
|
|||||||
|
|
||||||
UopsBenchmarkRunner::~UopsBenchmarkRunner() = default;
|
UopsBenchmarkRunner::~UopsBenchmarkRunner() = default;
|
||||||
|
|
||||||
const char *UopsBenchmarkRunner::getDisplayName() const { return "uops"; }
|
InstructionBenchmarkKey::ModeE UopsBenchmarkRunner::getMode() const {
|
||||||
|
return InstructionBenchmarkKey::Uops;
|
||||||
|
}
|
||||||
|
|
||||||
llvm::Expected<std::vector<llvm::MCInst>>
|
llvm::Expected<std::vector<llvm::MCInst>>
|
||||||
UopsBenchmarkRunner::createSnippet(RegisterAliasingTrackerCache &RATC,
|
UopsBenchmarkRunner::createSnippet(RegisterAliasingTrackerCache &RATC,
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
~UopsBenchmarkRunner() override;
|
~UopsBenchmarkRunner() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *getDisplayName() const override;
|
InstructionBenchmarkKey::ModeE getMode() const override;
|
||||||
|
|
||||||
llvm::Expected<std::vector<llvm::MCInst>>
|
llvm::Expected<std::vector<llvm::MCInst>>
|
||||||
createSnippet(RegisterAliasingTrackerCache &RATC, unsigned Opcode,
|
createSnippet(RegisterAliasingTrackerCache &RATC, unsigned Opcode,
|
||||||
|
@ -28,7 +28,7 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
|
|||||||
InstructionBenchmark ToDisk;
|
InstructionBenchmark ToDisk;
|
||||||
|
|
||||||
ToDisk.Key.OpcodeName = "name";
|
ToDisk.Key.OpcodeName = "name";
|
||||||
ToDisk.Key.Mode = "mode";
|
ToDisk.Key.Mode = InstructionBenchmarkKey::Latency;
|
||||||
ToDisk.Key.Config = "config";
|
ToDisk.Key.Config = "config";
|
||||||
ToDisk.CpuName = "cpu_name";
|
ToDisk.CpuName = "cpu_name";
|
||||||
ToDisk.LLVMTriple = "llvm_triple";
|
ToDisk.LLVMTriple = "llvm_triple";
|
||||||
|
Loading…
Reference in New Issue
Block a user