GPU: parallelize copy refreshes on multicore hosts

This commit is contained in:
spacede committed 2026-11-24 21:45:38 +01:00
1 parent 5a32c08c29
commit 05ee438706
1 file changed
+32 -2
+32 -2
View File
@@ -5156,7 +5156,7 @@ impl HostList {
}
/// Whether a submission's refreshes of host copies run on several threads,
/// a copy to a thread (`VICTORY_WIDE_REFRESH=1`; off by default).
/// a copy to a thread (`VICTORY_WIDE_REFRESH=0` disables it; `=1` forces it).
///
/// A submission brings some sixty copies up to date, one after the other
/// on the submitting thread: for each, the pages the title wrote are asked
@@ -5169,7 +5169,36 @@ impl HostList {
/// they are for the title's threads.
fn wide_refresh() -> bool {
static ON: OnceLock<bool> = OnceLock::new();
*ON.get_or_init(|| std::env::var_os("VICTORY_WIDE_REFRESH").is_some_and(|v| v == "1"))
*ON.get_or_init(|| {
wide_refresh_enabled(
std::env::var("VICTORY_WIDE_REFRESH").ok().as_deref(),
std::thread::available_parallelism().ok().map(|n| n.get()),
)
})
}
fn wide_refresh_enabled(setting: Option<&str>, logical_cpus: Option<usize>) -> bool {
match setting {
Some("1") => true,
Some("0") => false,
_ => logical_cpus.is_some_and(|n| n >= 4),
}
}
#[cfg(test)]
mod wide_refresh_tests {
use super::wide_refresh_enabled;
#[test]
fn parallel_refresh_is_default_on_multicore_and_can_be_overridden() {
assert!(wide_refresh_enabled(None, Some(4)));
assert!(wide_refresh_enabled(None, Some(16)));
assert!(!wide_refresh_enabled(None, Some(2)));
assert!(!wide_refresh_enabled(None, None));
assert!(wide_refresh_enabled(Some("1"), Some(1)));
assert!(!wide_refresh_enabled(Some("0"), Some(16)));
assert!(wide_refresh_enabled(Some("auto"), Some(4)));
}
}
/// A submission's refreshes not done yet, merged per buffer copy into the
@@ -6480,3 +6509,4 @@ mod batch { // Batch::texture_due lives here; `mod tests` is already taken at
);
}
}