use hwlocality::{
Topology,
topology::support::{CpuBindingSupport, FeatureSupport, MemoryBindingSupport},
};
fn main() -> eyre::Result<()> {
let topology = Topology::new()?;
println!("CPU binding support:");
let cpu_binding_support = |check_feature: fn(&CpuBindingSupport) -> bool| {
topology.supports(FeatureSupport::cpu_binding, check_feature)
};
println!(
"- Current process: {}",
cpu_binding_support(CpuBindingSupport::set_current_process)
);
println!(
"- Any process: {}",
cpu_binding_support(CpuBindingSupport::set_process)
);
println!(
"- Current thread: {}",
cpu_binding_support(CpuBindingSupport::set_current_thread)
);
println!(
"- Any thread: {}",
cpu_binding_support(CpuBindingSupport::set_thread)
);
println!("\nMemory binding support:");
let memory_binding_support = |check_feature: fn(&MemoryBindingSupport) -> bool| {
topology.supports(FeatureSupport::memory_binding, check_feature)
};
println!(
"- Current process: {}",
memory_binding_support(MemoryBindingSupport::set_current_process)
);
println!(
"- Any process: {}",
memory_binding_support(MemoryBindingSupport::set_process)
);
println!(
"- Current thread: {}",
memory_binding_support(MemoryBindingSupport::set_current_thread)
);
println!(
"- New bound allocation: {}",
memory_binding_support(MemoryBindingSupport::allocate_bound)
);
println!(
"- Bind pre-existing allocation: {}",
memory_binding_support(MemoryBindingSupport::set_area)
);
println!("\nRaw support flags: {:#?}", topology.feature_support());
Ok(())
}