99InteractiveController builds on this for interactive stepping.
1010"""
1111
12+ import dataclasses
13+ import json
1214import pathlib
1315import sys
1416import time
@@ -242,13 +244,14 @@ def schedule_layer_start(self, next_layer):
242244 be .continue_aie ()
243245
244246 # Poll stamps until breakpoint is hit
245- max_attempts = 1200
246- while max_attempts > 0 :
247- if all (be .poll_core_status () for be in bes_to_poll ):
248- break
247+ timeout = 10
248+ start_time = time .time ()
249+ while time .time () - start_time < timeout :
249250 if self .args .backend == "test" :
250251 break
251- max_attempts -= 1
252+ time .sleep (0.1 )
253+ if all (be .poll_core_status () for be in bes_to_poll ):
254+ break
252255
253256 # When combo events are used, it takes a few cycles to
254257 # hit the breakpoint, so pc might have moved
@@ -298,6 +301,7 @@ def _process_err(self):
298301 self .status_handle .get (p + "/" + "aie_status_error.txt" )
299302 else :
300303 self .status_handle .get ("aie_status_error.txt" )
304+ self ._write_run_summary ("FAIL" )
301305 sys .exit (1 )
302306
303307 def _process_end_breakpoint (self , layer , it , sid ):
@@ -341,6 +345,7 @@ def _process_start_breakpoint(self, layer, it, sid=0):
341345
342346 if self .args .exit_at_layer and layer .layer_order >= self .args .exit_at_layer :
343347 LOGGER .log (f"[INFO] Exiting debugger at Layer: { layer .layer_order } " )
348+ self ._write_run_summary ("SUCCESS" )
344349 sys .exit (0 )
345350
346351 if self .args .run_flags .layer_status and first_it :
@@ -470,6 +475,7 @@ def execute_and_dump(self):
470475 self .impls [sid ].continue_aie ()
471476 LOGGER .log ("\n Finished Execution" )
472477 self ._handle_fsp ()
478+ self ._write_run_summary ("SUCCESS" )
473479
474480 def _handle_fsp (self ):
475481 """Handle end-of-run logic for VAIML Failsafe Partition mode."""
@@ -487,3 +493,17 @@ def _handle_fsp(self):
487493 "to load the next Failsafe Partition and wait for "
488494 "`waiting for user input`. Then press Enter here."
489495 )
496+
497+ def _write_run_summary (self , status ):
498+ """
499+ Record run state to run_summary.json
500+ """
501+ rsf = self .args .top_output_dir + "/run_summary.json"
502+ flags_dict = dataclasses .asdict (self .args .run_flags )
503+ summary = {"status" : status , "run_flags" : flags_dict }
504+
505+ try :
506+ with open (rsf , "w" , encoding = "utf-8" ) as fh :
507+ json .dump (summary , fh , indent = 2 , default = str )
508+ except (IOError , OSError ) as e :
509+ print (f"Unable to write run summary file. { e } " )
0 commit comments