1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[llvm-exegesis] Delegate the decision of cycle counter name to the target

Currently the cycle counter is taken from the subtarget schedule model, which
isn't any use if the subtarget doesn't have one. Delegate the decision to the
target benchmark runner, as it may know better what to do in that case, with
the default being the current behaviour.

Differential Revision: https://reviews.llvm.org/D48779

llvm-svn: 336099
This commit is contained in:
John Brawn 2018-07-02 13:14:49 +00:00
parent 0c6c82408b
commit 86bf3b3bb5
3 changed files with 16 additions and 9 deletions

View File

@ -94,6 +94,18 @@ LatencyBenchmarkRunner::generatePrototype(unsigned Opcode) const {
return generateTwoInstructionPrototype(Instr); return generateTwoInstructionPrototype(Instr);
} }
const char *LatencyBenchmarkRunner::getCounterName() const {
if (!State.getSubtargetInfo().getSchedModel().hasExtraProcessorInfo())
llvm::report_fatal_error("sched model is missing extra processor info!");
const char *CounterName = State.getSubtargetInfo()
.getSchedModel()
.getExtraProcessorInfo()
.PfmCounters.CycleCounter;
if (!CounterName)
llvm::report_fatal_error("sched model does not define a cycle counter");
return CounterName;
}
std::vector<BenchmarkMeasure> std::vector<BenchmarkMeasure>
LatencyBenchmarkRunner::runMeasurements(const ExecutableFunction &Function, LatencyBenchmarkRunner::runMeasurements(const ExecutableFunction &Function,
const unsigned NumRepetitions) const { const unsigned NumRepetitions) const {
@ -101,12 +113,9 @@ LatencyBenchmarkRunner::runMeasurements(const ExecutableFunction &Function,
// measure several times and take the minimum value. // measure several times and take the minimum value.
constexpr const int NumMeasurements = 30; constexpr const int NumMeasurements = 30;
int64_t MinLatency = std::numeric_limits<int64_t>::max(); int64_t MinLatency = std::numeric_limits<int64_t>::max();
const char *CounterName = State.getSubtargetInfo() const char *CounterName = getCounterName();
.getSchedModel()
.getExtraProcessorInfo()
.PfmCounters.CycleCounter;
if (!CounterName) if (!CounterName)
llvm::report_fatal_error("sched model does not define a cycle counter"); llvm::report_fatal_error("could not determine cycle counter name");
const pfm::PerfEvent CyclesPerfEvent(CounterName); const pfm::PerfEvent CyclesPerfEvent(CounterName);
if (!CyclesPerfEvent.valid()) if (!CyclesPerfEvent.valid())
llvm::report_fatal_error("invalid perf event"); llvm::report_fatal_error("invalid perf event");

View File

@ -38,6 +38,8 @@ private:
std::vector<BenchmarkMeasure> std::vector<BenchmarkMeasure>
runMeasurements(const ExecutableFunction &EF, runMeasurements(const ExecutableFunction &EF,
const unsigned NumRepetitions) const override; const unsigned NumRepetitions) const override;
virtual const char *getCounterName() const;
}; };
} // namespace exegesis } // namespace exegesis

View File

@ -140,10 +140,6 @@ void benchmarkMain() {
return; return;
} }
// FIXME: Do not require SchedModel for latency.
if (!State.getSubtargetInfo().getSchedModel().hasExtraProcessorInfo())
llvm::report_fatal_error("sched model is missing extra processor info!");
const std::unique_ptr<BenchmarkRunner> Runner = const std::unique_ptr<BenchmarkRunner> Runner =
State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State); State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State);
if (!Runner) { if (!Runner) {