MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / prune_hyper_threading

Function prune_hyper_threading

crates/hyperqueue/src/worker/hwdetect.rs:72–92  ·  view source on GitHub ↗
(
    kind: &ResourceDescriptorKind,
)

Source from the content-addressed store, hash-verified

70}
71
72pub fn prune_hyper_threading(
73 kind: &ResourceDescriptorKind,
74) -> anyhow::Result<ResourceDescriptorKind> {
75 let groups = kind.as_groups();
76 let mut new_desc = Vec::new();
77 for group in groups {
78 let mut new_group = Vec::new();
79 for cpu_id in group {
80 if read_linux_thread_siblings(&cpu_id)?
81 .iter()
82 .min()
83 .ok_or_else(|| anyhow::anyhow!("Thread siblings are empty"))
84 .map(|v| *v == cpu_id)?
85 {
86 new_group.push(cpu_id);
87 }
88 }
89 new_desc.push(new_group);
90 }
91 Ok(ResourceDescriptorKind::groups(new_desc).unwrap())
92}
93
94/// Detects additional resources (apart from CPU) on this worker.
95/// Also returns the detected GPU families.

Callers 2

gather_configurationFunction · 0.85
command_worker_hwdetectFunction · 0.85

Calls 5

as_groupsMethod · 0.80
pushMethod · 0.80
groupsFunction · 0.50
iterMethod · 0.45

Tested by

no test coverage detected