|
@@ -1,9 +1,12 @@
|
|
|
import tempfile
|
|
import tempfile
|
|
|
import time
|
|
import time
|
|
|
|
|
+import pickle
|
|
|
|
|
+import pandas as pd
|
|
|
|
|
|
|
|
from imc_utils.pps_e36311a import PPS_E36311A
|
|
from imc_utils.pps_e36311a import PPS_E36311A
|
|
|
from imc_utils.build_config.cortex_m33 import BuildConfigM33
|
|
from imc_utils.build_config.cortex_m33 import BuildConfigM33
|
|
|
from imc_utils.build_config.test_env import TestEnv
|
|
from imc_utils.build_config.test_env import TestEnv
|
|
|
|
|
+from imc_utils.serial_watch import SerialWatcher
|
|
|
import imc_utils.serial_device
|
|
import imc_utils.serial_device
|
|
|
|
|
|
|
|
# from ..common_configs import WORKSPACE_ROOT, NVM_RESET_BIN, OPENOCD_SCRIPT
|
|
# from ..common_configs import WORKSPACE_ROOT, NVM_RESET_BIN, OPENOCD_SCRIPT
|
|
@@ -16,63 +19,53 @@ def main():
|
|
|
pps = PPS_E36311A()
|
|
pps = PPS_E36311A()
|
|
|
config = get_default_build_config()
|
|
config = get_default_build_config()
|
|
|
|
|
|
|
|
- config.bench_name = "vBasicMath"
|
|
|
|
|
- config.insert_compiler_checkpoints = True
|
|
|
|
|
- config.use_checkpoint_voltage_check = False
|
|
|
|
|
-
|
|
|
|
|
- pps.set_voltage(3.3, 1)
|
|
|
|
|
- pps.set_current(0.1, 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=True)
|
|
|
|
|
-
|
|
|
|
|
- total_iterations = 5
|
|
|
|
|
- measured_times = measure_execution_time(total_iterations)
|
|
|
|
|
- print(measured_times)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-def measure_execution_time(total_iterations):
|
|
|
|
|
- ser = imc_utils.serial_device.get_serial()
|
|
|
|
|
-
|
|
|
|
|
- num_finished = 0
|
|
|
|
|
- start_detected = False
|
|
|
|
|
- time_takens = []
|
|
|
|
|
- time_total = 0
|
|
|
|
|
-
|
|
|
|
|
- ser.read_all()
|
|
|
|
|
-
|
|
|
|
|
- while num_finished < total_iterations:
|
|
|
|
|
- if ser.readable():
|
|
|
|
|
- res = ser.readline()
|
|
|
|
|
- try:
|
|
|
|
|
- line = res.decode()[: len(res) - 1]
|
|
|
|
|
- except:
|
|
|
|
|
- continue
|
|
|
|
|
-
|
|
|
|
|
- if line.startswith("hardfault"):
|
|
|
|
|
- print("\nHARD FAULT")
|
|
|
|
|
-
|
|
|
|
|
- if not start_detected:
|
|
|
|
|
- if line.startswith("Start benchmark"):
|
|
|
|
|
- print("\nbenchmark start detected")
|
|
|
|
|
- t_start = time.time()
|
|
|
|
|
- start_detected = True
|
|
|
|
|
- else:
|
|
|
|
|
- if line.startswith("End benchmark"):
|
|
|
|
|
- t_end = time.time()
|
|
|
|
|
- t_diff = t_end - t_start
|
|
|
|
|
- time_takens.append(t_diff)
|
|
|
|
|
- time_total += t_diff
|
|
|
|
|
- num_finished += 1
|
|
|
|
|
- print(
|
|
|
|
|
- f"\nbenchmark end detected, time: {t_diff:.2f} secs, finished: {num_finished}, average: {time_total/num_finished:.2f} secs"
|
|
|
|
|
- )
|
|
|
|
|
- start_detected = False
|
|
|
|
|
- # print(time_takens)
|
|
|
|
|
- return time_takens
|
|
|
|
|
|
|
+ benchmarks = [ "vBasicMath", "vCrc", "vFFT", "vSha", "vStringSearch", "vMatMul", "vConv2d", "vAes"]
|
|
|
|
|
+ benchmarks = ["vMatMul", "vStringSearch"]
|
|
|
|
|
+
|
|
|
|
|
+ # (insert_compiler_checkpoints, voltage_check, enable_pass_counter)
|
|
|
|
|
+ measure_configs = [
|
|
|
|
|
+ (False, False, False),
|
|
|
|
|
+ # (True, True, False),
|
|
|
|
|
+ (True, False, True)
|
|
|
|
|
+ ]
|
|
|
|
|
+
|
|
|
|
|
+ for benchmark in benchmarks:
|
|
|
|
|
+ all_records = []
|
|
|
|
|
+ for measure_config in measure_configs:
|
|
|
|
|
+ insert_compiler_checkpoints = measure_config[0]
|
|
|
|
|
+ use_checkpoint_voltage_check = measure_config[1]
|
|
|
|
|
+ use_checkpoint_pass_counter = measure_config[2]
|
|
|
|
|
+
|
|
|
|
|
+ config.bench_name = benchmark
|
|
|
|
|
+ config.insert_compiler_checkpoints = insert_compiler_checkpoints
|
|
|
|
|
+ config.use_checkpoint_voltage_check = use_checkpoint_voltage_check
|
|
|
|
|
+ config.use_checkpoint_pass_counter = use_checkpoint_pass_counter
|
|
|
|
|
+ config.checkpoint_pass_count = 1000000
|
|
|
|
|
+
|
|
|
|
|
+ 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=True)
|
|
|
|
|
+
|
|
|
|
|
+ total_iterations = 10
|
|
|
|
|
+ watcher = SerialWatcher(benchmark, total_iterations)
|
|
|
|
|
+ records = watcher.run()
|
|
|
|
|
+ for record in records:
|
|
|
|
|
+ record.update({
|
|
|
|
|
+ "checkpoint_enabled": insert_compiler_checkpoints,
|
|
|
|
|
+ "voltage_check_enabled": use_checkpoint_voltage_check,
|
|
|
|
|
+ "pass_counter_enabled": use_checkpoint_pass_counter
|
|
|
|
|
+ })
|
|
|
|
|
+ all_records.append(record)
|
|
|
|
|
+ df = pd.DataFrame(all_records)
|
|
|
|
|
+ print(df)
|
|
|
|
|
+ save_records(benchmark, df)
|
|
|
|
|
+ pps.output_off(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_default_build_config():
|
|
def get_default_build_config():
|
|
@@ -85,7 +78,10 @@ def get_default_build_config():
|
|
|
config.bench_infinite_loop = True
|
|
config.bench_infinite_loop = True
|
|
|
return config
|
|
return config
|
|
|
|
|
|
|
|
|
|
+def save_records(bench_name, df):
|
|
|
|
|
+ with open(f"output/{bench_name}.pickle", "wb") as f:
|
|
|
|
|
+ pickle.dump(df, f)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
|
main()
|
|
main()
|
|
|
-
|
|
|