stdlib: Update AbstractCore's 'set_inst_stop_any_thread'

This patch:
- Makes this function private.
- Updates the function's documentation.
- Changes the 'init' parameter to 'board_initialized'.

It doesn't make much sense for this function to be exposed directly to
the user as it requires knowing whether the board is initialized or not.

In addition to this I believe it makes more sense for the 'init' logic
to be flipped and renamed "board_initialized' so that this value is True
if the board has been initialized.

The documentation for this function has been updated.

Change-Id: I016c65bde88357111d3e648d7aa99aeb6e31f410
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64833
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Bobby R. Bruce
2022-10-19 14:12:44 -07:00
committed by Bobby Bruce
parent 12d8d5ca26
commit c88b528738
4 changed files with 21 additions and 21 deletions

View File

@@ -132,5 +132,5 @@ simulator = Simulator(
# is greater than 0.
# In here, it schedules an exit event for the first SimPoint's warmup
# instructions
simulator.schedule_max_insts(board.get_simpoint().get_warmup_list()[0], True)
simulator.schedule_max_insts(board.get_simpoint().get_warmup_list()[0])
simulator.run()

View File

@@ -140,15 +140,18 @@ class AbstractCore(SubSystem):
raise NotImplementedError("This core type does not support simpoints")
@abstractmethod
def set_inst_stop_any_thread(self, inst: int, init: bool) -> None:
def _set_inst_stop_any_thread(
self, inst: int, board_initialized: bool
) -> None:
"""Schedule an exit event when any thread in this core reaches the
given number of instructions.
given number of instructions. This is called through the simulator
module and should not be called directly.
This is used to raise MAX_INSTS exit event in the gem5 standard library
:param inst: a number of instructions
:param init: if it is True, the exit event will be scheduled at the
init stage of the core, else, it will be scheduled during the
simulation
:param board_initialized: True if the board has already been
initialized, otherwise False. This parameter is necessary as the
instruction stop is setup differently dependent on this.
"""
raise NotImplementedError("This core type does not support MAX_INSTS")

View File

@@ -162,8 +162,10 @@ class BaseCPUCore(AbstractCore):
self.core.simpoint_start_insts = sorted(set(inst_starts))
@overrides(AbstractCore)
def set_inst_stop_any_thread(self, inst: int, init: bool) -> None:
if init:
self.core.max_insts_any_thread = inst
else:
def _set_inst_stop_any_thread(
self, inst: int, board_initialized: bool
) -> None:
if board_initialized:
self.core.scheduleInstStopAnyThread(inst)
else:
self.core.max_insts_any_thread = inst

View File

@@ -251,20 +251,15 @@ class Simulator:
simpoint_start_insts, self._instantiated
)
def schedule_max_insts(
self, inst: int, schedule_at_init: bool = False
) -> None:
def schedule_max_insts(self, inst: int) -> None:
"""
Schedule a MAX_INSTS exit event when any thread in the current core
reaches the given number of instructions
Schedule a MAX_INSTS exit event when any thread in any core reaches the
given number of instructions.
:param insts: a number of instructions
:param schedule_at_init: if it is True, schedule the event in the init
stage of the core, else, schedule the event during the simulation
:param insts: a number of instructions to run to.
"""
self._board.get_processor().get_cores()[0].set_inst_stop_any_thread(
inst, schedule_at_init
)
for core in self._board.get_processor().get_cores():
core._set_inst_stop_any_thread(inst, self._instantiated)
def get_stats(self) -> Dict:
"""