From c4fbfeaca9692898c541d33aea7774eb29ca57d2 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Thu, 23 Sep 2021 20:02:56 +0800 Subject: [PATCH] nac3standalone: added thread number arg --- nac3standalone/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nac3standalone/src/main.rs b/nac3standalone/src/main.rs index d48f82bd4..fbf47d3a6 100644 --- a/nac3standalone/src/main.rs +++ b/nac3standalone/src/main.rs @@ -21,12 +21,13 @@ use basic_symbol_resolver::*; fn main() { let demo_name = env::args().nth(1).unwrap(); + let threads: u32 = env::args().nth(2).map(|s| str::parse(&s).unwrap()).unwrap_or(1); let start = SystemTime::now(); Target::initialize_all(&InitializationConfig::default()); - let program = match fs::read_to_string(demo_name.to_owned() + ".py") { + let program = match fs::read_to_string(demo_name + ".py") { Ok(program) => program, Err(err) => { println!("Cannot open input file: {}", err); @@ -147,7 +148,7 @@ fn main() { // println!("IR:\n{}", module.print_to_string().to_str().unwrap()); }))); - let threads: Vec = (0..4).map(|i| format!("module{}", i)).collect(); + let threads: Vec = (0..threads).map(|i| format!("module{}", i)).collect(); let threads: Vec<_> = threads.iter().map(|s| s.as_str()).collect(); let (registry, handles) = WorkerRegistry::create_workers(&threads, top_level, f); registry.add_task(task);