[llvm] r334502 - [llvm-exegesis] Sum counter values when several counters are specified for a ProcRes.

Clement Courbet via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 12 06:28:37 PDT 2018


Author: courbet
Date: Tue Jun 12 06:28:37 2018
New Revision: 334502

URL: http://llvm.org/viewvc/llvm-project?rev=334502&view=rev
Log:
[llvm-exegesis] Sum counter values when several counters are specified for a ProcRes.

Summary: This allows handling memory ports on SNB.

Reviewers: gchatelet

Subscribers: tschuett, llvm-commits

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

Modified:
    llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp

Modified: llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp?rev=334502&r1=334501&r2=334502&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/Uops.cpp Tue Jun 12 06:28:37 2018
@@ -227,18 +227,24 @@ UopsBenchmarkRunner::runMeasurements(con
                                         .PfmCounters.IssueCounters[ProcResIdx];
     if (!PfmCounters)
       continue;
-    // FIXME: Sum results when there are several counters for a single ProcRes
+    // We sum counts when there are several counters for a single ProcRes
     // (e.g. P23 on SandyBridge).
-    pfm::PerfEvent UopPerfEvent(PfmCounters);
-    if (!UopPerfEvent.valid())
-      llvm::report_fatal_error(
-          llvm::Twine("invalid perf event ").concat(PfmCounters));
-    pfm::Counter Counter(UopPerfEvent);
-    Counter.start();
-    Function();
-    Counter.stop();
+    int64_t CounterValue = 0;
+    llvm::SmallVector<llvm::StringRef, 2> CounterNames;
+    llvm::StringRef(PfmCounters).split(CounterNames, ',');
+    for (const auto& CounterName : CounterNames) {
+      pfm::PerfEvent UopPerfEvent(CounterName);
+      if (!UopPerfEvent.valid())
+        llvm::report_fatal_error(
+            llvm::Twine("invalid perf event ").concat(PfmCounters));
+      pfm::Counter Counter(UopPerfEvent);
+      Counter.start();
+      Function();
+      Counter.stop();
+      CounterValue += Counter.read();
+    }
     Result.push_back({llvm::itostr(ProcResIdx),
-                      static_cast<double>(Counter.read()) / NumRepetitions,
+                      static_cast<double>(CounterValue) / NumRepetitions,
                       SchedModel.getProcResource(ProcResIdx)->Name});
   }
   return Result;




More information about the llvm-commits mailing list