Melissa Jost has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/64791?usp=email )

Change subject: stdlib, configs: Updating configs/example/gem5_library
......................................................................

stdlib, configs: Updating configs/example/gem5_library

This is a WIP commit with just one of the out-of-date files, but
now uses the Simulator.  I have some extra comments in the code
to clarify the organization of things, and once that's clear I'll
add the remaining files to this commit.

Change-Id: I2a81d5c2f27c89e8c03abb0203ca3e58a6688672
---
M configs/example/gem5_library/x86-parsec-benchmarks.py
1 file changed, 41 insertions(+), 85 deletions(-)



diff --git a/configs/example/gem5_library/x86-parsec-benchmarks.py b/configs/example/gem5_library/x86-parsec-benchmarks.py
index 08fa636..17ddc288 100644
--- a/configs/example/gem5_library/x86-parsec-benchmarks.py
+++ b/configs/example/gem5_library/x86-parsec-benchmarks.py
@@ -60,6 +60,8 @@
 from gem5.isas import ISA
 from gem5.coherence_protocol import CoherenceProtocol
 from gem5.resources.resource import Resource
+from gem5.simulate.simulator import Simulator
+from gem5.simulate.exit_event import ExitEvent

 from m5.stats.gem5stats import get_simstat

@@ -195,16 +197,18 @@
     readfile_contents=command,
 )

-# We need this for long running processes.
-m5.disableAllListeners()
-
-root = Root(full_system=True, system=board)
-
-# sim_quantum must be set if KVM cores are used.
-
-root.sim_quantum = int(1e9)
-
-m5.instantiate()
+# on_exit_event taken from x86-ubuntu-run-with-kvm.py
+# unsure if the functionality here is correct
+simulator = Simulator(
+    board=board,
+    on_exit_event={
+        # Here we want override the default behavior for the first m5 exit
+        # exit event. Instead of exiting the simulator, we just want to
+        # switch the processor. The 2nd m5 exit after will revert to using
+        # default behavior where the simulator run will exit.
+        ExitEvent.EXIT: (func() for func in [processor.switch])
+    },
+)

 # We maintain the wall clock time.

@@ -213,83 +217,14 @@
 print("Running the simulation")
 print("Using KVM cpu")

-start_tick = m5.curTick()
-end_tick = m5.curTick()
+start_tick = simulator.get_current_tick()
+end_tick = simulator.get_current_tick()
 m5.stats.reset()

 # We start the simulation
+# Should perform switches on its own (???)
+simulator.run()

-exit_event = m5.simulate()
-
-# The first exit_event ends with a `workbegin` cause. This means that the
-# system booted successfully and the execution on the program started.
-
-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:
-    # `workbegin` call was never encountered.
-
-    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`.
-
-exit_event = m5.simulate()
-
-# Reached the end of 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)
-
-# ROI has ended here, and we get `simInsts` using get_simstat and print 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"]
-)
-
-# Simulation is over at this point. We acknowledge that all the simulation
-# events were successful.
 print("All simulation events were successful.")

 # We print the final simulation statistics.
@@ -298,9 +233,16 @@
 print()
 print("Performance statistics:")

+# question: do we neeed to replace these ticks with info from
+# simulator.get_tick_stopwatch()?
+
+# also note: during runtime, we get a lot of unimplemented or skipped things,
+# is this a concern? it still runs to completion
 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("Instructions executed in ROI: " + ((str(simulator.get_roi_ticks()[0]))))
+print(
+ "Ran a total of", simulator.get_current_tick() / 1e12, "simulated seconds"
+)
 print(
     "Total wallclock time: %.2fs, %.2f min"
     % (time.time() - globalStart, (time.time() - globalStart) / 60)

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/64791?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I2a81d5c2f27c89e8c03abb0203ca3e58a6688672
Gerrit-Change-Number: 64791
Gerrit-PatchSet: 1
Gerrit-Owner: Melissa Jost <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to