summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2025-03-11 00:15:45 +0100
committerDennis Kobert <dennis@kobert.dev>2025-03-25 15:52:04 +0100
commit7f49625ee1cfadaf523da9e2c247fded90d82665 (patch)
tree290fb6c6b84c817010b915dcf058371ebb831803 /src
parent776dee32aca73ded5c0720afbe25ef2aae7b67f3 (diff)
Select counters
Diffstat (limited to 'src')
-rw-r--r--src/benchmark.rs252
1 files changed, 50 insertions, 202 deletions
diff --git a/src/benchmark.rs b/src/benchmark.rs
index 606f29b..6368fa8 100644
--- a/src/benchmark.rs
+++ b/src/benchmark.rs
@@ -17,8 +17,8 @@ use std::thread;
use std::time::{Duration, Instant};
const SLICE_US: u64 = 50000;
-const LOG_INTERVAL_MS: u64 = 10; // Log every 1 second
- // const RESHUFFLE_ROUNDS: usize = 5; // Number of rounds before reshuffling counters
+const LOG_INTERVAL_MS: u64 = 5; // Log every 1 second
+ // const RESHUFFLE_ROUNDS: usize = 5; // Number of rounds before reshuffling counters
const RESHUFFLE_ROUNDS: usize = 1; // Number of rounds before reshuffling counters
const MAX_COUNTERS_AT_ONCE: usize = 5;
@@ -379,284 +379,132 @@ fn define_available_events() -> Vec<(String, Event)> {
"cpu_cycles".to_string(),
Event::Hardware(Hardware::CPU_CYCLES),
),
- (
- "instructions".to_string(),
- Event::Hardware(Hardware::INSTRUCTIONS),
- ),
+ // (
+ // "instructions".to_string(),
+ // Event::Hardware(Hardware::INSTRUCTIONS),
+ // ),
(
"cache_references".to_string(),
Event::Hardware(Hardware::CACHE_REFERENCES),
),
- (
- "cache_misses".to_string(),
- Event::Hardware(Hardware::CACHE_MISSES),
- ),
- (
- "branch_instructions".to_string(),
- Event::Hardware(Hardware::BRANCH_INSTRUCTIONS),
- ),
- (
- "branch_misses".to_string(),
- Event::Hardware(Hardware::BRANCH_MISSES),
- ),
// (
- // "bus_cycles".to_string(),
- // Event::Hardware(Hardware::BUS_CYCLES),
+ // "cache_misses".to_string(),
+ // Event::Hardware(Hardware::CACHE_MISSES),
// ),
// (
- // "stalled_cycles_frontend".to_string(),
- // Event::Hardware(Hardware::STALLED_CYCLES_FRONTEND),
- // ),
- // (
- // "stalled_cycles_backend".to_string(),
- // Event::Hardware(Hardware::STALLED_CYCLES_BACKEND),
+ // "branch_instructions".to_string(),
+ // Event::Hardware(Hardware::BRANCH_INSTRUCTIONS),
// ),
(
- "ref_cpu_cycles".to_string(),
- Event::Hardware(Hardware::REF_CPU_CYCLES),
- ),
- ]);
-
- // Software events
- events.extend([
- (
- "sw_cpu_clock".to_string(),
- Event::Software(Software::CPU_CLOCK),
- ),
- (
- "sw_task_clock".to_string(),
- Event::Software(Software::TASK_CLOCK),
- ),
- (
- "sw_page_faults".to_string(),
- Event::Software(Software::PAGE_FAULTS),
- ),
- (
- "sw_context_switches".to_string(),
- Event::Software(Software::CONTEXT_SWITCHES),
- ),
- (
- "sw_cpu_migrations".to_string(),
- Event::Software(Software::CPU_MIGRATIONS),
- ),
- (
- "sw_page_faults_min".to_string(),
- Event::Software(Software::PAGE_FAULTS_MIN),
- ),
- (
- "sw_page_faults_maj".to_string(),
- Event::Software(Software::PAGE_FAULTS_MAJ),
- ),
- (
- "sw_alignment_faults".to_string(),
- Event::Software(Software::ALIGNMENT_FAULTS),
+ "branch_misses".to_string(),
+ Event::Hardware(Hardware::BRANCH_MISSES),
),
(
- "sw_emulation_faults".to_string(),
- Event::Software(Software::EMULATION_FAULTS),
+ "ref_cpu_cycles".to_string(),
+ Event::Hardware(Hardware::REF_CPU_CYCLES),
),
]);
// L1 Data Cache events
events.extend([
- (
- "l1d_read_access".to_string(),
- Event::Cache(Cache {
- which: WhichCache::L1D,
- operation: CacheOp::READ,
- result: CacheResult::ACCESS,
- }),
- ),
- (
- "l1d_read_miss".to_string(),
- Event::Cache(Cache {
- which: WhichCache::L1D,
- operation: CacheOp::READ,
- result: CacheResult::MISS,
- }),
- ),
- // (
- // "l1d_write_access".to_string(),
- // Event::Cache(Cache {
- // which: WhichCache::L1D,
- // operation: CacheOp::WRITE,
- // result: CacheResult::ACCESS,
- // }),
- // ),
- // (
- // "l1d_write_miss".to_string(),
- // Event::Cache(Cache {
- // which: WhichCache::L1D,
- // operation: CacheOp::WRITE,
- // result: CacheResult::MISS,
- // }),
- // ),
// (
- // "l1d_prefetch_access".to_string(),
+ // "l1d_read_access".to_string(),
// Event::Cache(Cache {
// which: WhichCache::L1D,
- // operation: CacheOp::PREFETCH,
+ // operation: CacheOp::READ,
// result: CacheResult::ACCESS,
// }),
// ),
- // (
- // "l1d_prefetch_miss".to_string(),
- // Event::Cache(Cache {
- // which: WhichCache::L1D,
- // operation: CacheOp::PREFETCH,
- // result: CacheResult::MISS,
- // }),
- // ),
- ]);
-
- // L1 Instruction Cache events
- events.extend([
(
- "l1i_read_access".to_string(),
- Event::Cache(Cache {
- which: WhichCache::L1I,
- operation: CacheOp::READ,
- result: CacheResult::ACCESS,
- }),
- ),
- (
- "l1i_read_miss".to_string(),
+ "l1d_read_miss".to_string(),
Event::Cache(Cache {
- which: WhichCache::L1I,
+ which: WhichCache::L1D,
operation: CacheOp::READ,
result: CacheResult::MISS,
}),
),
]);
- // Last Level Cache events
+ // L1 Instruction Cache events
events.extend([
// (
- // "llc_read_access".to_string(),
+ // "l1i_read_access".to_string(),
// Event::Cache(Cache {
- // which: WhichCache::LL,
+ // which: WhichCache::L1I,
// operation: CacheOp::READ,
// result: CacheResult::ACCESS,
// }),
// ),
// (
- // "llc_read_miss".to_string(),
+ // "l1i_read_miss".to_string(),
// Event::Cache(Cache {
- // which: WhichCache::LL,
+ // which: WhichCache::L1I,
// operation: CacheOp::READ,
// result: CacheResult::MISS,
// }),
// ),
+ ]);
+
+ // Data TLB events
+ events.extend([
// (
- // "llc_write_access".to_string(),
+ // "dtlb_read_access".to_string(),
// Event::Cache(Cache {
- // which: WhichCache::LL,
- // operation: CacheOp::WRITE,
+ // which: WhichCache::DTLB,
+ // operation: CacheOp::READ,
// result: CacheResult::ACCESS,
// }),
// ),
// (
- // "llc_write_miss".to_string(),
+ // "dtlb_read_miss".to_string(),
// Event::Cache(Cache {
- // which: WhichCache::LL,
- // operation: CacheOp::WRITE,
+ // which: WhichCache::DTLB,
+ // operation: CacheOp::READ,
// result: CacheResult::MISS,
// }),
// ),
+ ]);
+
+ // Instruction TLB events
+ events.extend([
// (
- // "llc_prefetch_access".to_string(),
+ // "itlb_read_access".to_string(),
// Event::Cache(Cache {
- // which: WhichCache::LL,
- // operation: CacheOp::PREFETCH,
+ // which: WhichCache::ITLB,
+ // operation: CacheOp::READ,
// result: CacheResult::ACCESS,
// }),
// ),
// (
- // "llc_prefetch_miss".to_string(),
+ // "itlb_read_miss".to_string(),
// Event::Cache(Cache {
- // which: WhichCache::LL,
- // operation: CacheOp::PREFETCH,
+ // which: WhichCache::ITLB,
+ // operation: CacheOp::READ,
// result: CacheResult::MISS,
// }),
// ),
]);
- // Data TLB events
+ // Branch Prediction Unit events
events.extend([
- (
- "dtlb_read_access".to_string(),
- Event::Cache(Cache {
- which: WhichCache::DTLB,
- operation: CacheOp::READ,
- result: CacheResult::ACCESS,
- }),
- ),
- (
- "dtlb_read_miss".to_string(),
- Event::Cache(Cache {
- which: WhichCache::DTLB,
- operation: CacheOp::READ,
- result: CacheResult::MISS,
- }),
- ),
// (
- // "dtlb_write_access".to_string(),
+ // "bpu_read_access".to_string(),
// Event::Cache(Cache {
- // which: WhichCache::DTLB,
- // operation: CacheOp::WRITE,
+ // which: WhichCache::BPU,
+ // operation: CacheOp::READ,
// result: CacheResult::ACCESS,
// }),
// ),
// (
- // "dtlb_write_miss".to_string(),
+ // "bpu_read_miss".to_string(),
// Event::Cache(Cache {
- // which: WhichCache::DTLB,
- // operation: CacheOp::WRITE,
+ // which: WhichCache::BPU,
+ // operation: CacheOp::READ,
// result: CacheResult::MISS,
// }),
// ),
]);
- // Instruction TLB events
- events.extend([
- (
- "itlb_read_access".to_string(),
- Event::Cache(Cache {
- which: WhichCache::ITLB,
- operation: CacheOp::READ,
- result: CacheResult::ACCESS,
- }),
- ),
- (
- "itlb_read_miss".to_string(),
- Event::Cache(Cache {
- which: WhichCache::ITLB,
- operation: CacheOp::READ,
- result: CacheResult::MISS,
- }),
- ),
- ]);
-
- // Branch Prediction Unit events
- events.extend([
- (
- "bpu_read_access".to_string(),
- Event::Cache(Cache {
- which: WhichCache::BPU,
- operation: CacheOp::READ,
- result: CacheResult::ACCESS,
- }),
- ),
- (
- "bpu_read_miss".to_string(),
- Event::Cache(Cache {
- which: WhichCache::BPU,
- operation: CacheOp::READ,
- result: CacheResult::MISS,
- }),
- ),
- ]);
-
// Sort events by name for consistent ordering
events.sort_unstable_by_key(|(name, _)| name.clone());