summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-exegesis/lib/Latency.cpp2
-rw-r--r--llvm/tools/llvm-exegesis/lib/Target.cpp11
-rw-r--r--llvm/tools/llvm-exegesis/llvm-exegesis.cpp13
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");
OpenPOWER on IntegriCloud