Skip to content

Commit

Permalink
Merge pull request #1288 from devnexen/gh1282_fix
Browse files Browse the repository at this point in the history
scx_utils: addressing #1282 concerns
  • Loading branch information
htejun authored Feb 2, 2025
2 parents 3b07ced + 2344c95 commit 11c37a5
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 11c37a5

Please sign in to comment.