Skip to content
Closed
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
37 changes: 23 additions & 14 deletions crates/celox-runtime/src/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ impl Shared {
timing.waits.push((other, completed, start, trace.nanos()));
}
}
if !aborted {
// A failed producer publishes its abort before its progress. The
// acquire above may satisfy the wait without entering the loop,
// so reload abort after observing that progress.
if !aborted && !self.abort.0.load(Ordering::Acquire) {
if let (Some(trace), Some(timing)) = (trace, &mut timing) {
timing.start = trace.nanos();
}
Expand Down Expand Up @@ -640,19 +643,25 @@ mod tests {
#[test]
fn failures_skip_pending_work_and_report_the_first_task() {
let (schedule, predecessors) = chain_schedule();
let mut pool = LanePool::new(3).unwrap();
let runner = recorder(predecessors.clone(), Some(0));
assert_eq!(
pool.run(&schedule, &runner),
Err(LaneTaskFailure { task: 0, code: 7 })
);
// Dependents of the failed task never ran.
assert!(!runner.done[1].load(Ordering::Acquire));
assert!(!runner.done[3].load(Ordering::Acquire));
// The pool remains usable after a failure.
let runner = recorder(predecessors, None);
pool.run(&schedule, &runner).unwrap();
assert_eq!(runner.calls.load(Ordering::Relaxed), 4);
for idle_spin in [Duration::ZERO, LanePool::DEFAULT_IDLE_SPIN] {
let mut pool = LanePool::with_idle_spin(3, idle_spin).unwrap();
// Exercise both parked and spinning workers across failure/recovery
// epochs: a dependent can observe progress just as abort is set.
for _ in 0..2000 {
let runner = recorder(predecessors.clone(), Some(0));
assert_eq!(
pool.run(&schedule, &runner),
Err(LaneTaskFailure { task: 0, code: 7 })
);
// Dependents of the failed task never ran.
assert!(!runner.done[1].load(Ordering::Acquire));
assert!(!runner.done[3].load(Ordering::Acquire));
// The pool remains usable after a failure.
let runner = recorder(predecessors.clone(), None);
pool.run(&schedule, &runner).unwrap();
assert_eq!(runner.calls.load(Ordering::Relaxed), 4);
}
}
}

#[test]
Expand Down
46 changes: 46 additions & 0 deletions crates/celox-test-suite/src/sv/cases/hierarchy.vtest
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,49 @@
(top Top)
(assert_eq added 256)
(assert_eq negated 65535))

(case bits_query_parameter_overrides
; IEEE 1800-2023 20.6.2: fixed-size type and variable queries are constants.
(source "bits_parameter_overrides.sv" #"
module Sub #(parameter int W = 1)(output int y); assign y = W; endmodule
module Top(output int type_bits, variable_bits, combined_bits);
typedef logic [3:0] nibble_t;
logic [11:0] value;
Sub #(.W($bits(nibble_t))) type_instance(.y(type_bits));
Sub #($bits(value)) variable_instance(.y(variable_bits));
Sub #(.W($bits(nibble_t) + $bits(value))) combined_instance(.y(combined_bits));
endmodule
"#)
(top Top)
(eval)
(assert_eq type_bits 4)
(assert_eq variable_bits 12)
(assert_eq combined_bits 16))

(case bits_query_parameter_overrides_follow_caller_specialization
(source "specialized_bits_parameter_overrides.sv" #"
package Types; typedef logic [8:0] word_t; endpackage
module Sub #(parameter int W = 1)(output int y); assign y = W; endmodule
module Caller #(parameter int N = 2)(output int variable_bits, type_bits, array_bits);
import Types::*;
logic [N-1:0] value;
logic [N-1:0] memory [3];
typedef logic [N:0] local_t;
Sub #(.W($bits(value))) variable_instance(.y(variable_bits));
Sub #(.W($bits(local_t) + $bits(word_t))) type_instance(.y(type_bits));
Sub #(.W($bits(memory))) array_instance(.y(array_bits));
endmodule
module Top(output int default_var, default_type, default_array,
output int override_var, override_type, override_array);
Caller default_instance(default_var, default_type, default_array);
Caller #(.N(5)) override_instance(override_var, override_type, override_array);
endmodule
"#)
(top Top)
(eval)
(assert_eq default_var 2)
(assert_eq default_type 12)
(assert_eq default_array 6)
(assert_eq override_var 5)
(assert_eq override_type 15)
(assert_eq override_array 15))
8 changes: 8 additions & 0 deletions crates/celox/tests/frontends/systemverilog/hierarchy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
use super::*;

sv_backends! {
fn bits_query_parameter_overrides_follow_caller_specialization(sim) {
@case "hierarchy::bits_query_parameter_overrides_follow_caller_specialization";
}

fn bits_query_parameter_overrides(sim) {
@case "hierarchy::bits_query_parameter_overrides";
}

fn parameter_patterns_keep_original_declarations_and_isolated_bindings(sim) { @case "hierarchy::parameter_patterns_keep_original_declarations_and_isolated_bindings"; }
fn parameter_patterns_preserve_enclosing_expressions(sim) { @case "hierarchy::parameter_patterns_preserve_enclosing_expressions"; }
fn widens_small_parameters_preserving_four_state_bits(sim) {
Expand Down
7 changes: 7 additions & 0 deletions docs/benchmarks/heliodor.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ host vCPU (`HELIODOR_CELOX_THREADS`, default `nproc`). Its own job keeps the
comparison groups' time budgets unchanged. The dashboard shows it as
"multi-threaded" next to single-threaded native execution.

`celox-tiered` also uses `HELIODOR_CELOX_THREADS` on both AArch64 and x86-64.
It starts on the interpreter and adopts native kernels with parallel execution
enabled once compilation finishes. The scheduler can keep sequential kernels
when parallel execution is not worthwhile. Set `HELIODOR_CELOX_THREADS=1` for
the previous single-threaded tiered configuration. Earlier tiered measurements
used one simulation thread; account for this when comparing historical timings.

Recent complete eight-hart runs total 10–13 hours on x86-64 and 17–18 hours on
AArch64. AArch64 four-hart runs total 5–7 hours, so splitting them into equivalent
execution modes preserves useful same-CPU comparisons with time for builds.
Expand Down
6 changes: 6 additions & 0 deletions docs/ja/benchmarks/heliodor.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ Linux バージョンはシミュレーション内で起動するゲストの
別ジョブにすることで、比較グループの実行時間の上限は変わりません。ダッシュボードでは
シングルスレッドの native 実行と並べて「multi-threaded」として表示します。

`celox-tiered` も AArch64・x86-64 の両方で `HELIODOR_CELOX_THREADS` を使います。
インタープリターで実行を始め、コンパイル完了後に並列実行を有効にした native カーネルへ移行します。
並列化の効果が小さい処理には、スケジューラーが逐次カーネルを選ぶことがあります。
従来のシングルスレッド設定で測定する場合は `HELIODOR_CELOX_THREADS=1` を指定してください。
過去の tiered 計測はシミュレーションを1スレッドで実行していたため、履歴との比較ではこの違いに注意してください。

直近の完走結果では、8 hart の合計は x86-64 で 10〜13 時間、AArch64 で 17〜18 時間です。
AArch64 の 4 hart も合計 5〜7 時間なので、同じ実行方式のペアに分け、ビルド時間を確保しつつ
Celox と Veryl-CC を同じ CPU で比較します。別グループ間では同じ CPU を保証しません。
Expand Down
4 changes: 2 additions & 2 deletions scripts/heliodor-suite.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const workloads = [
"test_soc_71v_linux_boot",
];
export const runners = ["veryl-cc-sync", "celox", "celox-tiered", "veryl-cc-tiered"];
// Multi-threaded Celox runs only on SMP workloads, in its own group so the
// existing comparison groups keep their time budgets.
// The synchronous multi-threaded Celox runner runs only on SMP workloads,
// in its own group so the existing comparison groups keep their time budgets.
export const parallelRunner = "celox-parallel";
export const allRunners = [...runners, parallelRunner];
const isSmp = test => /_smp_linux_boot_\d+hart$/.test(test);
Expand Down
15 changes: 11 additions & 4 deletions scripts/run-heliodor-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Environment:
HELIODOR_CELOX_TIMEOUT_MULTIPLIER
timeout Celox after N times the fastest successful Veryl baseline
HELIODOR_CELOX_THREADS
simulation threads of the celox-parallel runner (default: nproc)
simulation threads of celox-parallel and celox-tiered (default: nproc)
CELOX_OPT_LEVEL O0, O1, or O2 for the Celox runner (default: O2)
CELOX_SIR_PASS_OVERRIDES
space-separated SIR pass overrides, e.g. "-vectorize_concat +gvn"
Expand Down Expand Up @@ -1580,7 +1580,8 @@ run_one() {
run_in_heliodor "$timeout_sec" "$log" \
"${celox_execution_command[@]}" \
--project "$HELIODOR_DIR" --test "$test" \
"${celox_args[@]}" --backend tiered --opt-level "${CELOX_OPT_LEVEL,,}"
"${celox_args[@]}" --backend tiered --opt-level "${CELOX_OPT_LEVEL,,}" \
--threads "$HELIODOR_CELOX_THREADS"
process_status="$?"
;;
celox-interpreter)
Expand Down Expand Up @@ -1658,9 +1659,10 @@ run_one() {
result_valid=0
echo "error: $CELOX_RESULT_DIAGNOSTIC" >&2
fi
if [[ "$runner" == celox-parallel && "$semantic_status" == pass ]] \
if [[ ( "$runner" == celox-parallel || "$runner" == celox-tiered ) \
&& "$HELIODOR_CELOX_THREADS" -gt 1 && "$semantic_status" == pass ]] \
&& ! grep -Fxq "CELOX_TEST_THREADS test=$test threads=$HELIODOR_CELOX_THREADS" "$log"; then
echo "error: celox-parallel log does not record $HELIODOR_CELOX_THREADS threads" >&2
echo "error: $runner log does not record $HELIODOR_CELOX_THREADS threads" >&2
semantic_status=invalid
result_valid=0
fi
Expand Down Expand Up @@ -1733,6 +1735,11 @@ publish_result() {
run_all() {
validate_compile_only_runners || return "$?"
validate_native_image_mode || return "$?"
if runner_enabled celox-tiered \
&& { ! is_uint "$HELIODOR_CELOX_THREADS" || ((HELIODOR_CELOX_THREADS < 1)); }; then
echo "error: HELIODOR_CELOX_THREADS must be at least 1 for celox-tiered" >&2
return 2
fi
prepare
mkdir -p "$HELIODOR_RESULTS_DIR"
ensure_results_schema "$HELIODOR_RESULTS_DIR/results.tsv" || return "$?"
Expand Down
41 changes: 38 additions & 3 deletions scripts/tests/run-heliodor-bench-results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ run_in_heliodor() {
ensure_results_schema "$integration_results/results.tsv"
HELIODOR_COMPILE_ONLY=0
CELOX_OPT_LEVEL=O2
HELIODOR_CELOX_THREADS=4
HELIODOR_CELOX_BUILD_CACHE_DIR="$TMP/build-cache"
CELOX_SIR_PASS_OVERRIDES="-branchify_mux +gvn"
FIXTURE_RESULT_LINE=$'CELOX_TEST_TIMING test=integration_pass compile_ns=20 execute_ns=30 jit_execute_ns=25\nCELOX_TEST_RESULT test=integration_pass status=pass elapsed_ns=71'
Expand Down Expand Up @@ -462,11 +463,13 @@ assert_eq "$(awk -F '\t' 'NR == 8 { print $10 }' "$integration_results/results.t
assert_eq "$(awk -F '\t' 'NR == 8 { print $11 }' "$integration_results/results.tsv")" NA \
"run_one Veryl CLI execute elapsed"

FIXTURE_RESULT_LINE=$'CELOX_TEST_TIMING test=integration_tiered compile_ns=12 execute_ns=34 jit_execute_ns=NA\nCELOX_TIERED_STATS test=integration_tiered tier=compiled promotion=promoted interpreted_evaluations=10 compiled_evaluations=20 promoted_after_interpreted_evaluations=10 promotion_elapsed_ns=15 safe_point_polls=11 split_apply_deferrals=0 threshold_deferrals=0\nCELOX_TEST_RESULT test=integration_tiered status=pass elapsed_ns=48'
FIXTURE_RESULT_LINE=$'CELOX_TEST_THREADS test=integration_tiered threads=4\nCELOX_TEST_TIMING test=integration_tiered compile_ns=12 execute_ns=34 jit_execute_ns=NA\nCELOX_TIERED_STATS test=integration_tiered tier=compiled promotion=promoted interpreted_evaluations=10 compiled_evaluations=20 promoted_after_interpreted_evaluations=10 promotion_elapsed_ns=15 safe_point_polls=11 split_apply_deferrals=0 threshold_deferrals=0\nCELOX_TEST_RESULT test=integration_tiered status=pass elapsed_ns=48'
run_one celox-tiered integration_tiered >/dev/null \
|| fail "run_one rejected a fixture tiered pass"
[[ " ${FIXTURE_RUN_ARGS[*]} " == *" --backend tiered "* ]] \
|| fail "tiered runner did not select the tiered backend"
[[ " ${FIXTURE_RUN_ARGS[*]} " == *" --threads 4 "* ]] \
|| fail "tiered runner did not request parallel execution"
assert_eq "$(awk -F '\t' 'NR == 9 { print $1 }' "$integration_results/results.tsv")" \
celox-tiered "run_one tiered runner name"
assert_eq "$(awk -F '\t' 'NR == 9 { print $12 }' "$integration_results/results.tsv")" NA \
Expand All @@ -486,13 +489,15 @@ assert_eq "$(awk -F '\t' 'NR == 10 { print $1 }' "$integration_results/results.t
# host-qemu mode. Native host codegen is handled separately by run_one.
HELIODOR_CELOX_NATIVE_IMAGE_MODE=host-qemu
CELOX_EXECUTION_PREFIX=(qemu-aarch64 -L /fixture-sysroot)
FIXTURE_RESULT_LINE=$'CELOX_TEST_TIMING test=integration_qemu_tiered compile_ns=12 execute_ns=34 jit_execute_ns=NA\nCELOX_TIERED_STATS test=integration_qemu_tiered tier=compiled promotion=promoted interpreted_evaluations=10 compiled_evaluations=20 promoted_after_interpreted_evaluations=10 promotion_elapsed_ns=15 safe_point_polls=11 split_apply_deferrals=0 threshold_deferrals=0\nCELOX_TEST_RESULT test=integration_qemu_tiered status=pass elapsed_ns=48'
FIXTURE_RESULT_LINE=$'CELOX_TEST_THREADS test=integration_qemu_tiered threads=4\nCELOX_TEST_TIMING test=integration_qemu_tiered compile_ns=12 execute_ns=34 jit_execute_ns=NA\nCELOX_TIERED_STATS test=integration_qemu_tiered tier=compiled promotion=promoted interpreted_evaluations=10 compiled_evaluations=20 promoted_after_interpreted_evaluations=10 promotion_elapsed_ns=15 safe_point_polls=11 split_apply_deferrals=0 threshold_deferrals=0\nCELOX_TEST_RESULT test=integration_qemu_tiered status=pass elapsed_ns=48'
run_one celox-tiered integration_qemu_tiered >/dev/null \
|| fail "run_one rejected a host-qemu tiered fixture"
assert_eq "${FIXTURE_RUN_ARGS[0]}" qemu-aarch64 "tiered execution prefix command"
assert_eq "${FIXTURE_RUN_ARGS[1]}" -L "tiered execution prefix option"
assert_eq "${FIXTURE_RUN_ARGS[2]}" /fixture-sysroot "tiered execution prefix argument"
assert_eq "${FIXTURE_RUN_ARGS[3]}" "$CELOX_RUNNER_BIN" "tiered target runner"
[[ " ${FIXTURE_RUN_ARGS[*]} " == *" --threads 4 "* ]] \
|| fail "ARM tiered runner did not request parallel execution"

FIXTURE_RESULT_LINE=$'CELOX_TEST_TIMING test=integration_qemu_interpreter compile_ns=8 execute_ns=55 jit_execute_ns=NA\nCELOX_TEST_RESULT test=integration_qemu_interpreter status=pass elapsed_ns=65'
run_one celox-interpreter integration_qemu_interpreter >/dev/null \
Expand All @@ -502,6 +507,36 @@ assert_eq "${FIXTURE_RUN_ARGS[3]}" "$CELOX_RUNNER_BIN" "interpreter target runne
HELIODOR_CELOX_NATIVE_IMAGE_MODE=off
CELOX_EXECUTION_PREFIX=()

# A successful result without the requested thread count cannot be published.
FIXTURE_RESULT_LINE=$'CELOX_TEST_TIMING test=tiered_threads compile_ns=12 execute_ns=34 jit_execute_ns=NA\nCELOX_TEST_RESULT test=tiered_threads status=pass elapsed_ns=48'
for marker in "" "CELOX_TEST_THREADS test=tiered_threads threads=2"; do
(
FIXTURE_RESULT_LINE="$marker"$'\n'"$FIXTURE_RESULT_LINE"
if run_one celox-tiered tiered_threads >/dev/null 2>&1; then
fail "tiered accepted a missing or incorrect thread count"
fi
assert_eq "$(tail -n 1 "$integration_results/results.tsv" | cut -f 6)" invalid \
"tiered thread mismatch must invalidate the result"
)
done
(
HELIODOR_CELOX_THREADS=1
run_one celox-tiered tiered_threads >/dev/null \
|| fail "tiered rejected explicit sequential execution"
[[ " ${FIXTURE_RUN_ARGS[*]} " == *" --threads 1 "* ]] \
|| fail "tiered did not honor the sequential override"
)
for invalid_threads in 0 -1 invalid; do
(
HELIODOR_RUNNERS=celox-tiered
HELIODOR_CELOX_THREADS="$invalid_threads"
prepare() { fail "invalid thread count reached benchmark preparation"; }
status=0
run_all >/dev/null 2>&1 || status=$?
assert_eq "$status" 2 "invalid tiered thread count"
)
done

previous_cache="$FIXTURE_AOT_CACHE_DIR"
FIXTURE_RESULT_LINE=$'VERYL_TEST_CONFIG test=integration_veryl_tiered backend=cc aot_c_async=true compile_only=false\nVERYL_TEST_TIMING test=integration_veryl_tiered compile_ns=8 execute_ns=50\nVERYL_TIERED_STATS test=integration_veryl_tiered compiled_dispatches=100 fallback_dispatches=200\nVERYL_TEST_RESULT test=integration_veryl_tiered status=pass elapsed_ns=59'
run_one veryl-cc-tiered integration_veryl_tiered >/dev/null \
Expand Down Expand Up @@ -552,7 +587,7 @@ fi
HELIODOR_PUBLISH_ARCH=x86_64
HELIODOR_COMPILE_ONLY=0
HELIODOR_CELOX_NATIVE_IMAGE_MODE=off
FIXTURE_RESULT_LINE=$'CELOX_TEST_TIMING test=publish_tiered compile_ns=12 execute_ns=34 jit_execute_ns=NA\nCELOX_TIERED_STATS test=publish_tiered tier=compiled promotion=promoted interpreted_evaluations=10 compiled_evaluations=20 promoted_after_interpreted_evaluations=10 promotion_elapsed_ns=15 safe_point_polls=11 split_apply_deferrals=0 threshold_deferrals=0\nCELOX_TEST_RESULT test=publish_tiered status=pass elapsed_ns=48'
FIXTURE_RESULT_LINE=$'CELOX_TEST_THREADS test=publish_tiered threads=4\nCELOX_TEST_TIMING test=publish_tiered compile_ns=12 execute_ns=34 jit_execute_ns=NA\nCELOX_TIERED_STATS test=publish_tiered tier=compiled promotion=promoted interpreted_evaluations=10 compiled_evaluations=20 promoted_after_interpreted_evaluations=10 promotion_elapsed_ns=15 safe_point_polls=11 split_apply_deferrals=0 threshold_deferrals=0\nCELOX_TEST_RESULT test=publish_tiered status=pass elapsed_ns=48'
run_one celox-tiered publish_tiered >/dev/null \
|| fail "publishing rejected a completed tiered run"
FIXTURE_RESULT_LINE="${FIXTURE_RESULT_LINE/compiled_evaluations=20/compiled_evaluations=0}"
Expand Down
Loading