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 <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
This commit is contained in:
Bobby R. Bruce
2023-03-15 16:29:59 -07:00
committed by Bobby Bruce
parent 851e469e55
commit 76d1d024da

View File

@@ -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