diff options
| author | Miloš Stojanović <Milos.Stojanovic@rt-rk.com> | 2019-12-31 14:14:41 +0100 |
|---|---|---|
| committer | Miloš Stojanović <Milos.Stojanovic@rt-rk.com> | 2019-12-31 14:17:24 +0100 |
| commit | c7dc4734d23f45f576ba5af2aae5be9dfa2d3643 (patch) | |
| tree | 8ac0dc37838151e992078388ddc452c3fdd387d2 /llvm/tools/llvm-exegesis | |
| parent | b409f73e1fd8e498a2bff4208eeadf023959a0f7 (diff) | |
| download | bcm5719-llvm-c7dc4734d23f45f576ba5af2aae5be9dfa2d3643.tar.gz bcm5719-llvm-c7dc4734d23f45f576ba5af2aae5be9dfa2d3643.zip | |
[llvm-exegesis] Check counters before running
Check if the appropriate counters for the specified mode are defined on
the target. This is checked before any other work is done.
Differential Revision: https://reviews.llvm.org/D71927
Diffstat (limited to 'llvm/tools/llvm-exegesis')
| -rw-r--r-- | llvm/tools/llvm-exegesis/lib/Latency.cpp | 2 | ||||
| -rw-r--r-- | llvm/tools/llvm-exegesis/lib/Target.cpp | 11 | ||||
| -rw-r--r-- | llvm/tools/llvm-exegesis/llvm-exegesis.cpp | 13 |
3 files changed, 18 insertions, 8 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Latency.cpp b/llvm/tools/llvm-exegesis/lib/Latency.cpp index 7030658a460..9c1c087bb5e 100644 --- a/llvm/tools/llvm-exegesis/lib/Latency.cpp +++ b/llvm/tools/llvm-exegesis/lib/Latency.cpp @@ -186,8 +186,6 @@ Expected<std::vector<BenchmarkMeasure>> LatencyBenchmarkRunner::runMeasurements( 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) diff --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp index 57de7019be5..297419509c1 100644 --- a/llvm/tools/llvm-exegesis/lib/Target.cpp +++ b/llvm/tools/llvm-exegesis/lib/Target.cpp @@ -54,13 +54,24 @@ std::unique_ptr<SnippetGenerator> ExegesisTarget::createSnippetGenerator( std::unique_ptr<BenchmarkRunner> ExegesisTarget::createBenchmarkRunner(InstructionBenchmark::ModeE Mode, const LLVMState &State) const { + PfmCountersInfo PfmCounters = State.getPfmCounters(); switch (Mode) { case InstructionBenchmark::Unknown: return nullptr; case InstructionBenchmark::Latency: case InstructionBenchmark::InverseThroughput: + if (!PfmCounters.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 (!PfmCounters.UopsCounter && !PfmCounters.IssueCounters) + report_fatal_error("can't run 'uops' mode, sched model does not define " + "uops or issue counters."); return createUopsBenchmarkRunner(State); } return nullptr; diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp index a02d9997f76..c4574d38817 100644 --- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp +++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp @@ -242,6 +242,13 @@ void benchmarkMain() { 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 @@ void benchmarkMain() { 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"); |

