Skip to content

Commit

Permalink
Profiles for benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Mar 4, 2024
1 parent f102ca3 commit e007bd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/run_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument("-l", "--list", action="store_true", help="List all benchmarks")
parser.add_argument("-t", "--trace", action="store_true", help="Dump waveforms")
parser.add_argument("-p", "--profile", action="store_true", help="Write execution profiles")
parser.add_argument("-v", "--verbose", action="store_true", help="Verbose output")
parser.add_argument("-b", "--backend", default="cocotb", choices=["cocotb", "pysim"], help="Simulation backend")
parser.add_argument(
Expand Down Expand Up @@ -171,6 +172,9 @@ def main():
print(f"Could not find benchmark '{args.benchmark_name}'")
sys.exit(1)

if args.profile:
os.environ["__TRANSACTRON_PROFILE"] = "1"

success = run_benchmarks(benchmarks, args.backend, args.trace, args.verbose)
if not success:
print("Benchmark execution failed")
Expand Down
5 changes: 5 additions & 0 deletions test/regression/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
test_dir = Path(__file__).parent.parent
embench_dir = test_dir.joinpath("external/embench/build/src")
results_dir = test_dir.joinpath("regression/benchmark_results")
profile_dir = test_dir.joinpath("__profiles__")


@dataclass_json
Expand Down Expand Up @@ -77,6 +78,10 @@ async def run_benchmark(sim_backend: SimulationBackend, benchmark_name: str):

result = await sim_backend.run(mem_model, timeout_cycles=2000000)

if result.profile is not None:
os.makedirs(profile_dir, exist_ok=True)
result.profile.encode(f"{profile_dir}/benchmark.{benchmark_name}.json")

if not result.success:
raise RuntimeError("Simulation timed out")

Expand Down

0 comments on commit e007bd8

Please sign in to comment.