| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- import tempfile
- import time
- import pickle
- import pandas as pd
- from imc_utils.pps_e36311a import PPS_E36311A
- from imc_utils.build_config.cortex_m33 import BuildConfigM33
- from imc_utils.build_config.test_env import TestEnv
- from imc_utils.serial_watch import SerialWatcher
- WORKSPACE_ROOT = "/home/ybkim/workspace/imc/imc_freertos_app_m33"
- NVM_RESET_BIN = f"{WORKSPACE_ROOT}/imc/utils/nvm_reset.elf"
- OPENOCD_SCRIPT = f"{WORKSPACE_ROOT}/imc_freertos_app_m33.cfg"
- def get_build_config(benchmark, config_name):
- config = get_default_build_config()
- config.bench_name = benchmark
- bench_repeat_count = config.bench_repeat_count_small[benchmark]
- config.bench_repeat_count = bench_repeat_count
- if config_name == "pass_count":
- config.use_checkpoint_pass_counter = True
- config.checkpoint_pass_count = config.pass_count_10ms[benchmark]
-
- if config_name == "adaptive":
- config.use_checkpoint_voltage_check = True
- config.split_loop = True
- config.enable_adaptive_loop_pass_count = True
- # config.enable_static_loop_pass_count = True
- # config.loop_pass_count = 50
- config.max_loop_ids = 30
- return config
- def main():
- pps = PPS_E36311A()
- config = get_default_build_config()
- benchmarks = [
- "vBasicMath",
- "vCrc",
- "vFFT",
- "vSha",
- "vStringSearch",
- "vMatMul",
- "vConv2d",
- "vAes",
- ]
- # benchmarks = [
- # "vBasicMath"
- # ]
- configs = ["pass_count", "adaptive"]
- # configs = ["adaptive"]
- total_iterations = 20
- for benchmark in benchmarks:
- for config_name in configs:
- all_records = []
- config = get_build_config(benchmark, config_name)
- pps.set_voltage(3.3, 1)
- pps.set_current(0.1, 1)
- pps.output_on(1)
- env = TestEnv(WORKSPACE_ROOT, NVM_RESET_BIN, OPENOCD_SCRIPT)
- with tempfile.TemporaryDirectory() as build_dir:
- binary = env.build_binary(config, build_dir)
- env.clear_nvm_and_load_binary(binary, resume=False)
- pps.set_current(0.015, 1)
- time.sleep(1)
- env.resume_board(terminate=True)
- watcher = SerialWatcher(benchmark, total_iterations)
- records = watcher.run()
- for record in records:
- record.update(
- {
- # "loop_pass_count": loop_pass_count,
- }
- )
- all_records.append(record)
- df = pd.DataFrame(all_records)
- columns = ["bench_name", "time_taken", "recovery", "stats", "is_correct"]
- print(df[columns])
- save_records(benchmark, config_name, df)
- pps.output_off(1)
- def get_default_build_config():
- config = BuildConfigM33()
- config.insert_compiler_checkpoints = True
- config.enable_extension = True
- config.use_checkpoint_pass_counter = False
- config.use_checkpoint_voltage_check = False
- config.bench_infinite_loop = True
- config.print_recovery_message = True
- config.split_loop = False
- config.enable_static_loop_pass_count = False
- config.enable_adaptive_loop_pass_count = False
- config.print_stats = True
- return config
- def save_records(bench_name, config_name, df):
- with open(f"output/{config_name}/{bench_name}.pickle", "wb") as f:
- pickle.dump(df, f)
- if __name__ == "__main__":
- main()
|