diff options
author | John Brawn <john.brawn@arm.com> | 2018-07-02 13:14:49 +0000 |
---|---|---|
committer | John Brawn <john.brawn@arm.com> | 2018-07-02 13:14:49 +0000 |
commit | 3fc11a82d18392145c2d4d44218f36e984335b74 (patch) | |
tree | 732fee130c03f77c88ae40270c81b4096972c4fd /tools/llvm-exegesis | |
parent | 2a87571b0885b5fbd27ed9e4aa6979ad9f5ae173 (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336099 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-exegesis')
-rw-r--r-- | tools/llvm-exegesis/lib/Latency.cpp | 19 | ||||
-rw-r--r-- | tools/llvm-exegesis/lib/Latency.h | 2 | ||||
-rw-r--r-- | tools/llvm-exegesis/llvm-exegesis.cpp | 4 |
3 files changed, 16 insertions, 9 deletions
diff --git a/tools/llvm-exegesis/lib/Latency.cpp b/tools/llvm-exegesis/lib/Latency.cpp index 29bb74f6673..e2aae970e22 100644 --- a/tools/llvm-exegesis/lib/Latency.cpp +++ b/tools/llvm-exegesis/lib/Latency.cpp @@ -94,6 +94,18 @@ LatencyBenchmarkRunner::generatePrototype(unsigned Opcode) const { 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> LatencyBenchmarkRunner::runMeasurements(const ExecutableFunction &Function, const unsigned NumRepetitions) const { @@ -101,12 +113,9 @@ LatencyBenchmarkRunner::runMeasurements(const ExecutableFunction &Function, // measure several times and take the minimum value. constexpr const int NumMeasurements = 30; int64_t MinLatency = std::numeric_limits<int64_t>::max(); - const char *CounterName = State.getSubtargetInfo() - .getSchedModel() - .getExtraProcessorInfo() - .PfmCounters.CycleCounter; + const char *CounterName = getCounterName(); 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); if (!CyclesPerfEvent.valid()) llvm::report_fatal_error("invalid perf event"); diff --git a/tools/llvm-exegesis/lib/Latency.h b/tools/llvm-exegesis/lib/Latency.h index 058216d8113..9d6cfc7b387 100644 --- a/tools/llvm-exegesis/lib/Latency.h +++ b/tools/llvm-exegesis/lib/Latency.h @@ -38,6 +38,8 @@ private: std::vector<BenchmarkMeasure> runMeasurements(const ExecutableFunction &EF, const unsigned NumRepetitions) const override; + + virtual const char *getCounterName() const; }; } // namespace exegesis diff --git a/tools/llvm-exegesis/llvm-exegesis.cpp b/tools/llvm-exegesis/llvm-exegesis.cpp index 92d19c07015..6b626b0eaa3 100644 --- a/tools/llvm-exegesis/llvm-exegesis.cpp +++ b/tools/llvm-exegesis/llvm-exegesis.cpp @@ -140,10 +140,6 @@ void benchmarkMain() { 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 = State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State); if (!Runner) { |