From 5c6c607c8fc3b65c0fa6a3b6e4fdd58bd861dd53 Mon Sep 17 00:00:00 2001 From: guillaume didier Date: Fri, 20 Mar 2020 16:09:03 +0100 Subject: [PATCH] Add some warm up and fix some output related issues + make the cpuid leaf 4 availale as an util --- cache_utils/src/bin/cache_info.rs | 5 +++++ cache_utils/src/cache_info.rs | 6 +++--- cache_utils/src/calibration.rs | 14 ++++++++------ cache_utils/src/main.rs | 2 ++ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/cache_utils/src/bin/cache_info.rs b/cache_utils/src/bin/cache_info.rs index e69de29..b8e30dc 100644 --- a/cache_utils/src/bin/cache_info.rs +++ b/cache_utils/src/bin/cache_info.rs @@ -0,0 +1,5 @@ +use cache_utils::cache_info::get_cache_info; + +pub fn main() { + println!("{:#?}", get_cache_info()); +} diff --git a/cache_utils/src/cache_info.rs b/cache_utils/src/cache_info.rs index 4261efa..8baa06a 100644 --- a/cache_utils/src/cache_info.rs +++ b/cache_utils/src/cache_info.rs @@ -36,7 +36,7 @@ pub struct CacheInfo { pub level: u8, pub self_init: bool, pub fully_assoc: bool, - pub core_for_cache: u16, + pub maxID_for_cache: u16, pub core_in_package: u16, pub cache_line_size: u16, pub physical_line_partition: u16, @@ -64,7 +64,7 @@ impl CacheInfo { let level: u8 = (cr.eax >> 5 & 0x7) as u8; let self_init = (cr.eax >> 8 & 0x1) != 0; let fully_assoc = (cr.eax >> 9 & 0x1) != 0; - let core_for_cache = (cr.eax >> 14 & 0xfff) as u16 + 1; + let maxID_for_cache = (cr.eax >> 14 & 0xfff) as u16 + 1; let core_in_package = (cr.eax >> 26 & 0x3f) as u16 + 1; let cache_line_size = (cr.ebx & 0xfff) as u16 + 1; let physical_line_partition = (cr.ebx >> 12 & 0x3ff) as u16 + 1; @@ -79,7 +79,7 @@ impl CacheInfo { level, self_init, fully_assoc, - core_for_cache, + maxID_for_cache, core_in_package, cache_line_size, physical_line_partition, diff --git a/cache_utils/src/calibration.rs b/cache_utils/src/calibration.rs index 41a1893..f48283e 100644 --- a/cache_utils/src/calibration.rs +++ b/cache_utils/src/calibration.rs @@ -12,7 +12,7 @@ pub enum Verbosity { } extern crate alloc; -use crate::calibration::Verbosity::{Debug, RawResult, Thresholds}; +use crate::calibration::Verbosity::{Debug, NoOutput, RawResult, Thresholds}; use alloc::vec; use alloc::vec::Vec; use core::cmp::min; @@ -157,8 +157,9 @@ pub fn calibrate_flush( cache_line_size: usize, verbose_level: Verbosity, ) -> Vec<(usize, Vec<(usize, usize)>, usize)> { - println!("Calibrating cflush..."); - + if verbose_level > NoOutput { + println!("Calibrating cflush..."); + } let mut ret = Vec::new(); // Allocate a target array // TBD why size, why the position in the array, why the type (usize) @@ -284,9 +285,10 @@ pub fn calibrate_flush( threshold = (i, hit_histogram[i] + miss_histogram[i]); } }*/ - - println!("Threshold {}", threshold.0 * CFLUSH_BUCKET_SIZE); - println!("Calibration done."); + if verbose_level > NoOutput { + println!("Threshold {}", threshold.0 * CFLUSH_BUCKET_SIZE); + println!("Calibration done."); + } ret.push(( i as usize, diff --git a/cache_utils/src/main.rs b/cache_utils/src/main.rs index d3e7a67..cca6e41 100644 --- a/cache_utils/src/main.rs +++ b/cache_utils/src/main.rs @@ -71,9 +71,11 @@ pub fn main() { match sched_setaffinity(Pid::from_raw(0), &core) { Ok(()) => { + calibrate_flush(m, 64, Verbosity::NoOutput); calibrate_flush(m, 64, Verbosity::Thresholds); sched_setaffinity(Pid::from_raw(0), &old).unwrap(); println!("Iteration {}...ok ", i); + eprintln!("Iteration {}...ok ", i); } Err(Sys(Errno::EINVAL)) => { println!("skipping");