modify jobs option

This commit is contained in:
Magnus Ulimoen 2020-04-03 22:30:30 +02:00
parent 97bdf7b0a5
commit 6b94990015
1 changed files with 12 additions and 9 deletions

View File

@ -274,10 +274,12 @@ impl<T: operators::UpwindOperator> System<T> {
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
struct Options { struct Options {
json: std::path::PathBuf, json: std::path::PathBuf,
#[structopt(long, help = "Disable the progressbar")] /// Disable the progressbar
#[structopt(long)]
no_progressbar: bool, no_progressbar: bool,
#[structopt(short, long, help = "Number of simultaneous threads")] /// Number of simultaneous threads
jobs: Option<usize>, #[structopt(short, long)]
jobs: Option<Option<usize>>,
} }
fn main() { fn main() {
@ -326,12 +328,13 @@ fn main() {
let ntime = (integration_time / dt).round() as usize; let ntime = (integration_time / dt).round() as usize;
let pool = if let Some(j) = opt.jobs { let pool = if let Some(j) = opt.jobs {
Some( let builder = rayon::ThreadPoolBuilder::new();
rayon::ThreadPoolBuilder::new() let builder = if let Some(j) = j {
.num_threads(j) builder.num_threads(j)
.build() } else {
.unwrap(), builder
) };
Some(builder.build().unwrap())
} else { } else {
None None
}; };