Skip to content

Commit

Permalink
Only complain about threads once (#816)
Browse files Browse the repository at this point in the history
This cuts down on logging spam.
  • Loading branch information
matthiasgoergens authored Jan 8, 2025
1 parent 4684ab9 commit b60c6fe
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions multilinear_extensions/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ pub fn max_usable_threads() -> usize {
if cfg!(test) {
1
} else {
let n = rayon::current_num_threads();
let threads = prev_power_of_two(n);
if n != threads {
tracing::warn!("thread size {n} is not power of 2, using {threads} threads instead.");
}
threads
static MAX_USABLE_THREADS: std::sync::OnceLock<usize> = std::sync::OnceLock::new();
*MAX_USABLE_THREADS.get_or_init(|| {
let n = rayon::current_num_threads();
let threads = prev_power_of_two(n);
if n != threads {
tracing::warn!(
"thread size {n} is not power of 2, using {threads} threads instead."
);
}
threads
})
}
}

0 comments on commit b60c6fe

Please sign in to comment.