Use the same HW performance counter as on Genode.

This commit is contained in:
Michael Mueller
2024-10-14 15:16:22 +02:00
parent 2b868f7156
commit 4935773863
2 changed files with 7 additions and 7 deletions

View File

@@ -6,23 +6,23 @@ using namespace benchmark;
* Counter "Instructions Retired" * Counter "Instructions Retired"
* Counts when the last uop of an instruction retires. * Counts when the last uop of an instruction retires.
*/ */
[[maybe_unused]] PerfCounter Perf::INSTRUCTIONS = {"instr", PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS}; [[maybe_unused]] PerfCounter Perf::INSTRUCTIONS = {"instr", 4, 192};
/** /**
*/ */
[[maybe_unused]] PerfCounter Perf::CYCLES = {"cycles", PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES}; [[maybe_unused]] PerfCounter Perf::CYCLES = {"cycles", 4, 0x76};
/** /**
*/ */
[[maybe_unused]] PerfCounter Perf::L1_MISSES = {"l1-miss", PERF_TYPE_HW_CACHE, [[maybe_unused]] PerfCounter Perf::L1_MISSES = {"l1i-miss", PERF_TYPE_HW_CACHE,
PERF_COUNT_HW_CACHE_L1D | (PERF_COUNT_HW_CACHE_OP_READ << 8) | PERF_COUNT_HW_CACHE_L1I | (PERF_COUNT_HW_CACHE_OP_READ << 8) |
(PERF_COUNT_HW_CACHE_RESULT_MISS << 16)}; (PERF_COUNT_HW_CACHE_RESULT_MISS << 16)};
/** /**
* Counter "LLC Misses" * Counter "LLC Misses"
* Accesses to the LLC in which the data is not present(miss). * Accesses to the LLC in which the data is not present(miss).
*/ */
[[maybe_unused]] PerfCounter Perf::LLC_MISSES = {"llc-miss", PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES}; [[maybe_unused]] PerfCounter Perf::LLC_MISSES = {"l1d-miss", PERF_TYPE_HW_CACHE, PERF_COUNT_HW_CACHE_L1D | (PERF_COUNT_HW_CACHE_OP_READ << 8) | (PERF_COUNT_HW_CACHE_RESULT_MISS << 16)};
[[maybe_unused]] PerfCounter Perf::DTLB_READ_MISSES = {"dtlb-read-miss", PERF_TYPE_HW_CACHE, 0x10003}; [[maybe_unused]] PerfCounter Perf::DTLB_READ_MISSES = {"dtlb-read-miss", PERF_TYPE_HW_CACHE, 0x10003};
[[maybe_unused]] PerfCounter Perf::DTLB_STORE_MISSES = {"dtlb-store-miss", PERF_TYPE_HW_CACHE, 0x10103}; [[maybe_unused]] PerfCounter Perf::DTLB_STORE_MISSES = {"dtlb-store-miss", PERF_TYPE_HW_CACHE, 0x10103};

View File

@@ -35,7 +35,7 @@ public:
_perf_event_attribute.size = sizeof(perf_event_attr); _perf_event_attribute.size = sizeof(perf_event_attr);
_perf_event_attribute.config = event_id; _perf_event_attribute.config = event_id;
_perf_event_attribute.disabled = true; _perf_event_attribute.disabled = true;
_perf_event_attribute.inherit = 1; _perf_event_attribute.inherit = 0;
_perf_event_attribute.exclude_kernel = false; _perf_event_attribute.exclude_kernel = false;
_perf_event_attribute.exclude_hv = false; _perf_event_attribute.exclude_hv = false;
_perf_event_attribute.read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING; _perf_event_attribute.read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING;
@@ -67,7 +67,7 @@ public:
{ {
const auto multiplexing_correction = static_cast<double>(_data.time_enabled - _prev.time_enabled) / const auto multiplexing_correction = static_cast<double>(_data.time_enabled - _prev.time_enabled) /
static_cast<double>(_data.time_running - _prev.time_running); static_cast<double>(_data.time_running - _prev.time_running);
return static_cast<double>(_data.value - _prev.value) * multiplexing_correction; return static_cast<double>(_data.value - _prev.value);
} }
[[nodiscard]] const std::string &name() const { return _name; } [[nodiscard]] const std::string &name() const { return _name; }