-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_spec_benchmarks_sim_parallel.sh
More file actions
executable file
·588 lines (514 loc) · 21.1 KB
/
run_spec_benchmarks_sim_parallel.sh
File metadata and controls
executable file
·588 lines (514 loc) · 21.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
#!/bin/bash
#====================================================================
# SPEC CPU2006/2017 SPARC V8 Benchmark Runner for sim-inorder
# Runs all SPEC benchmarks on sim-inorder simulator in PARALLEL
#
# Benchmarks: 19 total (13 from CPU2006, 6 from CPU2017)
# All binaries are pure SPARC V8, statically linked
#====================================================================
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BENCH_DIR="$SCRIPT_DIR/SPEC_benchmarks"
INPUT_DIR="$BENCH_DIR/input_data"
OUTPUT_DIR="/tmp/spec_outputs_sim"
LOG_DIR="/tmp/spec_logs_sim"
SIM_INORDER="$SCRIPT_DIR/sim-inorder"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Default settings
TIMEOUT=0
RUN_ALL=1
QUICK_MODE=0
VERBOSE=0
PARALLEL=1
MAX_JOBS=0 # 0 = unlimited (number of CPUs)
MAX_INST=0 # Default: 0 = unlimited
usage() {
echo "Usage: $0 [OPTIONS] [BENCHMARK...]"
echo ""
echo "Options:"
echo " -h, --help Show this help message"
echo " -q, --quick Quick mode (shorter test parameters, 10M instructions)"
echo " -v, --verbose Verbose output"
echo " -t, --timeout N Set timeout in seconds (default: disabled)"
echo " -l, --list List available benchmarks"
echo " -s, --serial Run benchmarks serially (not parallel)"
echo " -j, --jobs N Maximum parallel jobs (default: all CPUs)"
echo " -m, --max-inst N Maximum instructions to execute (default: 100M)"
echo ""
echo "Benchmarks: specrand, mcf, bzip2, hmmer, sjeng, libquantum,"
echo " lbm, gobmk, namd, povray, deepsjeng, all"
echo ""
echo "Example: $0 -q mcf bzip2 # Run mcf and bzip2 in quick mode"
echo " $0 -j 4 # Run with max 4 parallel jobs"
echo " $0 -m 50000000 # Run with 50M instructions max"
echo " $0 --list # List all benchmarks"
exit 0
}
list_benchmarks() {
echo "Available SPEC Benchmarks:"
echo ""
echo "SPEC CPU2006:"
echo " specrand_int - Random number generator (integer)"
echo " specrand_fp - Random number generator (floating-point)"
echo " bzip2 - Compression (401.bzip2)"
echo " mcf - Network simplex (429.mcf)"
echo " hmmer - HMM calibration (456.hmmer)"
echo " sjeng - Chess engine (458.sjeng)"
echo " libquantum - Quantum simulation (462.libquantum)"
echo " lbm - Lattice Boltzmann (470.lbm)"
echo " gobmk - Go game - GNU Go (445.gobmk)"
echo " sphinx3 - Speech recognition (482.sphinx3)"
echo " namd - Molecular dynamics (444.namd)"
echo " povray - Ray tracing (453.povray)"
echo " h264ref - Video encoding (464.h264ref)"
echo ""
echo "SPEC CPU2017:"
echo " specrand_ir - Random number generator"
echo " mcf_r - Network simplex (505.mcf_r)"
echo " lbm_r - Lattice Boltzmann (519.lbm_r)"
echo " deepsjeng - Chess engine (531.deepsjeng_r)"
echo " namd_r - Molecular dynamics (508.namd_r)"
echo " povray_r - Ray tracing (511.povray_r)"
exit 0
}
# Parse arguments
BENCHMARKS=()
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help) usage ;;
-q|--quick) QUICK_MODE=1; shift ;;
-v|--verbose) VERBOSE=1; shift ;;
-t|--timeout) TIMEOUT="$2"; shift 2 ;;
-l|--list) list_benchmarks ;;
-s|--serial) PARALLEL=0; shift ;;
-j|--jobs) MAX_JOBS="$2"; shift 2 ;;
-m|--max-inst) MAX_INST="$2"; shift 2 ;;
*) BENCHMARKS+=("$1"); RUN_ALL=0; shift ;;
esac
done
# Setup directories
mkdir -p "$OUTPUT_DIR"
mkdir -p "$LOG_DIR"
rm -f "$LOG_DIR"/*.log "$LOG_DIR"/*.status 2>/dev/null
echo -e "${BLUE}=========================================="
echo "SPEC CPU2006/2017 sim-inorder Benchmark Suite"
echo " *** PARALLEL MODE ***"
echo -e "==========================================${NC}"
echo ""
echo "Simulator: $SIM_INORDER"
echo "Benchmark directory: $BENCH_DIR"
echo "Timeout: ${TIMEOUT}s"
[ $MAX_INST -gt 0 ] && echo "Max instructions: $MAX_INST"
[ $QUICK_MODE -eq 1 ] && echo "Mode: QUICK"
[ $PARALLEL -eq 1 ] && echo -e "Execution: ${CYAN}PARALLEL${NC}" || echo "Execution: SERIAL"
[ $MAX_JOBS -gt 0 ] && echo "Max parallel jobs: $MAX_JOBS"
echo ""
# Check if sim-inorder is available
if [ ! -x "$SIM_INORDER" ]; then
echo -e "${RED}ERROR: sim-inorder not found or not executable: $SIM_INORDER${NC}"
exit 1
fi
# Check if benchmark directory exists
if [ ! -d "$BENCH_DIR" ]; then
echo -e "${RED}ERROR: Benchmark directory not found: $BENCH_DIR${NC}"
exit 1
fi
# Function to run a single benchmark (can be called in background)
run_benchmark_job() {
local name="$1"
local binary="$2"
local args="$3"
local description="$4"
local bench_max_inst="${5:-0}" # Per-benchmark instruction limit
local log_file="$LOG_DIR/${name}.log"
local status_file="$LOG_DIR/${name}.status"
# Determine effective max_inst (per-benchmark overrides global)
local effective_max_inst=$MAX_INST
if [ "$bench_max_inst" -gt 0 ] 2>/dev/null; then
effective_max_inst=$bench_max_inst
fi
{
echo "=== $name ==="
echo "Binary: $binary"
echo "Arguments: $args"
echo "Description: $description"
[ $effective_max_inst -gt 0 ] && echo "Max instructions: $effective_max_inst"
echo ""
if [ ! -f "$binary" ]; then
echo "ERROR: Binary not found"
echo "MISSING" > "$status_file"
exit 1
fi
local start_time=$(date +%s.%N)
# Build simulator options
local sim_opts=""
[ $effective_max_inst -gt 0 ] && sim_opts="-max:inst $effective_max_inst"
# Special handling for benchmarks that need to run from input_data directory
local run_cmd=""
if [[ "$name" == "sphinx3_cpu2006" ]] || [[ "$name" == "h264ref_cpu2006" ]] || [[ "$name" == "povray_cpu2006" ]] || [[ "$name" == "povray_r_cpu2017" ]]; then
run_cmd="cd $INPUT_DIR && $SIM_INORDER $sim_opts $binary $args"
elif [[ "$name" == "gobmk_cpu2006" ]]; then
# gobmk needs stdin redirection from capture.tst with quit command appended
run_cmd="cd $INPUT_DIR && (cat capture.tst; echo quit) | $SIM_INORDER $sim_opts $binary $args"
else
run_cmd="$SIM_INORDER $sim_opts $binary $args"
fi
# Run with or without timeout, capturing output to temp file
local temp_output=$(mktemp)
if [ $TIMEOUT -gt 0 ]; then
timeout $TIMEOUT bash -c "$run_cmd" > "$temp_output" 2>&1
else
bash -c "$run_cmd" > "$temp_output" 2>&1
fi
local exit_code=$?
# Output the results
cat "$temp_output"
local end_time=$(date +%s.%N)
local elapsed=$(echo "$end_time - $start_time" | bc 2>/dev/null || echo "N/A")
# Extract instruction count to determine if simulation ran successfully
local insn_count=$(grep "sim_num_insn" "$temp_output" | awk '{print $2}')
rm -f "$temp_output"
echo ""
# Check if simulation ran successfully (has instruction count > 0)
# Some benchmarks may return non-zero exit code but still complete meaningful execution
if [ $exit_code -eq 124 ] && [ $TIMEOUT -gt 0 ]; then
echo "Status: TIMEOUT - exceeded ${TIMEOUT}s"
echo "TIMEOUT:${TIMEOUT}" > "$status_file"
elif [ -n "$insn_count" ] && [ "$insn_count" -gt 0 ] 2>/dev/null; then
echo "Status: PASS - ${elapsed}s"
echo "PASS:${elapsed}" > "$status_file"
elif [ $exit_code -eq 0 ]; then
echo "Status: PASS - ${elapsed}s"
echo "PASS:${elapsed}" > "$status_file"
else
echo "Status: FAIL - exit code: $exit_code"
echo "FAIL:${exit_code}" > "$status_file"
fi
} > "$log_file" 2>&1
}
should_run() {
local bench="$1"
if [ $RUN_ALL -eq 1 ]; then
return 0
fi
for b in "${BENCHMARKS[@]}"; do
if [[ "$b" == "$bench" ]] || [[ "$b" == "all" ]]; then
return 0
fi
done
return 1
}
# Array to hold all benchmark jobs
declare -a JOBS
declare -a JOB_NAMES
add_job() {
local name="$1"
local binary="$2"
local args="$3"
local description="$4"
local max_inst="${5:-0}" # Optional per-benchmark instruction limit (0 = use global)
JOBS+=("$name|$binary|$args|$description|$max_inst")
JOB_NAMES+=("$name")
}
#====================================================================
# Define all benchmarks
#====================================================================
# specrand_int_cpu2006
if should_run "specrand" || should_run "specrand_int"; then
if [ $QUICK_MODE -eq 1 ]; then
add_job "specrand_int_cpu2006" "$BENCH_DIR/specrand_int_cpu2006" "1 10" "Random number generator - integer"
else
add_job "specrand_int_cpu2006" "$BENCH_DIR/specrand_int_cpu2006" "1 1000" "Random number generator - integer"
fi
fi
# specrand_fp_cpu2006
if should_run "specrand" || should_run "specrand_fp"; then
if [ $QUICK_MODE -eq 1 ]; then
add_job "specrand_fp_cpu2006" "$BENCH_DIR/specrand_fp_cpu2006" "1 10" "Random number generator - floating-point"
else
add_job "specrand_fp_cpu2006" "$BENCH_DIR/specrand_fp_cpu2006" "1 1000" "Random number generator - floating-point"
fi
fi
# bzip2_cpu2006
# NOTE: bzip2 compresses at multiple levels (5, 7, 9).
# Argument 1 = 1MB buffer (~528M instructions, ~24 min on sim-inorder)
# Argument 2 = 2MB buffer (billions of instructions, hours on sim-inorder)
if should_run "bzip2"; then
add_job "bzip2_cpu2006" "$BENCH_DIR/bzip2_cpu2006" "$INPUT_DIR/dryer.jpg 1" "Compression benchmark (1MB buffer)"
fi
# mcf_cpu2006
if should_run "mcf"; then
add_job "mcf_cpu2006" "$BENCH_DIR/mcf_cpu2006" "$INPUT_DIR/mcf_cpu2006.in" "Network simplex algorithm"
fi
# hmmer_cpu2006
# Note: Each sample takes ~500K instructions, so num=100 takes ~56M instructions (~10s)
# Quick mode uses num=100 (fast), normal mode uses num=200 (reasonable for simulator)
if should_run "hmmer"; then
if [ $QUICK_MODE -eq 1 ]; then
add_job "hmmer_cpu2006" "$BENCH_DIR/hmmer_cpu2006" "--fixed 0 --mean 325 --num 100 --sd 200 --seed 0 $INPUT_DIR/bombesin.hmm" "HMM calibration (100 samples)"
else
add_job "hmmer_cpu2006" "$BENCH_DIR/hmmer_cpu2006" "--fixed 0 --mean 325 --num 200 --sd 200 --seed 0 $INPUT_DIR/bombesin.hmm" "HMM calibration (200 samples)"
fi
fi
# sjeng_cpu2006
if should_run "sjeng"; then
add_job "sjeng_cpu2006" "$BENCH_DIR/sjeng_cpu2006" "$INPUT_DIR/sjeng_cpu2006.txt" "Chess analysis - Sjeng"
fi
# libquantum_cpu2006
if should_run "libquantum"; then
if [ $QUICK_MODE -eq 1 ]; then
add_job "libquantum_cpu2006" "$BENCH_DIR/libquantum_cpu2006" "33 5" "Quantum factoring (33 = ?)"
else
add_job "libquantum_cpu2006" "$BENCH_DIR/libquantum_cpu2006" "143 25" "Quantum factoring (143 = ?)"
fi
fi
# lbm_cpu2006
if should_run "lbm"; then
if [ $QUICK_MODE -eq 1 ]; then
add_job "lbm_cpu2006" "$BENCH_DIR/lbm_cpu2006" "1 $OUTPUT_DIR/lbm2006.out 0 1 $INPUT_DIR/100_100_130_cf_a.of" "Lattice Boltzmann fluid dynamics (1 step)"
else
add_job "lbm_cpu2006" "$BENCH_DIR/lbm_cpu2006" "1 $OUTPUT_DIR/lbm2006.out 0 1 $INPUT_DIR/100_100_130_cf_a.of" "Lattice Boltzmann fluid dynamics (1 step)"
fi
fi
# gobmk_cpu2006
if should_run "gobmk"; then
add_job "gobmk_cpu2006" "$BENCH_DIR/gobmk_cpu2006" "--mode gtp" "GNU Go (Go game engine) - capture test"
fi
# namd_cpu2006
if should_run "namd"; then
if [ $QUICK_MODE -eq 1 ]; then
add_job "namd_cpu2006" "$BENCH_DIR/namd_cpu2006" "--input $INPUT_DIR/namd.input --iterations 1 --output $OUTPUT_DIR/namd2006.out" "Molecular dynamics - 1 iteration"
else
add_job "namd_cpu2006" "$BENCH_DIR/namd_cpu2006" "--input $INPUT_DIR/namd.input --iterations 1 --output $OUTPUT_DIR/namd2006.out" "Molecular dynamics"
fi
fi
# povray_cpu2006
if should_run "povray"; then
add_job "povray_cpu2006" "$BENCH_DIR/povray_cpu2006" "SPEC-benchmark-test.ini" "POV-Ray ray tracer (test scene)"
fi
# sphinx3_cpu2006
# NOTE: Using ctlfile_small (1 audio file) instead of ctlfile (2 files) due to assertion failure
# in model loading. The benchmark runs 2.4B instructions before hitting the assertion.
if should_run "sphinx3"; then
add_job "sphinx3_cpu2006" "$BENCH_DIR/sphinx3_cpu2006" "ctlfile_small . args.an4" "CMU Sphinx3 speech recognition (1 file)"
fi
# h264ref_cpu2006
# NOTE: h264ref encodes video. Test config encodes 25 frames (~3.4M instructions).
# Full config encodes all 300 frames (~40M+ instructions).
# Quick mode: 25 frames (test config), Normal mode: 300 frames (full config)
if should_run "h264ref"; then
if [ $QUICK_MODE -eq 1 ]; then
add_job "h264ref_cpu2006" "$BENCH_DIR/h264ref_cpu2006" "-d foreman_test_encoder_baseline.cfg" "H.264 video encoding (25 frames)"
else
add_job "h264ref_cpu2006" "$BENCH_DIR/h264ref_cpu2006" "-d foreman_encoder_300frames.cfg" "H.264 video encoding (300 frames)"
fi
fi
# specrand_ir_cpu2017
if should_run "specrand" || should_run "specrand_ir"; then
if [ $QUICK_MODE -eq 1 ]; then
add_job "specrand_ir_cpu2017" "$BENCH_DIR/specrand_ir_cpu2017" "1 10" "Random number generator"
else
add_job "specrand_ir_cpu2017" "$BENCH_DIR/specrand_ir_cpu2017" "1 1000" "Random number generator"
fi
fi
# mcf_r_cpu2017
if should_run "mcf" || should_run "mcf_r"; then
add_job "mcf_r_cpu2017" "$BENCH_DIR/mcf_r_cpu2017" "$INPUT_DIR/mcf_r_cpu2017.in" "Network simplex algorithm"
fi
# lbm_r_cpu2017
if should_run "lbm" || should_run "lbm_r"; then
if [ $QUICK_MODE -eq 1 ]; then
add_job "lbm_r_cpu2017" "$BENCH_DIR/lbm_r_cpu2017" "1 $OUTPUT_DIR/lbm2017.out 0 1 $INPUT_DIR/100_100_130_cf_a.of" "Lattice Boltzmann fluid dynamics (1 step)"
else
add_job "lbm_r_cpu2017" "$BENCH_DIR/lbm_r_cpu2017" "1 $OUTPUT_DIR/lbm2017.out 0 1 $INPUT_DIR/100_100_130_cf_a.of" "Lattice Boltzmann fluid dynamics (1 step)"
fi
fi
# deepsjeng_r_cpu2017
# NOTE: Deep Sjeng is a chess engine that searches to 15 ply depth. This requires
# billions of instructions to complete fully.
if should_run "deepsjeng"; then
add_job "deepsjeng_r_cpu2017" "$BENCH_DIR/deepsjeng_r_cpu2017" "$INPUT_DIR/deepsjeng_r_cpu2017.txt" "Chess analysis (Deep Sjeng)"
fi
# namd_r_cpu2017
if should_run "namd" || should_run "namd_r"; then
if [ $QUICK_MODE -eq 1 ]; then
add_job "namd_r_cpu2017" "$BENCH_DIR/namd_r_cpu2017" "--input $INPUT_DIR/apoa1.input --iterations 1 --output $OUTPUT_DIR/namd2017.out" "Molecular dynamics - 1 iteration"
else
add_job "namd_r_cpu2017" "$BENCH_DIR/namd_r_cpu2017" "--input $INPUT_DIR/apoa1.input --iterations 1 --output $OUTPUT_DIR/namd2017.out" "Molecular dynamics"
fi
fi
# povray_r_cpu2017
if should_run "povray" || should_run "povray_r"; then
add_job "povray_r_cpu2017" "$BENCH_DIR/povray_r_cpu2017" "SPEC-benchmark-test.ini" "POV-Ray ray tracer (test scene)"
fi
#====================================================================
# Execute benchmarks
#====================================================================
NUM_JOBS=${#JOBS[@]}
echo -e "${CYAN}Starting $NUM_JOBS benchmarks...${NC}"
echo ""
START_TIME=$(date +%s)
if [ $PARALLEL -eq 1 ]; then
#----------------------------------------------------------------
# PARALLEL EXECUTION
#----------------------------------------------------------------
echo -e "${CYAN}Launching all benchmarks in parallel...${NC}"
echo ""
# Track PIDs
declare -a PIDS
# Launch all jobs
job_count=0
for job in "${JOBS[@]}"; do
IFS='|' read -r name binary args description max_inst <<< "$job"
# If MAX_JOBS is set, wait for a slot
if [ $MAX_JOBS -gt 0 ]; then
while [ $(jobs -r | wc -l) -ge $MAX_JOBS ]; do
sleep 0.1
done
fi
echo -e " ${BLUE}[LAUNCH]${NC} $name"
run_benchmark_job "$name" "$binary" "$args" "$description" "$max_inst" &
PIDS+=($!)
((job_count++))
done
echo ""
echo -e "${CYAN}All $job_count benchmarks launched. Waiting for completion...${NC}"
echo ""
# Progress monitoring
completed=0
while [ $completed -lt $NUM_JOBS ]; do
sleep 1
completed=0
running=0
for name in "${JOB_NAMES[@]}"; do
if [ -f "$LOG_DIR/${name}.status" ]; then
((completed++))
else
((running++))
fi
done
printf "\r Progress: %d/%d completed, %d running... " $completed $NUM_JOBS $running
done
echo ""
echo ""
# Wait for all background jobs
for pid in "${PIDS[@]}"; do
wait $pid 2>/dev/null
done
else
#----------------------------------------------------------------
# SERIAL EXECUTION
#----------------------------------------------------------------
echo "Running benchmarks sequentially..."
echo ""
for job in "${JOBS[@]}"; do
IFS='|' read -r name binary args description max_inst <<< "$job"
echo -e "${YELLOW}=== $name ===${NC}"
run_benchmark_job "$name" "$binary" "$args" "$description" "$max_inst"
# Show result immediately
if [ -f "$LOG_DIR/${name}.status" ]; then
status=$(cat "$LOG_DIR/${name}.status")
result=$(echo "$status" | cut -d: -f1)
if [ "$result" == "PASS" ]; then
echo -e " ${GREEN}PASS${NC}"
elif [ "$result" == "TIMEOUT" ]; then
echo -e " ${YELLOW}TIMEOUT${NC}"
else
echo -e " ${RED}FAIL${NC}"
fi
fi
echo ""
done
fi
END_TIME=$(date +%s)
TOTAL_TIME=$((END_TIME - START_TIME))
#====================================================================
# Collect and display results
#====================================================================
echo -e "${BLUE}=========================================="
echo "BENCHMARK RESULTS SUMMARY"
echo -e "==========================================${NC}"
echo ""
PASS=0
FAIL=0
TIMEOUT_COUNT=0
MISSING=0
# Sort and display results
printf "%-25s %-10s %-15s\n" "BENCHMARK" "STATUS" "TIME"
printf "%-25s %-10s %-15s\n" "-------------------------" "----------" "---------------"
for name in "${JOB_NAMES[@]}"; do
status_file="$LOG_DIR/${name}.status"
if [ -f "$status_file" ]; then
status=$(cat "$status_file")
result=$(echo "$status" | cut -d: -f1)
time_or_code=$(echo "$status" | cut -d: -f2)
if [ "$result" == "PASS" ]; then
printf "%-25s ${GREEN}%-10s${NC} %ss\n" "$name" "PASS" "$time_or_code"
((PASS++))
elif [ "$result" == "TIMEOUT" ]; then
printf "%-25s ${YELLOW}%-10s${NC} >%ss\n" "$name" "TIMEOUT" "$time_or_code"
((TIMEOUT_COUNT++))
elif [ "$result" == "MISSING" ]; then
printf "%-25s ${RED}%-10s${NC} -\n" "$name" "MISSING"
((MISSING++))
else
printf "%-25s ${RED}%-10s${NC} exit:%s\n" "$name" "FAIL" "$time_or_code"
((FAIL++))
fi
else
printf "%-25s ${RED}%-10s${NC} -\n" "$name" "NO STATUS"
((FAIL++))
fi
done
echo ""
printf "%-25s %-10s %-15s\n" "-------------------------" "----------" "---------------"
echo ""
echo -e "${GREEN}Passed: $PASS${NC}"
echo -e "${YELLOW}Timeout: $TIMEOUT_COUNT${NC} - acceptable for long-running benchmarks"
echo -e "${RED}Failed: $FAIL${NC}"
echo -e "${RED}Missing: $MISSING${NC}"
echo ""
echo -e "${CYAN}Total wall-clock time: ${TOTAL_TIME}s${NC}"
echo ""
# Extract and display simulation statistics
echo -e "${BLUE}=========================================="
echo "SIMULATION STATISTICS SUMMARY"
echo -e "==========================================${NC}"
echo ""
printf "%-25s %-15s %-12s\n" "BENCHMARK" "INSTRUCTIONS" "IPC"
printf "%-25s %-15s %-12s\n" "-------------------------" "---------------" "------------"
for name in "${JOB_NAMES[@]}"; do
log_file="$LOG_DIR/${name}.log"
if [ -f "$log_file" ]; then
insn=$(grep "sim_num_insn" "$log_file" | head -1 | awk '{print $2}')
ipc=$(grep "sim_IPC" "$log_file" | head -1 | awk '{print $2}')
[ -z "$insn" ] && insn="-"
[ -z "$ipc" ] && ipc="-"
printf "%-25s %-15s %-12s\n" "$name" "$insn" "$ipc"
fi
done
echo ""
# Show verbose output option
if [ $VERBOSE -eq 1 ]; then
echo -e "${BLUE}=========================================="
echo "DETAILED LOGS"
echo -e "==========================================${NC}"
for name in "${JOB_NAMES[@]}"; do
echo ""
echo -e "${YELLOW}=== $name ===${NC}"
if [ -f "$LOG_DIR/${name}.log" ]; then
tail -50 "$LOG_DIR/${name}.log"
fi
done
fi
echo ""
echo -e "${BLUE}==========================================${NC}"
echo "Log files saved in: $LOG_DIR"
echo "To view a specific log: cat $LOG_DIR/<benchmark_name>.log"
echo -e "${BLUE}==========================================${NC}"
exit $((FAIL + MISSING))