run_expr_3.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import tempfile
  2. import time
  3. import pickle
  4. import pandas as pd
  5. from imc_utils.pps_e36311a import PPS_E36311A
  6. from imc_utils.build_config.cortex_m33 import BuildConfigM33
  7. from imc_utils.build_config.test_env import TestEnv
  8. from imc_utils.serial_watch import SerialWatcher
  9. WORKSPACE_ROOT = "/home/ybkim/workspace/imc/imc_freertos_app_m33"
  10. NVM_RESET_BIN = f"{WORKSPACE_ROOT}/imc/utils/nvm_reset.elf"
  11. OPENOCD_SCRIPT = f"{WORKSPACE_ROOT}/imc_freertos_app_m33.cfg"
  12. def main():
  13. pps = PPS_E36311A()
  14. config = get_default_build_config()
  15. benchmarks = [
  16. "vBasicMath",
  17. "vCrc",
  18. "vFFT",
  19. "vSha",
  20. "vStringSearch",
  21. "vMatMul",
  22. "vConv2d",
  23. "vAes",
  24. ]
  25. benchmarks = ["vSha"]
  26. for benchmark in benchmarks:
  27. all_records = []
  28. bench_repeat_count = config.bench_repeat_count_small[benchmark]
  29. config.bench_name = benchmark
  30. config.bench_repeat_count = bench_repeat_count
  31. pps.set_voltage(3.3, 1)
  32. pps.set_current(0.1, 1)
  33. pps.output_on(1)
  34. env = TestEnv(WORKSPACE_ROOT, NVM_RESET_BIN, OPENOCD_SCRIPT)
  35. with tempfile.TemporaryDirectory() as build_dir:
  36. binary = env.build_binary(config, build_dir)
  37. env.clear_nvm_and_load_binary(binary, resume=False)
  38. pps.set_current(0.015, 1)
  39. time.sleep(1)
  40. env.resume_board(terminate=True)
  41. total_iterations = 10
  42. watcher = SerialWatcher(benchmark, total_iterations)
  43. records = watcher.run()
  44. for record in records:
  45. record.update(
  46. {
  47. # "loop_pass_count": loop_pass_count,
  48. }
  49. )
  50. all_records.append(record)
  51. df = pd.DataFrame(all_records)
  52. print(df)
  53. save_records(benchmark, df)
  54. pps.output_off(1)
  55. def get_default_build_config():
  56. config = BuildConfigM33()
  57. config.bench_name = "vBasicMath"
  58. config.insert_compiler_checkpoints = True
  59. config.enable_extension = True
  60. config.use_checkpoint_pass_counter = False
  61. config.checkpoint_pass_count = 100
  62. config.use_checkpoint_voltage_check = True
  63. config.bench_infinite_loop = True
  64. config.split_loop = False
  65. config.enable_static_loop_pass_count = False
  66. config.loop_pass_count = 0
  67. config.enable_adaptive_loop_pass_count = False
  68. config.max_loop_ids = 30
  69. config.print_recovery_message = True
  70. return config
  71. def save_records(bench_name, df):
  72. with open(f"output/{bench_name}.pickle", "wb") as f:
  73. pickle.dump(df, f)
  74. if __name__ == "__main__":
  75. main()