-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#0: Switch to google benchmark for pgm dispatch tests
- Loading branch information
Showing
7 changed files
with
2,494 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
tests/tt_metal/tt_metal/perf_microbenchmark/dispatch/compare_pgm_dispatch_perf_ci.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/python3 | ||
|
||
import json | ||
import os | ||
import sys | ||
|
||
os.chdir(os.getenv("TT_METAL_HOME")) | ||
golden = json.load(open("tests/tt_metal/tt_metal/perf_microbenchmark/dispatch/pgm_dispatch_golden.json", "r")) | ||
|
||
THRESHOLD=4 | ||
result = os.system("build/test/tt_metal/perf_microbenchmark/dispatch/test_pgm_dispatch --benchmark_out_format=json --benchmark_out=bench.json") | ||
if result != 0: | ||
print(f"Test failed with error code {result}") | ||
sys.exit(result) | ||
|
||
result = json.load(open("bench.json", "r")) | ||
|
||
golden_benchmarks = {} | ||
for benchmark in golden["benchmarks"]: | ||
golden_benchmarks[benchmark["name"]] = benchmark | ||
|
||
result_benchmarks = {} | ||
for benchmark in result["benchmarks"]: | ||
result_benchmarks[benchmark["name"]] = benchmark | ||
|
||
exit_code = 0 | ||
|
||
for name, benchmark in golden_benchmarks.items(): | ||
if name not in result_benchmarks: | ||
print(f"Golden enchmark {name} missing from results") | ||
exit_code = 1 | ||
continue | ||
result = result_benchmarks[benchmark["name"]] | ||
|
||
if "error_occurred" in benchmark: | ||
if "error_occurred" not in result: | ||
print(f"Error in {name} was fixed in result. Consider adjusting baselines.") | ||
continue | ||
|
||
if "error_occurred" in result: | ||
if "error_occurred" not in benchmark: | ||
print(f"Benchmark {name} gave error {result['error_message']}") | ||
exit_code = 1 | ||
continue | ||
|
||
golden_time = benchmark["IterationTime"] | ||
result_time = result["IterationTime"] | ||
if result_time / golden_time > (1 + THRESHOLD / 100): | ||
print(f"Test {name} expected value {golden_time} but got {result_time}") | ||
exit_code = 1 | ||
if golden_time / result_time > (1 + THRESHOLD / 100): | ||
print(f"Test {name} got value {result_time} but expected {golden_time}. Consider adjusting baselines") | ||
|
||
for name in result_benchmarks: | ||
if name not in golden_benchmarks: | ||
print(f"Result benchmark {name} missing from goldens") | ||
exit_code = 1 | ||
|
||
if exit_code == 0: | ||
print("Test successful") | ||
sys.exit(exit_code) |
Oops, something went wrong.