diff --git a/benches/bench.env b/benches/bench.env index 9ff802b99..aadae61f7 100644 --- a/benches/bench.env +++ b/benches/bench.env @@ -1,2 +1,3 @@ # Arecibo config, used only in `justfile` by default -ARECIBO_BENCH_NUM_CONS=16384,1048576 +BENCH_NUM_CONS=16384,1048576 +BENCH_OUTPUT=commit-comment \ No newline at end of file diff --git a/benches/common/mod.rs b/benches/common/mod.rs index 3afbaf146..2233aca69 100644 --- a/benches/common/mod.rs +++ b/benches/common/mod.rs @@ -36,13 +36,13 @@ impl BenchParams { } fn output_type_env() -> anyhow::Result { - std::env::var("ARECIBO_BENCH_OUTPUT") - .map_err(|e| anyhow!("ARECIBO_BENCH_OUTPUT env var isn't set: {e}")) + std::env::var("BENCH_OUTPUT") + .map_err(|e| anyhow!("BENCH_OUTPUT env var isn't set: {e}")) } pub(crate) fn noise_threshold_env() -> anyhow::Result { - std::env::var("ARECIBO_BENCH_NOISE_THRESHOLD") - .map_err(|e| anyhow!("ARECIBO_BENCH_NOISE_THRESHOLD env var isn't set: {e}")) + std::env::var("BENCH_NOISE_THRESHOLD") + .map_err(|e| anyhow!("BENCH_NOISE_THRESHOLD env var isn't set: {e}")) .and_then(|nt| { nt.parse::() .map_err(|e| anyhow!("Failed to parse noise threshold: {e}")) diff --git a/benches/common/supernova/mod.rs b/benches/common/supernova/mod.rs index 5b74c3dbe..9e4132a68 100644 --- a/benches/common/supernova/mod.rs +++ b/benches/common/supernova/mod.rs @@ -54,8 +54,8 @@ pub fn num_cons() -> Vec { } fn num_cons_env() -> anyhow::Result> { - std::env::var("ARECIBO_BENCH_NUM_CONS") - .map_err(|e| anyhow!("ARECIBO_BENCH_NUM_CONS env var not set: {e}")) + std::env::var("BENCH_NUM_CONS") + .map_err(|e| anyhow!("BENCH_NUM_CONS env var not set: {e}")) .and_then(|rc| { let vec: anyhow::Result> = rc .split(',') diff --git a/benches/justfile b/benches/justfile index 6d7061897..557c2770a 100644 --- a/benches/justfile +++ b/benches/justfile @@ -9,8 +9,10 @@ commit := `git rev-parse HEAD` # Run CPU benchmarks bench +benches: #!/bin/sh + [ $(uname -m) = "x86_64" ] && FEATURES="asm" || FEATURES="default" + for bench in {{benches}}; do - cargo criterion --bench $bench + cargo criterion --bench $bench --features $FEATURES done # Run CUDA benchmarks on GPU @@ -22,6 +24,7 @@ gpu-bench +benches: export CUDA_ARCH=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader | sed 's/\.//g') export EC_GPU_CUDA_NVCC_ARGS="--fatbin --gpu-architecture=sm_$CUDA_ARCH --generate-code=arch=compute_$CUDA_ARCH,code=sm_$CUDA_ARCH" export EC_GPU_FRAMEWORK="cuda" + [ $(uname -m) = "x86_64" ] && FEATURES="cuda, asm" || FEATURES="cuda" for bench in {{benches}}; do cargo criterion --bench $bench --features "cuda" @@ -31,12 +34,23 @@ gpu-bench +benches: gpu-bench-ci +benches: #!/bin/sh printenv PATH - if [ $(uname -m) = "x86_64" ]; then - FEATURES="cuda,asm" - else - FEATURES="cuda" + [ $(uname -m) = "x86_64" ] && FEATURES="cuda, asm" || FEATURES="cuda" + + for bench in {{benches}}; do + cargo criterion --bench $bench --features $FEATURES --message-format=json > "$bench-{{commit}}".json + done + +comparative-bench +benches: + #!/bin/sh + # Initialize FEATURES based on architecture + [ $(uname -m) = "x86_64" ] && FEATURES="asm" || FEATURES="" + # Append cuda to FEATURES if nvcc is found + if which nvcc > /dev/null; then + FEATURES="${FEATURES:+$FEATURES,}cuda" fi + # add default if FEATURES is empty + FEATURES="${FEATURES:-default}" for bench in {{benches}}; do cargo criterion --bench $bench --features $FEATURES --message-format=json > "$bench-{{commit}}".json - done \ No newline at end of file + done