[llvm] r336099 - [llvm-exegesis] Delegate the decision of cycle counter name to the target

John Brawn via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 2 06:14:50 PDT 2018


Author: john.brawn
Date: Mon Jul  2 06:14:49 2018
New Revision: 336099

URL: http://llvm.org/viewvc/llvm-project?rev=336099&view=rev
Log:
[llvm-exegesis] Delegate the decision of cycle counter name to the target

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.

Differential Revision: https://reviews.llvm.org/D48779

Modified:
    llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp
    llvm/trunk/tools/llvm-exegesis/lib/Latency.h
    llvm/trunk/tools/llvm-exegesis/llvm-exegesis.cpp

Modified: llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp?rev=336099&r1=336098&r2=336099&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/Latency.cpp Mon Jul  2 06:14:49 2018
@@ -94,6 +94,18 @@ LatencyBenchmarkRunner::generatePrototyp
   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(
   // 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");

Modified: llvm/trunk/tools/llvm-exegesis/lib/Latency.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/Latency.h?rev=336099&r1=336098&r2=336099&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Latency.h (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/Latency.h Mon Jul  2 06:14:49 2018
@@ -38,6 +38,8 @@ private:
   std::vector<BenchmarkMeasure>
   runMeasurements(const ExecutableFunction &EF,
                   const unsigned NumRepetitions) const override;
+
+  virtual const char *getCounterName() const;
 };
 
 } // namespace exegesis

Modified: llvm/trunk/tools/llvm-exegesis/llvm-exegesis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/llvm-exegesis.cpp?rev=336099&r1=336098&r2=336099&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/llvm-exegesis.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/llvm-exegesis.cpp Mon Jul  2 06:14:49 2018
@@ -140,10 +140,6 @@ void benchmarkMain() {
     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) {




More information about the llvm-commits mailing list