Fix various warnings

This commit is contained in:
GuillaumeDIDIER 2020-07-02 15:39:37 +02:00
parent 551a201f56
commit bd4028f521
6 changed files with 25 additions and 29 deletions

View File

@ -14,7 +14,7 @@ pub fn main() {
let mut core = CpuSet::new(); let mut core = CpuSet::new();
core.set(unsafe { sched_getcpu() } as usize).unwrap(); 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 t0_pre = unsafe { rdtsc_fence() };
let start = Instant::now(); let start = Instant::now();
let t0_post = unsafe { rdtsc_fence() }; let t0_post = unsafe { rdtsc_fence() };
@ -22,7 +22,7 @@ pub fn main() {
let mut tsc = t0_post; let mut tsc = t0_post;
println!("TSC,Freq"); println!("TSC,Freq");
for i in 0..NUM_SAMPLE { for _ in 0..NUM_SAMPLE {
//let t1 = unsafe { rdtsc_fence() }; //let t1 = unsafe { rdtsc_fence() };
let frequency = get_freq_cpufreq_kernel(); let frequency = get_freq_cpufreq_kernel();
let t2 = unsafe { rdtsc_fence() }; let t2 = unsafe { rdtsc_fence() };
@ -33,7 +33,7 @@ pub fn main() {
} }
} }
println!("Idling"); println!("Idling");
for i in 0..NUM_SAMPLE_SLEEP { for _ in 0..NUM_SAMPLE_SLEEP {
sleep(Duration::from_micros(1000)); sleep(Duration::from_micros(1000));
let frequency = get_freq_cpufreq_kernel(); let frequency = get_freq_cpufreq_kernel();
let t2 = unsafe { rdtsc_fence() }; let t2 = unsafe { rdtsc_fence() };

View File

@ -8,11 +8,11 @@ const SAMPLE_BETWEEN_SLEEP: usize = 100;
const NUM_ITERATION: usize = 10; const NUM_ITERATION: usize = 10;
fn main() { fn main() {
let SLEEP_TIME: Duration = Duration::new(1, 0); let sleep_time: Duration = Duration::new(1, 0);
let p = Box::new(42u8); let p = Box::new(42u8);
let pointer = p.as_ref() as *const u8; let pointer = p.as_ref() as *const u8;
// preheat // preheat
for i in 0..SAMPLE_BETWEEN_SLEEP { for _ in 0..SAMPLE_BETWEEN_SLEEP {
unsafe { only_flush(pointer) }; unsafe { only_flush(pointer) };
} }
@ -24,7 +24,7 @@ fn main() {
for frequency_sample in 0..SAMPLE_BETWEEN_SLEEP { for frequency_sample in 0..SAMPLE_BETWEEN_SLEEP {
for i in 0..NUM_ITERATION { for i in 0..NUM_ITERATION {
sleep(SLEEP_TIME); sleep(sleep_time);
for j in 0..SAMPLE_BETWEEN_SLEEP { for j in 0..SAMPLE_BETWEEN_SLEEP {
if j == frequency_sample { if j == frequency_sample {
let t = unsafe { rdtsc_fence() }; let t = unsafe { rdtsc_fence() };

View File

@ -8,11 +8,11 @@ const SAMPLE_BETWEEN_SLEEP: usize = 100;
const NUM_ITERATION: usize = 10; const NUM_ITERATION: usize = 10;
fn main() { fn main() {
let SLEEP_TIME: Duration = Duration::new(1, 0); let sleep_time: Duration = Duration::new(1, 0);
let p = Box::new(42u8); let p = Box::new(42u8);
let pointer = p.as_ref() as *const u8; let pointer = p.as_ref() as *const u8;
// preheat // preheat
for i in 0..SAMPLE_BETWEEN_SLEEP { for _ in 0..SAMPLE_BETWEEN_SLEEP {
unsafe { only_reload(pointer) }; unsafe { only_reload(pointer) };
} }
@ -24,7 +24,7 @@ fn main() {
for frequency_sample in 0..SAMPLE_BETWEEN_SLEEP { for frequency_sample in 0..SAMPLE_BETWEEN_SLEEP {
for i in 0..NUM_ITERATION { for i in 0..NUM_ITERATION {
sleep(SLEEP_TIME); sleep(sleep_time);
for j in 0..SAMPLE_BETWEEN_SLEEP { for j in 0..SAMPLE_BETWEEN_SLEEP {
if j == frequency_sample { if j == frequency_sample {
let t = unsafe { rdtsc_fence() }; let t = unsafe { rdtsc_fence() };

View File

@ -1,6 +1,6 @@
#![allow(clippy::missing_safety_doc)] #![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 crate::{flush, maccess, rdtsc_fence};
use cpuid::MicroArchitecture; use cpuid::MicroArchitecture;
@ -25,9 +25,9 @@ pub enum Verbosity {
} }
pub struct HistParams { pub struct HistParams {
iterations: u32, pub iterations: u32,
bucket_size: usize, pub bucket_size: usize,
bucket_number: usize, pub bucket_number: usize,
} }
pub unsafe fn only_reload(p: *const u8) -> u64 { 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 { pub unsafe fn flush_and_reload(p: *const u8) -> u64 {
flush(p); flush(p);
let t = rdtsc_fence(); only_reload(p)
maccess(p);
rdtsc_fence() - t
} }
pub unsafe fn only_flush(p: *const u8) -> u64 { 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 { pub unsafe fn load_and_flush(p: *const u8) -> u64 {
maccess(p); maccess(p);
let t = rdtsc_fence(); only_flush(p)
flush(p);
rdtsc_fence() - t
} }
pub unsafe fn flush_and_flush(p: *const u8) -> u64 { pub unsafe fn flush_and_flush(p: *const u8) -> u64 {
flush(p); flush(p);
let t = rdtsc_fence(); only_flush(p)
flush(p);
rdtsc_fence() - t
} }
pub unsafe fn l3_and_reload(p: *const u8) -> u64 { 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_mfence();
arch_x86::_mm_prefetch(p as *const i8, arch_x86::_MM_HINT_T2); arch_x86::_mm_prefetch(p as *const i8, arch_x86::_MM_HINT_T2);
arch_x86::__cpuid_count(0, 0); arch_x86::__cpuid_count(0, 0);
let t = rdtsc_fence(); only_reload(p)
maccess(p);
rdtsc_fence() - t
} }
const BUCKET_SIZE: usize = 5; const BUCKET_SIZE: usize = 5;
@ -158,10 +150,10 @@ pub fn calibrate_access(array: &[u8; 4096]) -> u64 {
(min_i * BUCKET_SIZE) as u64 (min_i * BUCKET_SIZE) as u64
} }
const CFLUSH_BUCKET_SIZE: usize = 1; pub const CFLUSH_BUCKET_SIZE: usize = 1;
const CFLUSH_BUCKET_NUMBER: usize = 500; 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( pub fn calibrate_flush(
array: &[u8], 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 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 from_bucket = |bucket: usize| -> u64 { (bucket * hist_params.bucket_size) as u64 };
let slicing = if let Some(uarch) = MicroArchitecture::get_micro_architecture() { let slicing = if let Some(uarch) = MicroArchitecture::get_micro_architecture() {
Some(cache_slicing(uarch, 8)) Some(cache_slicing(uarch, 8))
} else { } else {

View File

@ -56,7 +56,7 @@ impl CacheSlicing {
} }
pub fn hash(&self, addr: usize) -> Option<usize> { pub fn hash(&self, addr: usize) -> Option<usize> {
match self { match self {
SimpleAddressing(mask) => Some((addr & *mask)), SimpleAddressing(mask) => Some(addr & *mask),
ComplexAddressing(masks) => { ComplexAddressing(masks) => {
let mut res = 0; let mut res = 0;
for mask in *masks { for mask in *masks {

View File

@ -45,6 +45,8 @@ pub unsafe fn flush(p: *const u8) {
arch_x86::_mm_clflush(p); arch_x86::_mm_clflush(p);
} }
pub fn noop<T>(_: *const T) {}
// future enhancements // future enhancements
// prefetch // prefetch
// long nop (64 nops) // long nop (64 nops)