Add a third function handling the linear hashing functions Im and Ker
This commit is contained in:
parent
dc0fe08dab
commit
0e0d5606bd
@ -16,6 +16,7 @@ pub fn main() {
|
|||||||
);
|
);
|
||||||
println!("{:?}", slicing.image((1 << 12) - 1));
|
println!("{:?}", slicing.image((1 << 12) - 1));
|
||||||
println!("{:?}", slicing.kernel_compl_basis((1 << 12) - 1));
|
println!("{:?}", slicing.kernel_compl_basis((1 << 12) - 1));
|
||||||
|
println!("{:?}", slicing.image_antecedent((1 << 12) - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,13 @@ use crate::complex_addressing::CacheSlicing::{
|
|||||||
};
|
};
|
||||||
use cpuid::{CPUVendor, MicroArchitecture};
|
use cpuid::{CPUVendor, MicroArchitecture};
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use alloc::collections::VecDeque;
|
use alloc::collections::VecDeque;
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
#[cfg(feature = "no_std")]
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use hashbrown::HashSet;
|
use hashbrown::HashSet;
|
||||||
@ -229,4 +233,26 @@ impl CacheSlicing {
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn image_antecedent(&self, mask: usize) -> Option<HashMap<u8, usize>> {
|
||||||
|
match self {
|
||||||
|
ComplexAddressing(_functions) => {
|
||||||
|
let matrix = self.pivot(mask);
|
||||||
|
|
||||||
|
let mut result = HashMap::<u8, usize>::new();
|
||||||
|
result.insert(0, 0);
|
||||||
|
|
||||||
|
for (slice_u, addr_u) in matrix {
|
||||||
|
if (slice_u != 0) {
|
||||||
|
let mut tmp = HashMap::new();
|
||||||
|
for (slice_v, addr_v) in &result {
|
||||||
|
tmp.insert(slice_v ^ slice_u, addr_v ^ addr_u);
|
||||||
|
}
|
||||||
|
result.extend(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some(result)
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user