the amount of threads now adapt to the host system amount of threads
This commit is contained in:
@@ -8,6 +8,8 @@ pub mod rtweekend;
|
|||||||
pub mod sphere;
|
pub mod sphere;
|
||||||
pub mod vec3;
|
pub mod vec3;
|
||||||
|
|
||||||
|
use std::{f64, thread::available_parallelism};
|
||||||
|
|
||||||
use image::{Pixel, RgbImage};
|
use image::{Pixel, RgbImage};
|
||||||
use indicatif::{ProgressBar, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressStyle};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
@@ -136,9 +138,14 @@ fn main() {
|
|||||||
dist_to_focus,
|
dist_to_focus,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let num_threads: usize = match available_parallelism() {
|
||||||
|
Ok(threads) => threads.into(),
|
||||||
|
Err(_) => 1,
|
||||||
|
};
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
rayon::ThreadPoolBuilder::new()
|
rayon::ThreadPoolBuilder::new()
|
||||||
.num_threads(11)
|
.num_threads(num_threads)
|
||||||
.build_global()
|
.build_global()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user