diff --git a/crates/celox-sir-opt/src/optimizer/pipeline/pass_manager.rs b/crates/celox-sir-opt/src/optimizer/pipeline/pass_manager.rs index 53c03eb292..1147013bff 100644 --- a/crates/celox-sir-opt/src/optimizer/pipeline/pass_manager.rs +++ b/crates/celox-sir-opt/src/optimizer/pipeline/pass_manager.rs @@ -168,14 +168,13 @@ impl ExecutionUnitPassManager { run: impl Fn(&Self, &mut ExecutionUnit, &PassOptions) + Sync, options: &PassOptions, ) { - #[cfg(not(target_arch = "wasm32"))] - const MAX_PARALLEL_UNITS: usize = 4; - + // As many workers as compiling may use (see + // `OptimizeOptions::compile_threads`), no more than the host has. #[cfg(not(target_arch = "wasm32"))] let worker_count = items.len().min( std::thread::available_parallelism() .map_or(1, usize::from) - .min(MAX_PARALLEL_UNITS), + .min(options.optimize_options.compile_threads()), ); #[cfg(target_arch = "wasm32")] let worker_count = 1; diff --git a/crates/celox-sir-opt/src/policy.rs b/crates/celox-sir-opt/src/policy.rs index e902661b5b..14ea785cd2 100644 --- a/crates/celox-sir-opt/src/policy.rs +++ b/crates/celox-sir-opt/src/policy.rs @@ -314,9 +314,9 @@ impl OptimizeOptions { } /// Compile with at most `threads` threads (at least one): the frontend - /// lowers independent modules on them, and native code generation - /// compiles independent units on as many of them as its memory budget - /// allows. One compiles everything on the calling thread. They are not + /// lowers independent modules on them, the optimizer optimizes + /// independent units on them, and native code generation compiles + /// independent units on as many of them as its memory budget allows. One compiles everything on the calling thread. They are not /// simulation lanes (see [`Self::set_parallel_lanes`]); the result is the /// same for every count. The default is the available parallelism of /// the host. diff --git a/crates/celox/src/bin/celox/runner.rs b/crates/celox/src/bin/celox/runner.rs index 68145ac4d6..dfc4a74060 100644 --- a/crates/celox/src/bin/celox/runner.rs +++ b/crates/celox/src/bin/celox/runner.rs @@ -111,9 +111,9 @@ pub(super) struct ExecutionArgs { /// Simulation threads, including the calling thread. #[arg(long, default_value_t = 1, value_parser = clap::value_parser!(u32).range(1..=64))] pub threads: u32, - /// Compile threads: the SystemVerilog frontend and native code - /// generation compile independent modules and units on up to this many - /// threads. The compiled program is the same for every count. Default: + /// Compile threads: the SystemVerilog frontend, the SIR optimizer and + /// native code generation compile independent modules and units on up + /// to this many threads. The compiled program is the same for every count. Default: /// the available parallelism of the host. #[arg(long, value_name = "N", value_parser = clap::value_parser!(u32).range(1..))] pub compile_threads: Option, diff --git a/crates/celox/src/simulator/builder/host.rs b/crates/celox/src/simulator/builder/host.rs index 5a03fc8d75..802f895e3a 100644 --- a/crates/celox/src/simulator/builder/host.rs +++ b/crates/celox/src/simulator/builder/host.rs @@ -473,9 +473,10 @@ impl<'a, Target> SimulatorBuilder<'a, Target> { } /// Compile with at most `threads` host threads (at least one). The - /// SystemVerilog frontend lowers independent modules on them, and - /// native code generation compiles independent units on as many as its - /// memory budget allows. One compiles on the calling thread only. The + /// SystemVerilog frontend lowers independent modules on them, the SIR + /// optimizer optimizes independent units on them, and native code + /// generation compiles independent units on as many as its memory + /// budget allows. One compiles on the calling thread only. The /// compiled program is the same for every count; these are not the /// simulation threads of [`Self::threads`]. The default is the /// available parallelism of the host. diff --git a/docs/guide/parallel-simulation.md b/docs/guide/parallel-simulation.md index 40011e4b33..fd6c38b9f9 100644 --- a/docs/guide/parallel-simulation.md +++ b/docs/guide/parallel-simulation.md @@ -67,8 +67,9 @@ trigger clock events, stay ordered exactly as in sequential simulation. Compilation has its own thread count, separate from the simulation threads above. The SystemVerilog frontend lowers independent modules (such as the -state modules of packages) on these threads, and native code generation -compiles independent units on as many of them as its memory budget allows. +state modules of packages) on these threads, the SIR optimizer optimizes +independent units on them, and native code generation compiles independent +units on as many of them as its memory budget allows. The compiled program is the same for every count. ```rust diff --git a/docs/ja/guide/parallel-simulation.md b/docs/ja/guide/parallel-simulation.md index 54cc7923b2..9508cfe1ba 100644 --- a/docs/ja/guide/parallel-simulation.md +++ b/docs/ja/guide/parallel-simulation.md @@ -64,7 +64,8 @@ Celox は次の 2 段階で、並列化によって遅くなることを防ぎ コンパイルには、上記のシミュレーションスレッドとは別のスレッド数があります。 SystemVerilog フロントエンドは独立したモジュール(パッケージの状態モジュール -など)をこれらのスレッドで変換し、ネイティブコード生成は独立したユニットを +など)をこれらのスレッドで変換し、SIR オプティマイザーは独立したユニットを +これらのスレッドで最適化し、ネイティブコード生成は独立したユニットを メモリ予算の許す数のスレッドでコンパイルします。生成されるプログラムは スレッド数によらず同じです。 diff --git a/packages/celox/src/types.ts b/packages/celox/src/types.ts index d6f8c5ed46..28915178aa 100644 --- a/packages/celox/src/types.ts +++ b/packages/celox/src/types.ts @@ -590,8 +590,9 @@ export interface SimulatorOptions { */ threads?: number; /** - * Compile threads: the SystemVerilog frontend and native code generation - * compile independent modules and units on up to this many threads. + * Compile threads: the SystemVerilog frontend, the SIR optimizer and + * native code generation compile independent modules and units on up to + * this many threads. * The compiled program is the same for every count. These are not the * simulation `threads`. Default: the available parallelism of the host. */