[gem5-dev] [L] Change in gem5/gem5[release-staging-v22-1]: stdlib, configs: Updating configs/example/gem5_library
Bobby Bruce has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/66332?usp=email ) Change subject: stdlib, configs: Updating configs/example/gem5_library .. stdlib, configs: Updating configs/example/gem5_library This commit updates all of the older tests in this directory to use the Simulator to run instead of m5.simulate() Change-Id: I2a81d5c2f27c89e8c03abb0203ca3e58a6688672 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64791 Reviewed-by: Bobby Bruce Tested-by: kokoro Maintainer: Bobby Bruce Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/66332 --- M configs/example/gem5_library/x86-gapbs-benchmarks.py M configs/example/gem5_library/x86-npb-benchmarks.py M configs/example/gem5_library/x86-parsec-benchmarks.py M configs/example/gem5_library/x86-spec-cpu2006-benchmarks.py M configs/example/gem5_library/x86-spec-cpu2017-benchmarks.py 5 files changed, 161 insertions(+), 438 deletions(-) Approvals: Bobby Bruce: Looks good to me, approved; Looks good to me, approved kokoro: Regressions pass diff --git a/configs/example/gem5_library/x86-gapbs-benchmarks.py b/configs/example/gem5_library/x86-gapbs-benchmarks.py index bdc0d94..638d34b 100644 --- a/configs/example/gem5_library/x86-gapbs-benchmarks.py +++ b/configs/example/gem5_library/x86-gapbs-benchmarks.py @@ -64,8 +64,8 @@ from gem5.isas import ISA from gem5.coherence_protocol import CoherenceProtocol from gem5.resources.resource import Resource - -from m5.stats.gem5stats import get_simstat +from gem5.simulate.simulator import Simulator +from gem5.simulate.exit_event import ExitEvent requires( isa_required=ISA.X86, @@ -210,14 +210,26 @@ readfile_contents=command, ) -root = Root(full_system=True, system=board) -# sim_quantum must be set when KVM cores are used. +def handle_exit(): +print("Done booting Linux") +print("Resetting stats at the start of ROI!") +m5.stats.reset() +global start_tick +start_tick = m5.curTick() +processor.switch() +yield False # E.g., continue the simulation. +print("Dump stats at the end of the ROI!") +m5.stats.dump() +yield True # Stop the simulation. We're done. -root.sim_quantum = int(1e9) -board._pre_instantiate() -m5.instantiate() +simulator = Simulator( +board=board, +on_exit_event={ +ExitEvent.EXIT: handle_exit(), +}, +) # We maintain the wall clock time. @@ -232,74 +244,8 @@ # the first ROI annotation in details. The X86Board currently does not support # `work items started count reached`. -exit_event = m5.simulate() - -# The first exit_event ends with a `workbegin` cause. This means that the -# system started successfully and the execution on the program started. The -# ROI begin is encountered. - -if exit_event.getCause() == "workbegin": - -print("Done booting Linux") -print("Resetting stats at the start of ROI!") - -m5.stats.reset() -start_tick = m5.curTick() - -# We have completed up to this step using KVM cpu. Now we switch to timing -# cpu for detailed simulation. - -processor.switch() -else: -print("Unexpected termination of simulation before ROI was reached!") -print( -"Exiting @ tick {} because {}.".format( -m5.curTick(), exit_event.getCause() -) -) -exit(-1) - -# The next exit_event is to simulate the ROI. It should be exited with a cause -# marked by `workend`. This implies that the first annotation is successfully -# completed. - -exit_event = m5.simulate() - -# Reached the end of first ROI. -# We dump the stats here. - -# We exepect that ROI ends with `workend`. Otherwise the simulation ended -# unexpectedly. -if exit_event.getCause() == "workend": -print("Dump stats at the end of the ROI!") - -m5.stats.dump() -end_tick = m5.curTick() -else: -print("Unexpected termination of simulation while ROI was being executed!") -print( -"Exiting @ tick {} because {}.".format( -m5.curTick(), exit_event.getCause() -) -) -exit(-1) - -# We get simInsts using get_simstat and output it in the final print statement. - -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( -gem5stats.to_json()["system"]["processor"]["switch0"]["core"][ -"exec_context.thread_0" -]["numInsts"]["value"] -) + float( -gem5stats.to_json()["system"]["processor"]["switch1"]["core"][ -"exec_context.thread_0" -]["numInsts"]["value"] -) +simulator.run() +end_tick = m5.curTick() # Since we simulated the ROI in details, therefore, simulation is over at this # point. @@ -313,8 +259,9 @@ print("Performance statistics:") print("Simulated time in ROI: %.2fs" % ((end_tick - start_tick) / 1e12)) -print("Instructions executed in ROI:
[gem5-dev] [L] Change in gem5/gem5[release-staging-v22-1]: stdlib, configs: Updating configs/example/gem5_library
Hello kokoro, I'd like you to do a code review. Please visit https://gem5-review.googlesource.com/c/public/gem5/+/66332?usp=email to review the following change. Change subject: stdlib, configs: Updating configs/example/gem5_library .. stdlib, configs: Updating configs/example/gem5_library This commit updates all of the older tests in this directory to use the Simulator to run instead of m5.simulate() Change-Id: I2a81d5c2f27c89e8c03abb0203ca3e58a6688672 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64791 Reviewed-by: Bobby Bruce Tested-by: kokoro Maintainer: Bobby Bruce --- M configs/example/gem5_library/x86-gapbs-benchmarks.py M configs/example/gem5_library/x86-npb-benchmarks.py M configs/example/gem5_library/x86-parsec-benchmarks.py M configs/example/gem5_library/x86-spec-cpu2006-benchmarks.py M configs/example/gem5_library/x86-spec-cpu2017-benchmarks.py 5 files changed, 160 insertions(+), 438 deletions(-) diff --git a/configs/example/gem5_library/x86-gapbs-benchmarks.py b/configs/example/gem5_library/x86-gapbs-benchmarks.py index bdc0d94..638d34b 100644 --- a/configs/example/gem5_library/x86-gapbs-benchmarks.py +++ b/configs/example/gem5_library/x86-gapbs-benchmarks.py @@ -64,8 +64,8 @@ from gem5.isas import ISA from gem5.coherence_protocol import CoherenceProtocol from gem5.resources.resource import Resource - -from m5.stats.gem5stats import get_simstat +from gem5.simulate.simulator import Simulator +from gem5.simulate.exit_event import ExitEvent requires( isa_required=ISA.X86, @@ -210,14 +210,26 @@ readfile_contents=command, ) -root = Root(full_system=True, system=board) -# sim_quantum must be set when KVM cores are used. +def handle_exit(): +print("Done booting Linux") +print("Resetting stats at the start of ROI!") +m5.stats.reset() +global start_tick +start_tick = m5.curTick() +processor.switch() +yield False # E.g., continue the simulation. +print("Dump stats at the end of the ROI!") +m5.stats.dump() +yield True # Stop the simulation. We're done. -root.sim_quantum = int(1e9) -board._pre_instantiate() -m5.instantiate() +simulator = Simulator( +board=board, +on_exit_event={ +ExitEvent.EXIT: handle_exit(), +}, +) # We maintain the wall clock time. @@ -232,74 +244,8 @@ # the first ROI annotation in details. The X86Board currently does not support # `work items started count reached`. -exit_event = m5.simulate() - -# The first exit_event ends with a `workbegin` cause. This means that the -# system started successfully and the execution on the program started. The -# ROI begin is encountered. - -if exit_event.getCause() == "workbegin": - -print("Done booting Linux") -print("Resetting stats at the start of ROI!") - -m5.stats.reset() -start_tick = m5.curTick() - -# We have completed up to this step using KVM cpu. Now we switch to timing -# cpu for detailed simulation. - -processor.switch() -else: -print("Unexpected termination of simulation before ROI was reached!") -print( -"Exiting @ tick {} because {}.".format( -m5.curTick(), exit_event.getCause() -) -) -exit(-1) - -# The next exit_event is to simulate the ROI. It should be exited with a cause -# marked by `workend`. This implies that the first annotation is successfully -# completed. - -exit_event = m5.simulate() - -# Reached the end of first ROI. -# We dump the stats here. - -# We exepect that ROI ends with `workend`. Otherwise the simulation ended -# unexpectedly. -if exit_event.getCause() == "workend": -print("Dump stats at the end of the ROI!") - -m5.stats.dump() -end_tick = m5.curTick() -else: -print("Unexpected termination of simulation while ROI was being executed!") -print( -"Exiting @ tick {} because {}.".format( -m5.curTick(), exit_event.getCause() -) -) -exit(-1) - -# We get simInsts using get_simstat and output it in the final print statement. - -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( -gem5stats.to_json()["system"]["processor"]["switch0"]["core"][ -"exec_context.thread_0" -]["numInsts"]["value"] -) + float( -gem5stats.to_json()["system"]["processor"]["switch1"]["core"][ -"exec_context.thread_0" -]["numInsts"]["value"] -) +simulator.run() +end_tick = m5.curTick() # Since we simulated the ROI in details, therefore, simulation is over at this # point. @@ -313,8 +259,9 @@ print("Performance statistics:") print("Simulated time in ROI: %.2fs" % ((end_tick - start_tick) / 1e12)) -print("Instructions executed in ROI: %d" % ((roi_insts))) -print("Ran a total of", m5.curTick() / 1e12, "simulated seconds") +print( +"Ran a total of",