diff --git a/configs/example/gem5_library/checkpoints/simpoints-se-restore.py b/configs/example/gem5_library/checkpoints/simpoints-se-restore.py index b529672981..f8f48d0ec1 100644 --- a/configs/example/gem5_library/checkpoints/simpoints-se-restore.py +++ b/configs/example/gem5_library/checkpoints/simpoints-se-restore.py @@ -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() diff --git a/src/python/gem5/components/processors/abstract_core.py b/src/python/gem5/components/processors/abstract_core.py index ea2875eabf..58296bca3b 100644 --- a/src/python/gem5/components/processors/abstract_core.py +++ b/src/python/gem5/components/processors/abstract_core.py @@ -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") diff --git a/src/python/gem5/components/processors/base_cpu_core.py b/src/python/gem5/components/processors/base_cpu_core.py index 535a80000c..631fd0ad0e 100644 --- a/src/python/gem5/components/processors/base_cpu_core.py +++ b/src/python/gem5/components/processors/base_cpu_core.py @@ -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 diff --git a/src/python/gem5/simulate/simulator.py b/src/python/gem5/simulate/simulator.py index d7e214191b..0d2917d755 100644 --- a/src/python/gem5/simulate/simulator.py +++ b/src/python/gem5/simulate/simulator.py @@ -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: """