forked from nonsensical-dev/zenyx-engine
Merge branch 'main' of codeberg.org:Caznix/Zenyx
This commit is contained in:
commit
1a0eadbc14
1 changed files with 32 additions and 25 deletions
|
@ -382,38 +382,45 @@ impl CPU {
|
||||||
let logical_cores = cpu_opt.map(|_| sys.cpus().len() as u8);
|
let logical_cores = cpu_opt.map(|_| sys.cpus().len() as u8);
|
||||||
let physical_cores = System::physical_core_count().map(|pc| pc as u8);
|
let physical_cores = System::physical_core_count().map(|pc| pc as u8);
|
||||||
|
|
||||||
let cpuid = CpuId::new();
|
|
||||||
let mut l1_cache = None;
|
let mut l1_cache = None;
|
||||||
let mut l2_cache = None;
|
let mut l2_cache = None;
|
||||||
let mut l3_cache = None;
|
let mut l3_cache = None;
|
||||||
if let Some(iter) = cpuid.get_cache_parameters() {
|
|
||||||
for cache in iter {
|
#[cfg(any(
|
||||||
match cache.level() {
|
all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"),
|
||||||
1 => {
|
all(target_arch = "x86_64", not(target_env = "sgx"))
|
||||||
let size = cache.physical_line_partitions()
|
))]
|
||||||
* cache.coherency_line_size()
|
{
|
||||||
* cache.associativity();
|
let cpuid = CpuId::new();
|
||||||
if size > 0 {
|
if let Some(iter) = cpuid.get_cache_parameters() {
|
||||||
l1_cache = Some(Memory::from_bytes(size.try_into().unwrap()));
|
for cache in iter {
|
||||||
|
match cache.level() {
|
||||||
|
1 => {
|
||||||
|
let size = cache.physical_line_partitions()
|
||||||
|
* cache.coherency_line_size()
|
||||||
|
* cache.associativity();
|
||||||
|
if size > 0 {
|
||||||
|
l1_cache = Some(Memory::from_bytes(size.try_into().unwrap()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
2 => {
|
||||||
2 => {
|
let size = cache.physical_line_partitions()
|
||||||
let size = cache.physical_line_partitions()
|
* cache.coherency_line_size()
|
||||||
* cache.coherency_line_size()
|
* cache.associativity();
|
||||||
* cache.associativity();
|
if size > 0 {
|
||||||
if size > 0 {
|
l2_cache = Some(Memory::from_bytes(size.try_into().unwrap()));
|
||||||
l2_cache = Some(Memory::from_bytes(size.try_into().unwrap()));
|
}
|
||||||
}
|
}
|
||||||
}
|
3 => {
|
||||||
3 => {
|
let size = (cache.physical_line_partitions() as u64)
|
||||||
let size = (cache.physical_line_partitions() as u64)
|
* (cache.coherency_line_size() as u64)
|
||||||
* (cache.coherency_line_size() as u64)
|
* (cache.associativity() as u64);
|
||||||
* (cache.associativity() as u64);
|
if size > 0 {
|
||||||
if size > 0 {
|
l3_cache = Some(Memory::from_bytes(size));
|
||||||
l3_cache = Some(Memory::from_bytes(size));
|
}
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue