diff options
| author | Clement Courbet <courbet@google.com> | 2018-09-26 11:22:56 +0000 |
|---|---|---|
| committer | Clement Courbet <courbet@google.com> | 2018-09-26 11:22:56 +0000 |
| commit | 596c56ff9c744b227d189ab04ac90c47f77dfa68 (patch) | |
| tree | d65447af9bf8f167c4f8bcd880bb4614e2e9076f /llvm/tools/llvm-exegesis/lib/Uops.cpp | |
| parent | 5beaac433dac39034fa85ca6fa785e86d3260ffa (diff) | |
| download | bcm5719-llvm-596c56ff9c744b227d189ab04ac90c47f77dfa68.tar.gz bcm5719-llvm-596c56ff9c744b227d189ab04ac90c47f77dfa68.zip | |
[llvm-exegesis] Add support for measuring NumMicroOps.
Summary:
Example output for vzeroall:
---
mode: uops
key:
instructions:
- 'VZEROALL'
config: ''
register_initial_values:
cpu_name: haswell
llvm_triple: x86_64-unknown-linux-gnu
num_repetitions: 10000
measurements:
- { debug_string: HWPort0, value: 0.0006, per_snippet_value: 0.0006,
key: '3' }
- { debug_string: HWPort1, value: 0.0011, per_snippet_value: 0.0011,
key: '4' }
- { debug_string: HWPort2, value: 0.0004, per_snippet_value: 0.0004,
key: '5' }
- { debug_string: HWPort3, value: 0.0018, per_snippet_value: 0.0018,
key: '6' }
- { debug_string: HWPort4, value: 0.0002, per_snippet_value: 0.0002,
key: '7' }
- { debug_string: HWPort5, value: 1.0019, per_snippet_value: 1.0019,
key: '8' }
- { debug_string: HWPort6, value: 1.0033, per_snippet_value: 1.0033,
key: '9' }
- { debug_string: HWPort7, value: 0.0001, per_snippet_value: 0.0001,
key: '10' }
- { debug_string: NumMicroOps, value: 20.0069, per_snippet_value: 20.0069,
key: NumMicroOps }
error: ''
info: ''
assembled_snippet: C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C3
...
Reviewers: gchatelet
Subscribers: tschuett, RKSimon, andreadb, llvm-commits
Differential Revision: https://reviews.llvm.org/D52539
llvm-svn: 343094
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/Uops.cpp')
| -rw-r--r-- | llvm/tools/llvm-exegesis/lib/Uops.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Uops.cpp b/llvm/tools/llvm-exegesis/lib/Uops.cpp index dbecbfe5441..d7ac880d051 100644 --- a/llvm/tools/llvm-exegesis/lib/Uops.cpp +++ b/llvm/tools/llvm-exegesis/lib/Uops.cpp @@ -255,23 +255,18 @@ UopsBenchmarkRunner::runMeasurements(const ExecutableFunction &Function, ScratchSpace &Scratch) const { const auto &SchedModel = State.getSubtargetInfo().getSchedModel(); - std::vector<BenchmarkMeasure> Result; - for (unsigned ProcResIdx = 1; - ProcResIdx < SchedModel.getNumProcResourceKinds(); ++ProcResIdx) { - const char *const PfmCounters = SchedModel.getExtraProcessorInfo() - .PfmCounters.IssueCounters[ProcResIdx]; - if (!PfmCounters) - continue; + const auto RunMeasurement = [&Function, + &Scratch](const char *const Counters) { // We sum counts when there are several counters for a single ProcRes // (e.g. P23 on SandyBridge). int64_t CounterValue = 0; llvm::SmallVector<llvm::StringRef, 2> CounterNames; - llvm::StringRef(PfmCounters).split(CounterNames, ','); + llvm::StringRef(Counters).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)); + llvm::Twine("invalid perf event ").concat(Counters)); pfm::Counter Counter(UopPerfEvent); Scratch.clear(); Counter.start(); @@ -279,10 +274,24 @@ UopsBenchmarkRunner::runMeasurements(const ExecutableFunction &Function, Counter.stop(); CounterValue += Counter.read(); } - Result.push_back({llvm::itostr(ProcResIdx), - static_cast<double>(CounterValue), - static_cast<double>(CounterValue), - SchedModel.getProcResource(ProcResIdx)->Name}); + return CounterValue; + }; + + std::vector<BenchmarkMeasure> Result; + const auto& PfmCounters = SchedModel.getExtraProcessorInfo().PfmCounters; + // Uops per port. + for (unsigned ProcResIdx = 1; + ProcResIdx < SchedModel.getNumProcResourceKinds(); ++ProcResIdx) { + const char *const Counters = PfmCounters.IssueCounters[ProcResIdx]; + if (!Counters) + continue; + const double CounterValue = RunMeasurement(Counters); + Result.push_back(BenchmarkMeasure::Create(SchedModel.getProcResource(ProcResIdx)->Name, CounterValue)); + } + // NumMicroOps. + if (const char *const UopsCounter = PfmCounters.UopsCounter) { + const double CounterValue = RunMeasurement(UopsCounter); + Result.push_back(BenchmarkMeasure::Create("NumMicroOps", CounterValue)); } return Result; } |

