Add some warm up and fix some output related issues + make the cpuid leaf 4 availale as an util

This commit is contained in:
guillaume didier 2020-03-20 16:09:03 +01:00
parent f599b74ef3
commit 5c6c607c8f
4 changed files with 18 additions and 9 deletions

View File

@ -0,0 +1,5 @@
use cache_utils::cache_info::get_cache_info;
pub fn main() {
println!("{:#?}", get_cache_info());
}

View File

@ -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,

View File

@ -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)> {
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]);
}
}*/
if verbose_level > NoOutput {
println!("Threshold {}", threshold.0 * CFLUSH_BUCKET_SIZE);
println!("Calibration done.");
}
ret.push((
i as usize,

View File

@ -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");