Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions crates/celox-sir-opt/src/optimizer/pipeline/pass_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,13 @@ impl ExecutionUnitPassManager {
run: impl Fn(&Self, &mut ExecutionUnit<RegionedAbsoluteAddr>, &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;
Expand Down
6 changes: 3 additions & 3 deletions crates/celox-sir-opt/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions crates/celox/src/bin/celox/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>,
Expand Down
7 changes: 4 additions & 3 deletions crates/celox/src/simulator/builder/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions docs/guide/parallel-simulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/ja/guide/parallel-simulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ Celox は次の 2 段階で、並列化によって遅くなることを防ぎ

コンパイルには、上記のシミュレーションスレッドとは別のスレッド数があります。
SystemVerilog フロントエンドは独立したモジュール(パッケージの状態モジュール
など)をこれらのスレッドで変換し、ネイティブコード生成は独立したユニットを
など)をこれらのスレッドで変換し、SIR オプティマイザーは独立したユニットを
これらのスレッドで最適化し、ネイティブコード生成は独立したユニットを
メモリ予算の許す数のスレッドでコンパイルします。生成されるプログラムは
スレッド数によらず同じです。

Expand Down
5 changes: 3 additions & 2 deletions packages/celox/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down