UopsBenchmarkRunner.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #include "UopsBenchmarkRunner.h"
  9. #include "Target.h"
  10. namespace llvm {
  11. namespace exegesis {
  12. UopsBenchmarkRunner::~UopsBenchmarkRunner() = default;
  13. Expected<std::vector<BenchmarkMeasure>>
  14. UopsBenchmarkRunner::runMeasurements(const FunctionExecutor &Executor) const {
  15. std::vector<BenchmarkMeasure> Result;
  16. const PfmCountersInfo &PCI = State.getPfmCounters();
  17. // Uops per port.
  18. for (const auto *IssueCounter = PCI.IssueCounters,
  19. *IssueCounterEnd = PCI.IssueCounters + PCI.NumIssueCounters;
  20. IssueCounter != IssueCounterEnd; ++IssueCounter) {
  21. if (!IssueCounter->Counter)
  22. continue;
  23. auto ExpectedCounterValue = Executor.runAndMeasure(IssueCounter->Counter);
  24. if (!ExpectedCounterValue)
  25. return ExpectedCounterValue.takeError();
  26. Result.push_back(BenchmarkMeasure::Create(IssueCounter->ProcResName,
  27. *ExpectedCounterValue));
  28. }
  29. // NumMicroOps.
  30. if (const char *const UopsCounter = PCI.UopsCounter) {
  31. auto ExpectedCounterValue = Executor.runAndMeasure(UopsCounter);
  32. if (!ExpectedCounterValue)
  33. return ExpectedCounterValue.takeError();
  34. Result.push_back(
  35. BenchmarkMeasure::Create("NumMicroOps", *ExpectedCounterValue));
  36. }
  37. return std::move(Result);
  38. }
  39. } // namespace exegesis
  40. } // namespace llvm