stdlib: This commit added warning for exit default behavior
This commit imported the warn from m5.util library and added a function named "defaultBehaviorWarning" to the exit_event_generators.py file under src/python/gem5/simulator. This function takes two string variable and output a warning that contains a warning about the default behavior, the behavior type, and an detail explaination about it. Jira Issue: https://gem5.atlassian.net/browse/GEM5-1235 Change-Id: I54500425eaa1a556769aa1f8ea6b32852694c94d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/61189 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
@@ -27,17 +27,25 @@
|
||||
import m5.stats
|
||||
from ..components.processors.abstract_processor import AbstractProcessor
|
||||
from ..components.processors.switchable_processor import SwitchableProcessor
|
||||
from m5.util import warn
|
||||
|
||||
"""
|
||||
In this package we store generators for simulation exit events.
|
||||
"""
|
||||
|
||||
def defaultBehaviorWarning(type, effect):
|
||||
warn(
|
||||
"As no behavior was set by the user, default behavior is being carried"
|
||||
f" out.\n Type: {type} \n Detail: {effect} \n")
|
||||
|
||||
def default_exit_generator():
|
||||
"""
|
||||
A default generator for an exit event. It will return True, indicating that
|
||||
the Simulator run loop should exit.
|
||||
"""
|
||||
defaultBehaviorWarning(
|
||||
"default_exit_generator",
|
||||
"A default generator for an exit event. It will return True, "
|
||||
"indicating that the Simulator run loop should exit.")
|
||||
while True:
|
||||
yield True
|
||||
|
||||
@@ -48,6 +56,11 @@ def default_switch_generator(processor: AbstractProcessor):
|
||||
SwitchableProcessor, this generator will switch it. Otherwise nothing will
|
||||
happen.
|
||||
"""
|
||||
defaultBehaviorWarning(
|
||||
"default_switch_generator",
|
||||
"A default generator for a switch exit event.If the processor is a "
|
||||
"SwitchableProcessor, this generator will switch it. Otherwise nothing"
|
||||
" will happen.")
|
||||
is_switchable = isinstance(processor, SwitchableProcessor)
|
||||
while True:
|
||||
if is_switchable:
|
||||
@@ -61,6 +74,10 @@ def default_workbegin_generator():
|
||||
A default generator for a workbegin exit event. It will reset the
|
||||
simulation statistics.
|
||||
"""
|
||||
defaultBehaviorWarning(
|
||||
"default_workbegin_generator",
|
||||
"A default generator for a workbegin exit event. It will reset the "
|
||||
"simulation statistics.")
|
||||
while True:
|
||||
m5.stats.reset()
|
||||
yield False
|
||||
@@ -71,6 +88,10 @@ def default_workend_generator():
|
||||
A default generator for a workend exit event. It will dump the simulation
|
||||
statistics.
|
||||
"""
|
||||
defaultBehaviorWarning(
|
||||
"default_workend_generator",
|
||||
"A default generator for a workend exit event. It will dump the "
|
||||
"simulation statistics.")
|
||||
while True:
|
||||
m5.stats.dump()
|
||||
yield False
|
||||
|
||||
Reference in New Issue
Block a user