def get_stats(self) -> Dict: """ Obtain the current simulation statistics as a Dictionary, conforming to a JSON-style schema. **Warning:** Will throw an Exception if called before `run()`. The board must be initialized before obtaining statistics """ if not self._instantiated: raise Exception( "Cannot obtain simulation statistics prior to inialization.") return get_simstat(self._root).to_json()
# We switch to timing cpu for detailed simulation. processor.switch() else: # `m5_exit instruction encountered` was never reached print("Unexpected termination of simulation before ROI was reached!") print("Exiting @ tick {} because {}.".format(m5.curTick(), exit_event.getCause())) exit(-1) # Simulate the ROI exit_event = m5.simulate() # Reached the end of ROI gem5stats = get_simstat(root) # We get the number of committed instructions from the timing # cores. We then sum and print them at the end. roi_insts = float(\ json.loads(gem5stats.dumps())\ ["system"]["processor"]["cores2"]["core"]["exec_context.thread_0"]\ ["numInsts"]["value"]) + float(\ json.loads(gem5stats.dumps())\ ["system"]["processor"]["cores3"]["core"]["exec_context.thread_0"]\ ["numInsts"]["value"]\ ) if exit_event.getCause() == "m5_exit instruction encountered": print("Dump stats at the end of the ROI!")