From a40fc575b8deb8b2246e01e1bd0cca66afd90c85 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 31 Jan 2024 14:36:47 -0500 Subject: [PATCH 1/2] exposing branch misses under macos --- benchmarks/performancecounters/apple_arm_events.h | 2 +- benchmarks/performancecounters/event_counter.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/benchmarks/performancecounters/apple_arm_events.h b/benchmarks/performancecounters/apple_arm_events.h index 088fa1728..608817277 100644 --- a/benchmarks/performancecounters/apple_arm_events.h +++ b/benchmarks/performancecounters/apple_arm_events.h @@ -1102,7 +1102,7 @@ struct AppleEvents { printf("%14s: %llu\n", alias->alias, val); }*/ return performance_counters{ - counters_0[counter_map[0]], counters_0[counter_map[3]], + counters_0[counter_map[0]], counters_0[counter_map[2]], counters_0[counter_map[2]], counters_0[counter_map[1]]}; } }; diff --git a/benchmarks/performancecounters/event_counter.h b/benchmarks/performancecounters/event_counter.h index 63e605690..1492b0181 100644 --- a/benchmarks/performancecounters/event_counter.h +++ b/benchmarks/performancecounters/event_counter.h @@ -35,6 +35,8 @@ struct event_count { enum event_counter_types { CPU_CYCLES, INSTRUCTIONS, + BRANCH_MISSES=2, + BRANCH=4 }; double elapsed_sec() const { @@ -49,7 +51,12 @@ struct event_count { double instructions() const { return static_cast(event_counts[INSTRUCTIONS]); } - + double branches() const { + return static_cast(event_counts[BRANCH]); + } + double branch_misses() const { + return static_cast(event_counts[BRANCH_MISSES]); + } event_count& operator=(const event_count& other) { this->elapsed = other.elapsed; this->event_counts = other.event_counts; From f5de1bc25382a96edd206cae219074c182bf1e98 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 31 Jan 2024 14:57:27 -0500 Subject: [PATCH 2/2] formatting --- benchmarks/performancecounters/event_counter.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/benchmarks/performancecounters/event_counter.h b/benchmarks/performancecounters/event_counter.h index 1492b0181..4a1e5eca3 100644 --- a/benchmarks/performancecounters/event_counter.h +++ b/benchmarks/performancecounters/event_counter.h @@ -35,8 +35,8 @@ struct event_count { enum event_counter_types { CPU_CYCLES, INSTRUCTIONS, - BRANCH_MISSES=2, - BRANCH=4 + BRANCH_MISSES = 2, + BRANCH = 4 }; double elapsed_sec() const { @@ -51,9 +51,7 @@ struct event_count { double instructions() const { return static_cast(event_counts[INSTRUCTIONS]); } - double branches() const { - return static_cast(event_counts[BRANCH]); - } + double branches() const { return static_cast(event_counts[BRANCH]); } double branch_misses() const { return static_cast(event_counts[BRANCH_MISSES]); }