validation.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import tempfile
  2. import time
  3. import pandas as pd
  4. import pickle
  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. import imc_utils.serial_device
  9. from imc_utils.serial_watch import SerialWatcher
  10. WORKSPACE_ROOT = "/home/ybkim/workspace/imc/imc_freertos_app_m33"
  11. NVM_RESET_BIN = f"{WORKSPACE_ROOT}/imc/utils/nvm_reset.elf"
  12. OPENOCD_SCRIPT = f"{WORKSPACE_ROOT}/imc_freertos_app_m33.cfg"
  13. def main():
  14. pps = PPS_E36311A()
  15. config = get_default_build_config()
  16. benchmarks = [
  17. "vBasicMath", "vCrc", "vFFT", "vSha", "vStringSearch", "vMatMul", "vConv2d", "vAes"
  18. ]
  19. for benchmark in benchmarks:
  20. config.bench_name = benchmark
  21. config.insert_compiler_checkpoints = False
  22. config.use_checkpoint_pass_counter = False
  23. config.use_checkpoint_voltage_check = False
  24. config.checkpoint_pass_count = 1000
  25. config.bench_infinite_loop = True
  26. config.split_loop = True
  27. pps.set_voltage(3.3, 1)
  28. pps.set_current(0.1, 1)
  29. pps.output_on(1)
  30. env = TestEnv(WORKSPACE_ROOT, NVM_RESET_BIN, OPENOCD_SCRIPT)
  31. with tempfile.TemporaryDirectory() as build_dir:
  32. binary = env.build_binary(config, build_dir)
  33. env.clear_nvm_and_load_binary(binary, resume=False)
  34. # pps.set_current(0.015, 1)
  35. # time.sleep(1)
  36. env.resume_board(terminate=True)
  37. total_iterations = 2
  38. records = SerialWatcher(benchmark, total_iterations).run()
  39. # records = measure_execution_time(benchmark, total_iterations)
  40. df = pd.DataFrame(records)
  41. save_records(benchmark, df)
  42. print(df)
  43. def get_default_build_config():
  44. config = BuildConfigM33()
  45. config.bench_name = "vBasicMath"
  46. config.insert_compiler_checkpoints = True
  47. config.enable_extension = True
  48. config.use_checkpoint_pass_counter = False
  49. config.use_checkpoint_voltage_check = True
  50. config.bench_infinite_loop = True
  51. config.checkpoint_pass_count = 100
  52. config.print_recovery_message = True
  53. return config
  54. def save_records(bench_name, df):
  55. with open(f"output/{bench_name}.pickle", "wb") as f:
  56. pickle.dump(df, f)
  57. if __name__ == "__main__":
  58. main()