Davide Basilio Bartolini has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/36775 )
Change subject: cpu: Do not require default options for cache sizes
......................................................................
cpu: Do not require default options for cache sizes
This change is useful when using custom simulation scripts that do not
rely on configs/common/Options.py.
Without this change, the custom script always needed to provide some
value for cache sizes and HW prefetchers configuration; with this change
it is possible to provide no value and use what is defined in the core
configuration as default.
Change-Id: I00bd600054e2ee4d13346f2870b7630ac84581cb
---
M configs/common/CacheConfig.py
1 file changed, 30 insertions(+), 21 deletions(-)
diff --git a/configs/common/CacheConfig.py b/configs/common/CacheConfig.py
index 05c38e0..4117261 100644
--- a/configs/common/CacheConfig.py
+++ b/configs/common/CacheConfig.py
@@ -48,6 +48,27 @@
from common.Caches import *
from common import ObjectList
+def _print_hwp_warning(cacheString, hwpClass, prefetcher):
+ print("Warning:", cacheString, "-hwp-type is set (", hwpClass, "),
but",
+ "the current", cacheString, " has a default Hardware Prefetcher",
+ "of type", type(prefetcher), ", using the prefetcher type
specified",
+ "by the flag option.")
+
+def _get_cache_opts(level, options):
+ opts = {}
+
+ size_attr = '{}_size'.format(level)
+ if hasattr(options, size_attr):
+ opts['size'] = getattr(options, size_attr)
+
+ assoc_attr = '{}_assoc'.format(level)
+ if hasattr(options, assoc_attr):
+ opts['assoc'] = getattr(options, assoc_attr)
+ return opts
+
+def _is_opt_defined(opt, options):
+ return hasattr(options, opt) and getattr(options, opt) is not None
+
def config_cache(options, system):
if options.external_memory_system and (options.caches or
options.l2cache):
print("External caches and internal caches are exclusive
options.\n")
@@ -98,19 +119,15 @@
# are not connected using addTwoLevelCacheHierarchy. Use the
# same clock as the CPUs.
system.l2 = l2_cache_class(clk_domain=system.cpu_clk_domain,
- size=options.l2_size,
- assoc=options.l2_assoc)
+ **_get_cache_opts('l2', options))
system.tol2bus = L2XBar(clk_domain = system.cpu_clk_domain)
system.l2.cpu_side = system.tol2bus.master
system.l2.mem_side = system.membus.slave
- if options.l2_hwp_type:
+ if _is_opt_defined('l2_hwp_type', options):
hwpClass = ObjectList.hwp_list.get(options.l2_hwp_type)
if system.l2.prefetcher != "Null":
- print("Warning: l2-hwp-type is set (", hwpClass, "), but",
- "the current l2 has a default Hardware Prefetcher",
- "of type", type(system.l2.prefetcher), ", using the",
- "specified by the flag option.")
+ _print_hwp_warning("l2", hwpClass, system.l2.prefetcher)
system.l2.prefetcher = hwpClass()
if options.memchecker:
@@ -118,10 +135,8 @@
for i in range(options.num_cpus):
if options.caches:
- icache = icache_class(size=options.l1i_size,
- assoc=options.l1i_assoc)
- dcache = dcache_class(size=options.l1d_size,
- assoc=options.l1d_assoc)
+ icache = icache_class(**_get_cache_opts('l1i', options))
+ dcache = dcache_class(**_get_cache_opts('l1d', options))
# If we have a walker cache specified, instantiate two
# instances here
@@ -147,22 +162,16 @@
# Let CPU connect to monitors
dcache = dcache_mon
- if options.l1d_hwp_type:
+ if _is_opt_defined('l1d_hwp_type', options):
hwpClass = ObjectList.hwp_list.get(options.l1d_hwp_type)
if dcache.prefetcher != m5.params.NULL:
- print("Warning: l1d-hwp-type is set (", hwpClass, "),
but",
- "the current l1d has a default Hardware
Prefetcher",
- "of type", type(dcache.prefetcher), ", using
the",
- "specified by the flag option.")
+ _print_hwp_warning("l1d", hwpClass, dcache.prefetcher)
dcache.prefetcher = hwpClass()
- if options.l1i_hwp_type:
+ if _is_opt_defined('l1i_hwp_type', options):
hwpClass = ObjectList.hwp_list.get(options.l1i_hwp_type)
if icache.prefetcher != m5.params.NULL:
- print("Warning: l1i-hwp-type is set (", hwpClass, "),
but",
- "the current l1i has a default Hardware
Prefetcher",
- "of type", type(icache.prefetcher), ", using
the",
- "specified by the flag option.")
+ _print_hwp_warning("l1d", hwpClass, dcache.prefetcher)
icache.prefetcher = hwpClass()
# When connecting the caches, the clock is also inherited
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/36775
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I00bd600054e2ee4d13346f2870b7630ac84581cb
Gerrit-Change-Number: 36775
Gerrit-PatchSet: 1
Gerrit-Owner: Davide Basilio Bartolini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s