[lld] [clang] [clang-tools-extra] [llvm] [llvm-exegesis] Add support for validation counters (PR #76653)
Clement Courbet via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 11 01:32:10 PST 2024
================
@@ -112,9 +116,11 @@ class Counter {
PerfEvent Event;
int FileDescriptor = -1;
bool IsDummyEvent;
+ std::vector<PerfEvent> ValidationEvents;
----------------
legrosbuffle wrote:
OK, let's rename `Counter` to `CounterGroup`, but let's at least create a (private) abstraction for an event and attached FD, to avoid the aligned arrays code duplication in `Counter::initRealEvent`:
```
struct ConfiguredEvent {
llvm::Error init(const pid_t ProcessID, const int GroupFd) {
constexpr int Cpu = -1; // measure any processor.
constexpr int GroupFd = -1; // no grouping of counters.
constexpr uint32_t Flags = 0;
perf_event_attr AttrCopy = *Event.attribute();
FileDescriptor = perf_event_open(&AttrCopy, ProcessID, Cpu, GroupFd, Flags);
if (FileDescriptor == -1) {
return ...;
}
};
PerfEvent Event;
int FileDescriptor = -1;
};
// The main event, configured as an ungrouped event.
ConfiguredEvent MainEvent;
bool IsDummyEvent;
// A set of optional validation events grouped into the file descriptor for
// `MainEvent` using `PERF_IOC_FLAG_GROUP`.
std::vector<ConfiguredEvent> ValidationEvents;
```
https://github.com/llvm/llvm-project/pull/76653
More information about the cfe-commits
mailing list