summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/lib/Uops.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/Uops.cpp')
-rw-r--r--llvm/tools/llvm-exegesis/lib/Uops.cpp43
1 files changed, 12 insertions, 31 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Uops.cpp b/llvm/tools/llvm-exegesis/lib/Uops.cpp
index d8065adbdb2..50be707feb2 100644
--- a/llvm/tools/llvm-exegesis/lib/Uops.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Uops.cpp
@@ -12,7 +12,6 @@
#include "Assembler.h"
#include "BenchmarkRunner.h"
#include "MCInstrDescView.h"
-#include "PerfHelper.h"
#include "Target.h"
// FIXME: Load constants into registers (e.g. with fld1) to not break
@@ -221,33 +220,10 @@ UopsSnippetGenerator::generateCodeTemplates(const Instruction &Instr) const {
return getSingleton(std::move(CT));
}
-std::vector<BenchmarkMeasure>
-UopsBenchmarkRunner::runMeasurements(const ExecutableFunction &Function,
- ScratchSpace &Scratch) const {
+llvm::Expected<std::vector<BenchmarkMeasure>>
+UopsBenchmarkRunner::runMeasurements(const FunctionExecutor &Executor) const {
const auto &SchedModel = State.getSubtargetInfo().getSchedModel();
- 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(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(Counters));
- pfm::Counter Counter(UopPerfEvent);
- Scratch.clear();
- Counter.start();
- Function(Scratch.ptr());
- Counter.stop();
- CounterValue += Counter.read();
- }
- return CounterValue;
- };
-
std::vector<BenchmarkMeasure> Result;
const auto &PfmCounters = SchedModel.getExtraProcessorInfo().PfmCounters;
// Uops per port.
@@ -256,16 +232,21 @@ UopsBenchmarkRunner::runMeasurements(const ExecutableFunction &Function,
const char *const Counters = PfmCounters.IssueCounters[ProcResIdx];
if (!Counters)
continue;
- const double CounterValue = RunMeasurement(Counters);
+ auto ExpectedCounterValue = Executor.runAndMeasure(Counters);
+ if (!ExpectedCounterValue)
+ return ExpectedCounterValue.takeError();
Result.push_back(BenchmarkMeasure::Create(
- SchedModel.getProcResource(ProcResIdx)->Name, CounterValue));
+ SchedModel.getProcResource(ProcResIdx)->Name, *ExpectedCounterValue));
}
// NumMicroOps.
if (const char *const UopsCounter = PfmCounters.UopsCounter) {
- const double CounterValue = RunMeasurement(UopsCounter);
- Result.push_back(BenchmarkMeasure::Create("NumMicroOps", CounterValue));
+ auto ExpectedCounterValue = Executor.runAndMeasure(UopsCounter);
+ if (!ExpectedCounterValue)
+ return ExpectedCounterValue.takeError();
+ Result.push_back(
+ BenchmarkMeasure::Create("NumMicroOps", *ExpectedCounterValue));
}
- return Result;
+ return std::move(Result);
}
constexpr const size_t UopsSnippetGenerator::kMinNumDifferentAddresses;
OpenPOWER on IntegriCloud