Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scx_utils: addressing #1282 concerns #1288

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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