added chunked Pi calculations test for fork vs thread

This commit is contained in:
2026-05-26 17:18:48 +03:00
parent 34d7c37f8a
commit c9a4b7f85d
7 changed files with 894 additions and 0 deletions
+29
View File
@@ -156,9 +156,16 @@ compile_thread_recursive() {
"$ROOT_DIR/thread_recursive_scaling/thread_recursive.c" -lm
}
compile_pi_digits_benchmark() {
log "Compiling pi_digits_benchmark"
gcc -O2 -pthread -o "$ROOT_DIR/pi_digits_benchmark/pi_digits_benchmark" \
"$ROOT_DIR/pi_digits_benchmark/pi_digits_benchmark.c"
}
compile_creation_time
compile_fork_bomb
compile_thread_recursive
compile_pi_digits_benchmark
# Defaults (override by env vars)
ALLOW_DANGEROUS=${ALLOW_DANGEROUS:-0}
@@ -166,6 +173,10 @@ FORK_BOMB_SECONDS=${FORK_BOMB_SECONDS:-5}
CREATION_TIME_ITERS=${CREATION_TIME_ITERS:-"100 1000 10000"}
CREATION_TIME_SECONDS=${CREATION_TIME_SECONDS:-60}
PROC_SAMPLE_STEP=${PROC_SAMPLE_STEP:-50}
THREAD_COUNT=${THREAD_COUNT:-4}
PROCESS_COUNT=${PROCESS_COUNT:-4}
PI_DIGITS=${PI_DIGITS:-2000}
CHUNK_SIZE=${CHUNK_SIZE:-500}
CREATION_TIME_STDOUT="$OUT_DIR/creation_time_stdout.log"
CREATION_TIME_STDERR="$OUT_DIR/creation_time_stderr.log"
@@ -200,5 +211,23 @@ run_with_sampling \
"$OUT_DIR/thread_recursive_scaling.csv" \
0
PI_BENCH_OUT_BASE="$OUT_DIR/pi_digits_benchmark"
PI_THREAD_STDOUT="$OUT_DIR/pi_digits_thread_stdout.log"
PI_THREAD_STDERR="$OUT_DIR/pi_digits_thread_stderr.log"
PI_PROC_STDOUT="$OUT_DIR/pi_digits_process_stdout.log"
PI_PROC_STDERR="$OUT_DIR/pi_digits_process_stderr.log"
run_with_sampling \
"pi_digits_benchmark_thread" \
"cd '$ROOT_DIR/pi_digits_benchmark' && THREAD_COUNT='$THREAD_COUNT' PROCESS_COUNT='$PROCESS_COUNT' PI_DIGITS='$PI_DIGITS' CHUNK_SIZE='$CHUNK_SIZE' ./pi_digits_benchmark --mode thread --out-dir '$PI_BENCH_OUT_BASE/thread' >'$PI_THREAD_STDOUT' 2>'$PI_THREAD_STDERR'" \
"$OUT_DIR/pi_digits_thread.csv" \
0
run_with_sampling \
"pi_digits_benchmark_process" \
"cd '$ROOT_DIR/pi_digits_benchmark' && THREAD_COUNT='$THREAD_COUNT' PROCESS_COUNT='$PROCESS_COUNT' PI_DIGITS='$PI_DIGITS' CHUNK_SIZE='$CHUNK_SIZE' ./pi_digits_benchmark --mode process --out-dir '$PI_BENCH_OUT_BASE/process' >'$PI_PROC_STDOUT' 2>'$PI_PROC_STDERR'" \
"$OUT_DIR/pi_digits_process.csv" \
0
log "All experiments finished"
log "Run directory: $OUT_DIR"