summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib')
-rw-r--r--llvm/tools/llvm-exegesis/lib/Latency.cpp19
-rw-r--r--llvm/tools/llvm-exegesis/lib/Latency.h2
2 files changed, 16 insertions, 5 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Latency.cpp b/llvm/tools/llvm-exegesis/lib/Latency.cpp
index 29bb74f6673..e2aae970e22 100644
--- a/llvm/tools/llvm-exegesis/lib/Latency.cpp
+++ b/llvm/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/llvm/tools/llvm-exegesis/lib/Latency.h b/llvm/tools/llvm-exegesis/lib/Latency.h
index 058216d8113..9d6cfc7b387 100644
--- a/llvm/tools/llvm-exegesis/lib/Latency.h
+++ b/llvm/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
OpenPOWER on IntegriCloud