| 1 |
//===-- UopsBenchmarkRunner.cpp ---------------------------------*- C++ -*-===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
#include "UopsBenchmarkRunner.h" |
| 10 |
|
| 11 |
#include "Target.h" |
| 12 |
|
| 13 |
namespace llvm { |
| 14 |
namespace exegesis { |
| 15 |
|
| 16 |
UopsBenchmarkRunner::~UopsBenchmarkRunner() = default; |
| 17 |
|
| 18 |
Expected<std::vector<BenchmarkMeasure>> |
| 19 |
UopsBenchmarkRunner::runMeasurements(const FunctionExecutor &Executor) const { |
| 20 |
std::vector<BenchmarkMeasure> Result; |
| 21 |
const PfmCountersInfo &PCI = State.getPfmCounters(); |
| 22 |
// Uops per port. |
| 23 |
for (const auto *IssueCounter = PCI.IssueCounters, |
| 24 |
*IssueCounterEnd = PCI.IssueCounters + PCI.NumIssueCounters; |
| 25 |
IssueCounter != IssueCounterEnd; ++IssueCounter) { |
| 26 |
if (!IssueCounter->Counter) |
| 27 |
continue; |
| 28 |
auto ExpectedCounterValue = Executor.runAndMeasure(IssueCounter->Counter); |
| 29 |
if (!ExpectedCounterValue) |
| 30 |
return ExpectedCounterValue.takeError(); |
| 31 |
Result.push_back(BenchmarkMeasure::Create(IssueCounter->ProcResName, |
| 32 |
*ExpectedCounterValue)); |
| 33 |
} |
| 34 |
// NumMicroOps. |
| 35 |
if (const char *const UopsCounter = PCI.UopsCounter) { |
| 36 |
auto ExpectedCounterValue = Executor.runAndMeasure(UopsCounter); |
| 37 |
if (!ExpectedCounterValue) |
| 38 |
return ExpectedCounterValue.takeError(); |
| 39 |
Result.push_back( |
| 40 |
BenchmarkMeasure::Create("NumMicroOps", *ExpectedCounterValue)); |
| 41 |
} |
| 42 |
return std::move(Result); |
| 43 |
} |
| 44 |
|
| 45 |
} // namespace exegesis |
| 46 |
} // namespace llvm |