Skip to content

Commit def3aa2

Browse files
committed
Add count_accelerators and run on pbrt
1 parent 97dc374 commit def3aa2

File tree

5 files changed

+51
-11
lines changed

5 files changed

+51
-11
lines changed

growlibm/count_accelerators.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -ne 2 ]; then
4+
echo "Error: Incorrect number of arguments."
5+
echo "Usage: $0 <accelerators_file> <search_file>"
6+
exit 1
7+
fi
8+
9+
ACCELERATORS_FILE=$1
10+
SEARCH_FILE=$2
11+
TEMP_FILE=$(mktemp)
12+
13+
if [ ! -f "$ACCELERATORS_FILE" ]; then
14+
echo "Error: Accelerator file not found at '$ACCELERATORS_FILE'"
15+
exit 1
16+
fi
17+
18+
if [ ! -f "$SEARCH_FILE" ]; then
19+
echo "Error: Search file not found at '$SEARCH_FILE'"
20+
exit 1
21+
fi
22+
23+
while IFS= read -r line || [[ -n "$line" ]]; do
24+
if [[ "$line" =~ ^[0-9]+- ]]; then
25+
accelerator_id=$(echo "$line" | cut -d',' -f1)
26+
27+
count=$(grep -o -w "$accelerator_id" "$SEARCH_FILE" | wc -l)
28+
29+
echo "$line, $count" >> "$TEMP_FILE"
30+
else
31+
echo "$line" >> "$TEMP_FILE"
32+
fi
33+
done < "$ACCELERATORS_FILE"
34+
35+
mv "$TEMP_FILE" "$ACCELERATORS_FILE"

growlibm/extend-platform.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
(displayln operatorStr))
7777
#:exists 'append)
7878

79-
(with-output-to-file "reports/report_info.csv"
79+
(with-output-to-file "reports/report_info.txt"
8080
(lambda ()
8181
(displayln (format "~a, ~a" link spec)))
8282
#:exists 'append)

growlibm/generate-candidates.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@
130130
(define renamed-subexprs (map rename-vars filtered-again))
131131
(define pairs (hash->list (count-frequencies renamed-subexprs)))
132132

133-
(with-output-to-file (string-append report-dir "/report_info.csv")
133+
(with-output-to-file (string-append report-dir "/report_info.txt")
134134
(lambda ()
135135
(printf "og length, ~a\n"(length pairs)))
136136
#:exists 'replace)
137137

138138
(define deduplicated-pairs (hash->list (deduplicate pairs)))
139139

140-
(with-output-to-file (string-append report-dir "/report_info.csv")
140+
(with-output-to-file (string-append report-dir "/report_info.txt")
141141
(lambda ()
142142
(printf "deduped length, ~a\n"(length deduplicated-pairs)))
143143
#:exists 'append)

growlibm/generate-html.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import json
22

3-
# --- 1. Configuration ---
43
START_REPORT_PATH = 'reports/start/results.json'
54
END_REPORT_PATH = 'reports/end/results.json'
65
START_FOLDER = 'start'
@@ -46,7 +45,7 @@ def get_accuracy_str(path):
4645
<h1>GrowLibm Report</h1>
4746
<p><a href="grow_platform.txt">Grow Platform</a></p>
4847
<p><a href="candidates.txt">Candidates</a></p>
49-
<p><a href="report_info.csv">More Info</a></p>
48+
<p><a href="report_info.txt">More Info</a></p>
5049
5150
<h2>Overall Summary</h2>
5251
<p><strong>Start:</strong> {start_accuracy_str} - <a href="{START_FOLDER}/">Folder</a></p>

infra/nightly.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export PATH="$PATH:$HOME/.cargo/bin/"
88

99
# Seed is fixed for the whole day; this way two branches run the same seed
1010
SEED=$(date "+%Y%j")
11-
BENCHDIR="bench/"
11+
BENCHDIR="bench/graphics/pbrt.fpcore"
1212
REPORTDIR="reports"
1313
NUMITERS=10
1414

@@ -21,11 +21,12 @@ racket -y "src/main.rkt" report \
2121
--dump-exprs \
2222
--platform "no-accelerators" \
2323
--disable "generate:evaluate" \
24-
"$BENCHDIR" "$REPORTDIR"/"start" > "$REPORTDIR/expr_dump.txt"
24+
"$BENCHDIR" \
25+
"$REPORTDIR/start" > "$REPORTDIR/expr_dump.txt"
2526

2627
# generate accelerator candidates
2728
racket -y growlibm/generate-candidates.rkt "$REPORTDIR"
28-
29+
2930
racket -y growlibm/to-json.rkt
3031
# extend platform loop
3132
for ((i = 0; i < $NUMITERS; i++)) do
@@ -35,9 +36,10 @@ for ((i = 0; i < $NUMITERS; i++)) do
3536
--threads 4 \
3637
--disable "generate:taylor" \
3738
--disable "generate:evaluate" \
38-
"$REPORTDIR/candidates.txt" "$REPORTDIR"/"iter$i"
39+
"$REPORTDIR/candidates.txt" \
40+
"$REPORTDIR/iter$i"
3941

40-
racket -y "growlibm/extend-platform.rkt" "$REPORTDIR"/"iter$i/results.json"
42+
racket -y "growlibm/extend-platform.rkt" "$REPORTDIR/iter$i/results.json"
4143
done
4244

4345
# run herbie again with expanded platform
@@ -46,10 +48,14 @@ racket -y "src/main.rkt" report \
4648
--platform "grow" \
4749
--threads 4 \
4850
--disable "generate:evaluate" \
49-
"$BENCHDIR" "$REPORTDIR"/"end"
51+
"$BENCHDIR" \
52+
"$REPORTDIR/end"
5053

5154
# print the new platform
5255
cat "src/platforms/grow.rkt" > "$REPORTDIR/grow_platform.txt"
5356

57+
chmod +x growlibm/count_accelerators.sh
58+
growlibm/count_accelerators.sh "$REPORTDIR/report_info.txt" "$REPORTDIR/end/results.json"
59+
5460
# generate the html report page
5561
python3 growlibm/generate-html.py

0 commit comments

Comments
 (0)