From 76d1d024dac2300989c7c9beaaa33ba9983e84e4 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Wed, 15 Mar 2023 16:29:59 -0700 Subject: [PATCH] stdlib: Fix SwitchableProcessor use in SE mode The SwitchableProcessors in the standard library have switched-in and switched-out cores. The `get_cores` API in the stdlib only returns switched-in cores. In most uses this is desirable. In the case of setting workloads in SE mode it's necessary to set the workload to every core, switched-in and switched-out. As the `get_cores` function was used for this, SwitchableProcessors were failing when used in SE Mode. This patch checks the processor type and, if a SwitchableProcessor, uses the SwitchableProcessor's special `_all_cores` function which gets all the cores, regardless as to their switched-in/switched-out status. Issue-on: https://gem5.atlassian.net/browse/GEM5-1320 Change-Id: I0b7a699ac6196e827667955bef7afa37b2648744 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/68997 Reviewed-by: Jason Lowe-Power Tested-by: kokoro Maintainer: Bobby Bruce Reviewed-by: Bobby Bruce --- .../components/boards/se_binary_workload.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/python/gem5/components/boards/se_binary_workload.py b/src/python/gem5/components/boards/se_binary_workload.py index 98fe840a27..c62a1b67ea 100644 --- a/src/python/gem5/components/boards/se_binary_workload.py +++ b/src/python/gem5/components/boards/se_binary_workload.py @@ -35,6 +35,8 @@ from ...resources.resource import ( SimpointDirectoryResource, ) +from ..processors.switchable_processor import SwitchableProcessor + from gem5.resources.elfie import ELFieInfo from gem5.resources.looppoint import Looppoint @@ -112,8 +114,23 @@ class SEBinaryWorkload: if env_list is not None: process.env = env_list - for core in self.get_processor().get_cores(): - core.set_workload(process) + if isinstance(self.get_processor(), SwitchableProcessor): + # This is a hack to get switchable processors working correctly in + # SE mode. The "get_cores" API for processors only gets the current + # switched-in cores and, in most cases, this is what the script + # required. In the case there are switched-out cores via the + # SwitchableProcessor, we sometimes need to apply things to ALL + # cores (switched-in or switched-out). In this case we have an + # `__all_cores` function. Here we must apply the process to every + # core. + # + # A better API for this which avoids `isinstance` checks would be + # welcome. + for core in self.get_processor()._all_cores(): + core.set_workload(process) + else: + for core in self.get_processor().get_cores(): + core.set_workload(process) # Set whether to exit on work items for the se_workload self.exit_on_work_items = exit_on_work_items