Fix various warnings
This commit is contained in:
parent
551a201f56
commit
bd4028f521
@ -14,7 +14,7 @@ pub fn main() {
|
||||
let mut core = CpuSet::new();
|
||||
core.set(unsafe { sched_getcpu() } as usize).unwrap();
|
||||
|
||||
sched_setaffinity(Pid::from_raw(0), &core);
|
||||
sched_setaffinity(Pid::from_raw(0), &core).unwrap();
|
||||
let t0_pre = unsafe { rdtsc_fence() };
|
||||
let start = Instant::now();
|
||||
let t0_post = unsafe { rdtsc_fence() };
|
||||
@ -22,7 +22,7 @@ pub fn main() {
|
||||
let mut tsc = t0_post;
|
||||
|
||||
println!("TSC,Freq");
|
||||
for i in 0..NUM_SAMPLE {
|
||||
for _ in 0..NUM_SAMPLE {
|
||||
//let t1 = unsafe { rdtsc_fence() };
|
||||
let frequency = get_freq_cpufreq_kernel();
|
||||
let t2 = unsafe { rdtsc_fence() };
|
||||
@ -33,7 +33,7 @@ pub fn main() {
|
||||
}
|
||||
}
|
||||
println!("Idling");
|
||||
for i in 0..NUM_SAMPLE_SLEEP {
|
||||
for _ in 0..NUM_SAMPLE_SLEEP {
|
||||
sleep(Duration::from_micros(1000));
|
||||
let frequency = get_freq_cpufreq_kernel();
|
||||
let t2 = unsafe { rdtsc_fence() };
|
||||
|
@ -8,11 +8,11 @@ const SAMPLE_BETWEEN_SLEEP: usize = 100;
|
||||
const NUM_ITERATION: usize = 10;
|
||||
|
||||
fn main() {
|
||||
let SLEEP_TIME: Duration = Duration::new(1, 0);
|
||||
let sleep_time: Duration = Duration::new(1, 0);
|
||||
let p = Box::new(42u8);
|
||||
let pointer = p.as_ref() as *const u8;
|
||||
// preheat
|
||||
for i in 0..SAMPLE_BETWEEN_SLEEP {
|
||||
for _ in 0..SAMPLE_BETWEEN_SLEEP {
|
||||
unsafe { only_flush(pointer) };
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ fn main() {
|
||||
|
||||
for frequency_sample in 0..SAMPLE_BETWEEN_SLEEP {
|
||||
for i in 0..NUM_ITERATION {
|
||||
sleep(SLEEP_TIME);
|
||||
sleep(sleep_time);
|
||||
for j in 0..SAMPLE_BETWEEN_SLEEP {
|
||||
if j == frequency_sample {
|
||||
let t = unsafe { rdtsc_fence() };
|
||||
|
@ -8,11 +8,11 @@ const SAMPLE_BETWEEN_SLEEP: usize = 100;
|
||||
const NUM_ITERATION: usize = 10;
|
||||
|
||||
fn main() {
|
||||
let SLEEP_TIME: Duration = Duration::new(1, 0);
|
||||
let sleep_time: Duration = Duration::new(1, 0);
|
||||
let p = Box::new(42u8);
|
||||
let pointer = p.as_ref() as *const u8;
|
||||
// preheat
|
||||
for i in 0..SAMPLE_BETWEEN_SLEEP {
|
||||
for _ in 0..SAMPLE_BETWEEN_SLEEP {
|
||||
unsafe { only_reload(pointer) };
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ fn main() {
|
||||
|
||||
for frequency_sample in 0..SAMPLE_BETWEEN_SLEEP {
|
||||
for i in 0..NUM_ITERATION {
|
||||
sleep(SLEEP_TIME);
|
||||
sleep(sleep_time);
|
||||
for j in 0..SAMPLE_BETWEEN_SLEEP {
|
||||
if j == frequency_sample {
|
||||
let t = unsafe { rdtsc_fence() };
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![allow(clippy::missing_safety_doc)]
|
||||
|
||||
use crate::complex_addressing::{cache_slicing, CacheSlicing};
|
||||
use crate::complex_addressing::{cache_slicing};
|
||||
use crate::{flush, maccess, rdtsc_fence};
|
||||
|
||||
use cpuid::MicroArchitecture;
|
||||
@ -25,9 +25,9 @@ pub enum Verbosity {
|
||||
}
|
||||
|
||||
pub struct HistParams {
|
||||
iterations: u32,
|
||||
bucket_size: usize,
|
||||
bucket_number: usize,
|
||||
pub iterations: u32,
|
||||
pub bucket_size: usize,
|
||||
pub bucket_number: usize,
|
||||
}
|
||||
|
||||
pub unsafe fn only_reload(p: *const u8) -> u64 {
|
||||
@ -38,9 +38,7 @@ pub unsafe fn only_reload(p: *const u8) -> u64 {
|
||||
|
||||
pub unsafe fn flush_and_reload(p: *const u8) -> u64 {
|
||||
flush(p);
|
||||
let t = rdtsc_fence();
|
||||
maccess(p);
|
||||
rdtsc_fence() - t
|
||||
only_reload(p)
|
||||
}
|
||||
|
||||
pub unsafe fn only_flush(p: *const u8) -> u64 {
|
||||
@ -51,16 +49,12 @@ pub unsafe fn only_flush(p: *const u8) -> u64 {
|
||||
|
||||
pub unsafe fn load_and_flush(p: *const u8) -> u64 {
|
||||
maccess(p);
|
||||
let t = rdtsc_fence();
|
||||
flush(p);
|
||||
rdtsc_fence() - t
|
||||
only_flush(p)
|
||||
}
|
||||
|
||||
pub unsafe fn flush_and_flush(p: *const u8) -> u64 {
|
||||
flush(p);
|
||||
let t = rdtsc_fence();
|
||||
flush(p);
|
||||
rdtsc_fence() - t
|
||||
only_flush(p)
|
||||
}
|
||||
|
||||
pub unsafe fn l3_and_reload(p: *const u8) -> u64 {
|
||||
@ -68,9 +62,7 @@ pub unsafe fn l3_and_reload(p: *const u8) -> u64 {
|
||||
arch_x86::_mm_mfence();
|
||||
arch_x86::_mm_prefetch(p as *const i8, arch_x86::_MM_HINT_T2);
|
||||
arch_x86::__cpuid_count(0, 0);
|
||||
let t = rdtsc_fence();
|
||||
maccess(p);
|
||||
rdtsc_fence() - t
|
||||
only_reload(p)
|
||||
}
|
||||
|
||||
const BUCKET_SIZE: usize = 5;
|
||||
@ -158,10 +150,10 @@ pub fn calibrate_access(array: &[u8; 4096]) -> u64 {
|
||||
(min_i * BUCKET_SIZE) as u64
|
||||
}
|
||||
|
||||
const CFLUSH_BUCKET_SIZE: usize = 1;
|
||||
const CFLUSH_BUCKET_NUMBER: usize = 500;
|
||||
pub const CFLUSH_BUCKET_SIZE: usize = 1;
|
||||
pub const CFLUSH_BUCKET_NUMBER: usize = 500;
|
||||
|
||||
const CFLUSH_NUM_ITER: u32 = 1 << 11;
|
||||
pub const CFLUSH_NUM_ITER: u32 = 1 << 11;
|
||||
|
||||
pub fn calibrate_flush(
|
||||
array: &[u8],
|
||||
@ -260,6 +252,8 @@ fn calibrate_impl_fixed_freq(
|
||||
let to_bucket = |time: u64| -> usize { time as usize / hist_params.bucket_size };
|
||||
let from_bucket = |bucket: usize| -> u64 { (bucket * hist_params.bucket_size) as u64 };
|
||||
|
||||
|
||||
|
||||
let slicing = if let Some(uarch) = MicroArchitecture::get_micro_architecture() {
|
||||
Some(cache_slicing(uarch, 8))
|
||||
} else {
|
||||
|
@ -56,7 +56,7 @@ impl CacheSlicing {
|
||||
}
|
||||
pub fn hash(&self, addr: usize) -> Option<usize> {
|
||||
match self {
|
||||
SimpleAddressing(mask) => Some((addr & *mask)),
|
||||
SimpleAddressing(mask) => Some(addr & *mask),
|
||||
ComplexAddressing(masks) => {
|
||||
let mut res = 0;
|
||||
for mask in *masks {
|
||||
|
@ -45,6 +45,8 @@ pub unsafe fn flush(p: *const u8) {
|
||||
arch_x86::_mm_clflush(p);
|
||||
}
|
||||
|
||||
pub fn noop<T>(_: *const T) {}
|
||||
|
||||
// future enhancements
|
||||
// prefetch
|
||||
// long nop (64 nops)
|
||||
|
Loading…
Reference in New Issue
Block a user