Files
gem5/util/cpt_upgraders/mempool-to-seworkload.py
Gabe Black 1a1ba692c3 sim: Move the MemPools object out of System and into SEWorkload.
This removes the need for all the FullSystem checks in the System class,
and simplifies that class in general.

Change-Id: Ie8a3bc67db9195027d2111009b15ca59221bdeb2
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50348
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-09-30 00:30:49 +00:00

33 lines
1.1 KiB
Python

# This upgrader moves memory pools from the system object to the SE workload
# object.
def upgrader(cpt):
systems = {}
# Find sections with 'num_mem_pools' options, and assume those are system
# objects which host MemPools.
for sec in cpt.sections():
num_mem_pools = cpt.get(sec, 'num_mem_pools', fallback=None)
if num_mem_pools is not None:
systems[sec] = num_mem_pools
for sec, num_mem_pools in systems.items():
# Transfer num_mem_pools to the new location.
cpt.remove_option(sec, 'num_mem_pools')
cpt.set(f'{sec}.workload', 'num_mem_pools', num_mem_pools)
for idx in range(int(num_mem_pools)):
old_name = f'{sec}.memPool{idx}'
new_name = f'{sec}.workload.memPool{idx}'
# Create the new section.
cpt.add_section(new_name)
# Copy items from the old section into it.
for item in cpt.items(old_name):
cpt.set(new_name, *item)
# Delete the old section.
cpt.remove_section(old_name)
depends = 'mempool-sections'