From 49357738632df7938894cb003ef1775aa127de5e Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 14 Oct 2024 15:16:22 +0200 Subject: [PATCH] Use the same HW performance counter as on Genode. --- src/benchmark/perf.cpp | 10 +++++----- src/benchmark/perf.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/benchmark/perf.cpp b/src/benchmark/perf.cpp index 4841dbe..21df280 100644 --- a/src/benchmark/perf.cpp +++ b/src/benchmark/perf.cpp @@ -6,23 +6,23 @@ using namespace benchmark; * Counter "Instructions Retired" * 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, - PERF_COUNT_HW_CACHE_L1D | (PERF_COUNT_HW_CACHE_OP_READ << 8) | +[[maybe_unused]] PerfCounter Perf::L1_MISSES = {"l1i-miss", PERF_TYPE_HW_CACHE, + PERF_COUNT_HW_CACHE_L1I | (PERF_COUNT_HW_CACHE_OP_READ << 8) | (PERF_COUNT_HW_CACHE_RESULT_MISS << 16)}; /** * Counter "LLC Misses" * 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_STORE_MISSES = {"dtlb-store-miss", PERF_TYPE_HW_CACHE, 0x10103}; diff --git a/src/benchmark/perf.h b/src/benchmark/perf.h index 2ecf278..94d87ad 100644 --- a/src/benchmark/perf.h +++ b/src/benchmark/perf.h @@ -35,7 +35,7 @@ public: _perf_event_attribute.size = sizeof(perf_event_attr); _perf_event_attribute.config = event_id; _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_hv = false; _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(_data.time_enabled - _prev.time_enabled) / static_cast(_data.time_running - _prev.time_running); - return static_cast(_data.value - _prev.value) * multiplexing_correction; + return static_cast(_data.value - _prev.value); } [[nodiscard]] const std::string &name() const { return _name; }