Files
gem5/util/cpt_upgraders/mempool-to-seworkload.py
Bobby R. Bruce 787204c92d python: Apply Black formatter to Python files
The command executed was `black src configs tests util`.

Change-Id: I8dfaa6ab04658fea37618127d6ac19270028d771
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47024
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-08-03 09:10:41 +00:00

34 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"