summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-exegesis/lib/BenchmarkResult.h5
-rw-r--r--llvm/tools/llvm-exegesis/lib/Latency.cpp3
-rw-r--r--llvm/tools/llvm-exegesis/lib/Uops.cpp35
3 files changed, 28 insertions, 15 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index e4e29ef1523..0fcf4e9fe6d 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
@@ -41,6 +41,10 @@ struct InstructionBenchmarkKey {
};
struct BenchmarkMeasure {
+ // A helper to create an unscaled BenchmarkMeasure.
+ static BenchmarkMeasure Create(std::string Key, double Value) {
+ return {Key, Value, Value, Key};
+ }
std::string Key;
// This is the per-instruction value, i.e. measured quantity scaled per
// instruction.
@@ -48,6 +52,7 @@ struct BenchmarkMeasure {
// This is the per-snippet value, i.e. measured quantity for one repetition of
// the whole snippet.
double PerSnippetValue;
+ // FIXME: remove, use `Key` instead.
std::string DebugString;
};
diff --git a/llvm/tools/llvm-exegesis/lib/Latency.cpp b/llvm/tools/llvm-exegesis/lib/Latency.cpp
index 3c402c4700c..9eeb2644f06 100644
--- a/llvm/tools/llvm-exegesis/lib/Latency.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Latency.cpp
@@ -130,8 +130,7 @@ LatencyBenchmarkRunner::runMeasurements(const ExecutableFunction &Function,
if (Value < MinLatency)
MinLatency = Value;
}
- return {{"latency", static_cast<double>(MinLatency),
- static_cast<double>(MinLatency), ""}};
+ return {BenchmarkMeasure::Create("latency", MinLatency)};
}
} // namespace exegesis
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;
}
OpenPOWER on IntegriCloud