[PATCH] D48779: [llvm-exegesis] Delegate the decision of cycle counter name to the target
John Brawn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 29 10:45:21 PDT 2018
john.brawn created this revision.
john.brawn added reviewers: courbet, gchatelet.
Herald added a subscriber: tschuett.
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.
Repository:
rL LLVM
https://reviews.llvm.org/D48779
Files:
tools/llvm-exegesis/lib/Latency.cpp
tools/llvm-exegesis/lib/Latency.h
tools/llvm-exegesis/llvm-exegesis.cpp
Index: tools/llvm-exegesis/llvm-exegesis.cpp
===================================================================
--- tools/llvm-exegesis/llvm-exegesis.cpp
+++ tools/llvm-exegesis/llvm-exegesis.cpp
@@ -140,10 +140,6 @@
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) {
Index: tools/llvm-exegesis/lib/Latency.h
===================================================================
--- tools/llvm-exegesis/lib/Latency.h
+++ tools/llvm-exegesis/lib/Latency.h
@@ -38,6 +38,8 @@
std::vector<BenchmarkMeasure>
runMeasurements(const ExecutableFunction &EF,
const unsigned NumRepetitions) const override;
+
+ virtual const char *getCounterName() const;
};
} // namespace exegesis
Index: tools/llvm-exegesis/lib/Latency.cpp
===================================================================
--- tools/llvm-exegesis/lib/Latency.cpp
+++ tools/llvm-exegesis/lib/Latency.cpp
@@ -94,19 +94,27 @@
return generateTwoInstructionPrototype(Instr);
}
+const char *LatencyBenchmarkRunner::getCounterName() const {
+ // FIXME: Do not require SchedModel for latency.
+ 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 {
// Cycle measurements include some overhead from the kernel. Repeat the
// 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;
- if (!CounterName)
- llvm::report_fatal_error("sched model does not define a cycle counter");
+ const char *CounterName = getCounterName();
const pfm::PerfEvent CyclesPerfEvent(CounterName);
if (!CyclesPerfEvent.valid())
llvm::report_fatal_error("invalid perf event");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48779.153534.patch
Type: text/x-patch
Size: 2838 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180629/afce8071/attachment.bin>
More information about the llvm-commits
mailing list