Skip to content

Commit

Permalink
scx_utils: addressing #1282 concerns
Browse files Browse the repository at this point in the history
on 32 bits packing the value by high and low bits with an always even
sized Vec.
  • Loading branch information
devnexen committed Feb 2, 2025
1 parent 57dd25b commit 2344c95
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rust/scx_utils/src/gpu.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(feature = "gpu-topology")]

use crate::misc::read_file_usize;
use crate::{Cpumask, NR_CPUS_POSSIBLE};
use crate::{Cpumask, NR_CPU_IDS};
use nvml_wrapper::bitmasks::InitFlags;
use nvml_wrapper::enum_wrappers::device::Clock;
use nvml_wrapper::Nvml;
Expand Down Expand Up @@ -50,10 +50,13 @@ pub fn create_gpus() -> BTreeMap<usize, Vec<Gpu>> {
continue;
};

let cpu_mask = if let Ok(cpu_affinity) = nvidia_gpu.cpu_affinity(*NR_CPUS_POSSIBLE) {
let cpu_mask = if let Ok(cpu_affinity) = nvidia_gpu.cpu_affinity(*NR_CPU_IDS) {
// Note: nvml returns it as an arch dependent array of integrals
#[cfg(target_pointer_width = "32")]
let cpu_affinity = cpu_affinity.into_iter().map(|aff| aff as u64).collect();
let cpu_affinity: Vec<u64> = cpu_affinity
.chunks_exact(2)
.map(|pair| (pair[1] as u64) << 32 | pair[0] as u64)
.collect();
Cpumask::from_vec(cpu_affinity)
} else {
Cpumask::new()
Expand Down

0 comments on commit 2344c95

Please sign in to comment.