[PATCH] D71927: [llvm-exegesis] Check counters before running
Miloš Stojanović via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 27 06:31:22 PST 2019
mstojanovic created this revision.
mstojanovic added reviewers: gchatelet, courbet, petarj.
Herald added a subscriber: tschuett.
Herald added a project: LLVM.
Check if the appropriate counter for the specified mode is defined on the target. This is checked before any other work is done.
https://reviews.llvm.org/D71927
Files:
llvm/tools/llvm-exegesis/lib/Latency.cpp
llvm/tools/llvm-exegesis/lib/Target.cpp
llvm/tools/llvm-exegesis/llvm-exegesis.cpp
Index: llvm/tools/llvm-exegesis/llvm-exegesis.cpp
===================================================================
--- llvm/tools/llvm-exegesis/llvm-exegesis.cpp
+++ llvm/tools/llvm-exegesis/llvm-exegesis.cpp
@@ -242,6 +242,13 @@
InitializeNativeExegesisTarget();
const LLVMState State(CpuName);
+
+ const std::unique_ptr<BenchmarkRunner> Runner =
+ State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State);
+ if (!Runner) {
+ report_fatal_error("cannot create benchmark runner");
+ }
+
const auto Opcodes = getOpcodesOrDie(State.getInstrInfo());
const auto Repetitor = SnippetRepetitor::Create(RepetitionMode, State);
@@ -272,12 +279,6 @@
Configurations = ExitOnErr(readSnippets(State, SnippetsFile));
}
- const std::unique_ptr<BenchmarkRunner> Runner =
- State.getExegesisTarget().createBenchmarkRunner(BenchmarkMode, State);
- if (!Runner) {
- report_fatal_error("cannot create benchmark runner");
- }
-
if (NumRepetitions == 0)
report_fatal_error("--num-repetitions must be greater than zero");
Index: llvm/tools/llvm-exegesis/lib/Target.cpp
===================================================================
--- llvm/tools/llvm-exegesis/lib/Target.cpp
+++ llvm/tools/llvm-exegesis/lib/Target.cpp
@@ -54,13 +54,24 @@
std::unique_ptr<BenchmarkRunner>
ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode,
const LLVMState &State) const {
+ PfmCountersInfo PfmCouters = State.getPfmCounters();
switch (Mode) {
case InstructionBenchmark::Unknown:
return nullptr;
case InstructionBenchmark::Latency:
case InstructionBenchmark::InverseThroughput:
+ if (!PfmCouters.CycleCounter) {
+ const char *ModeName = Mode == InstructionBenchmark::Latency
+ ? "latency"
+ : "inverse_throughput";
+ report_fatal_error(Twine("can't run '").concat(ModeName).concat("' mode, "
+ "sched model does not define a cycle counter."));
+ }
return createLatencyBenchmarkRunner(State, Mode);
case InstructionBenchmark::Uops:
+ if (!PfmCouters.UopsCounter)
+ report_fatal_error(
+ "can't run 'uops' mode, sched model does not define a uops counter.");
return createUopsBenchmarkRunner(State);
}
return nullptr;
Index: llvm/tools/llvm-exegesis/lib/Latency.cpp
===================================================================
--- llvm/tools/llvm-exegesis/lib/Latency.cpp
+++ llvm/tools/llvm-exegesis/lib/Latency.cpp
@@ -186,8 +186,6 @@
constexpr const int NumMeasurements = 30;
int64_t MinValue = std::numeric_limits<int64_t>::max();
const char *CounterName = State.getPfmCounters().CycleCounter;
- if (!CounterName)
- report_fatal_error("sched model does not define a cycle counter");
for (size_t I = 0; I < NumMeasurements; ++I) {
auto ExpectedCounterValue = Executor.runAndMeasure(CounterName);
if (!ExpectedCounterValue)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71927.235409.patch
Type: text/x-patch
Size: 3022 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191227/623e5de8/attachment-0001.bin>
More information about the llvm-commits
mailing list