Skip to content

Commit aca66bf

Browse files
Archith IyerArchith Iyer
authored andcommitted
fix Benchmarking Speedup CI
1 parent 9124adc commit aca66bf

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

.github/workflows/bench.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,7 @@ jobs:
5252
(cd pr && bash .github/workflows/phoenix/submit.sh .github/workflows/phoenix/bench.sh ${{ matrix.device }} --single) &
5353
(cd master && bash .github/workflows/phoenix/submit.sh .github/workflows/phoenix/bench.sh ${{ matrix.device }} --single) &
5454
wait
55-
56-
- name: Check Speedup
57-
run: |
58-
cd pr
59-
. ./mfc.sh load -c p -m ${{ matrix.device }}
60-
61-
single_time=$(grep "Runtime:" bench-${{ matrix.device }}-single.yaml | awk '{print $2}')
62-
double_time=$(grep "Runtime:" bench-${{ matrix.device }}.yaml | awk '{print $2}')
63-
speedup=$(echo "$double_time / $single_time" | bc -l)
64-
65-
echo "Single precision time: $single_time"
66-
echo "Double precision time: $double_time"
67-
echo "Speedup: $speedup"
68-
69-
if (( $(echo "$speedup < 1.5" | bc -l) )); then
70-
echo "Error: Speedup is less than 1.5x in single precision"
71-
exit 1
72-
fi
73-
55+
7456
- name: Generate & Post Comment
7557
run: |
7658
cd pr

toolchain/mfc/bench.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BenchCase:
1717
args: typing.List[str]
1818

1919

20-
def bench(targets = None):
20+
def bench(targets=None):
2121
if targets is None:
2222
targets = ARG("targets")
2323

@@ -31,7 +31,7 @@ def bench(targets = None):
3131
cons.indent()
3232
cons.print()
3333

34-
CASES = [ BenchCase(**case) for case in file_load_yaml(MFC_BENCH_FILEPATH) ]
34+
CASES = [BenchCase(**case) for case in file_load_yaml(MFC_BENCH_FILEPATH)]
3535

3636
for case in CASES:
3737
case.args = case.args + ARG("--")
@@ -40,14 +40,17 @@ def bench(targets = None):
4040
results = {
4141
"metadata": {
4242
"invocation": sys.argv[1:],
43-
"lock": dataclasses.asdict(CFG())
43+
"lock": dataclasses.asdict(CFG())
4444
},
4545
"cases": {},
4646
}
4747

48+
single_precision_runtime = None
49+
double_precision_runtime = None
50+
4851
for i, case in enumerate(CASES):
4952
summary_filepath = os.path.join(bench_dirpath, f"{case.slug}.yaml")
50-
log_filepath = os.path.join(bench_dirpath, f"{case.slug}.out")
53+
log_filepath = os.path.join(bench_dirpath, f"{case.slug}.out")
5154

5255
cons.print(f"{str(i+1).zfill(len(CASES) // 10 + 1)}/{len(CASES)}: {case.slug} @ [bold]{os.path.relpath(case.path)}[/bold]")
5356
cons.indent()
@@ -65,13 +68,28 @@ def bench(targets = None):
6568
stdout=log_file,
6669
stderr=subprocess.STDOUT)
6770

71+
output_summary = file_load_yaml(summary_filepath)
6872
results["cases"][case.slug] = {
69-
"description": dataclasses.asdict(case),
70-
"output_summary": file_load_yaml(summary_filepath),
73+
"description": dataclasses.asdict(case),
74+
"output_summary": output_summary,
7175
}
7276

73-
file_dump_yaml(ARG("output"), results)
77+
if "single" in case.slug:
78+
single_precision_runtime = output_summary.get("exec")
79+
elif "double" in case.slug:
80+
double_precision_runtime = output_summary.get("exec")
81+
82+
# Check for speedup requirement
83+
if single_precision_runtime and double_precision_runtime:
84+
speedup = double_precision_runtime / single_precision_runtime
85+
cons.print(f"Single precision runtime: {single_precision_runtime}")
86+
cons.print(f"Double precision runtime: {double_precision_runtime}")
87+
cons.print(f"Speedup: {speedup:.2f}")
7488

89+
if speedup < 1.2:
90+
raise MFCException("Error: Single precision runtime is not at least 1.2 times faster than double precision.")
91+
92+
file_dump_yaml(ARG("output"), results)
7593
cons.print(f"Wrote results to [bold magenta]{os.path.relpath(ARG('output'))}[/bold magenta].")
7694

7795
cons.unindent()

0 commit comments

Comments
 (0)