1 //===-- UopsBenchmarkRunner.cpp ---------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "UopsBenchmarkRunner.h"
16 UopsBenchmarkRunner::~UopsBenchmarkRunner() = default;
18 Expected
<std::vector
<BenchmarkMeasure
>>
19 UopsBenchmarkRunner::runMeasurements(const FunctionExecutor
&Executor
) const {
20 std::vector
<BenchmarkMeasure
> Result
;
21 const PfmCountersInfo
&PCI
= State
.getPfmCounters();
23 SmallVector
<const char *> ValCountersToRun
;
24 Error ValCounterErr
= getValidationCountersToRun(ValCountersToRun
);
26 return std::move(ValCounterErr
);
29 for (const auto *IssueCounter
= PCI
.IssueCounters
,
30 *IssueCounterEnd
= PCI
.IssueCounters
+ PCI
.NumIssueCounters
;
31 IssueCounter
!= IssueCounterEnd
; ++IssueCounter
) {
32 SmallVector
<int64_t> ValCounterPortValues(ValCountersToRun
.size(), -1);
33 if (!IssueCounter
->Counter
)
35 auto ExpectedCounterValue
= Executor
.runAndSample(
36 IssueCounter
->Counter
, ValCountersToRun
, ValCounterPortValues
);
37 if (!ExpectedCounterValue
)
38 return ExpectedCounterValue
.takeError();
40 std::map
<ValidationEvent
, int64_t> ValidationInfo
;
41 for (size_t I
= 0; I
< ValidationCounters
.size(); ++I
)
42 ValidationInfo
[ValidationCounters
[I
]] = ValCounterPortValues
[I
];
44 Result
.push_back(BenchmarkMeasure::Create(
45 IssueCounter
->ProcResName
, (*ExpectedCounterValue
)[0], ValidationInfo
));
48 if (const char *const UopsCounter
= PCI
.UopsCounter
) {
49 SmallVector
<int64_t> ValCounterUopsValues(ValCountersToRun
.size(), -1);
50 auto ExpectedCounterValue
= Executor
.runAndSample(
51 UopsCounter
, ValCountersToRun
, ValCounterUopsValues
);
52 if (!ExpectedCounterValue
)
53 return ExpectedCounterValue
.takeError();
55 std::map
<ValidationEvent
, int64_t> ValidationInfo
;
56 for (size_t I
= 0; I
< ValidationCounters
.size(); ++I
)
57 ValidationInfo
[ValidationCounters
[I
]] = ValCounterUopsValues
[I
];
59 Result
.push_back(BenchmarkMeasure::Create(
60 "NumMicroOps", (*ExpectedCounterValue
)[0], ValidationInfo
));
62 return std::move(Result
);
65 } // namespace exegesis