From 4fcee8af8bc78d0489f227a5116cc161a3da4deb Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Tue, 12 Jun 2018 13:28:37 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334502 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-exegesis/lib/Uops.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tools/llvm-exegesis/lib/Uops.cpp b/tools/llvm-exegesis/lib/Uops.cpp index be74a921967..ae9288133ad 100644 --- a/tools/llvm-exegesis/lib/Uops.cpp +++ b/tools/llvm-exegesis/lib/Uops.cpp @@ -227,18 +227,24 @@ UopsBenchmarkRunner::runMeasurements(const ExecutableFunction &Function, .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 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(Counter.read()) / NumRepetitions, + static_cast(CounterValue) / NumRepetitions, SchedModel.getProcResource(ProcResIdx)->Name}); } return Result; -- 2.11.0