Giacomo Travaglini has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/43287 )
Change subject: configs, tests: Ruby.create_system cpus option
......................................................................
configs, tests: Ruby.create_system cpus option
This patch is adding an extra parameter to the Ruby.create_system
function. The idea is to remove any assumption about cpu configuration
in the ruby scripts.
At the moment the scripts are assuming a flat list of cpu assigned
to the system object. Unfortunately this is not standardized, as
some systems might empoloy a different layout of cpus, like grouping
them in cluster objects.
With this patch we are allowing client scripts to provide the cpu list
as an extra argument
This has the extra benefit of removing the indexing hack
if len(system.cpu) == 1:
which was present in most scripts
Change-Id: Ibc06b920273cde4f7c394d61c0ca664a7143cd27
Signed-off-by: Giacomo Travaglini <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/43287
Maintainer: Bobby R. Bruce <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
Tested-by: kokoro <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
---
M configs/example/ruby_direct_test.py
M configs/example/ruby_gpu_random_test.py
M configs/example/ruby_random_test.py
M configs/ruby/CHI.py
M configs/ruby/MESI_Three_Level.py
M configs/ruby/MESI_Three_Level_HTM.py
M configs/ruby/MESI_Two_Level.py
M configs/ruby/MI_example.py
M configs/ruby/MOESI_CMP_directory.py
M configs/ruby/MOESI_CMP_token.py
M configs/ruby/MOESI_hammer.py
M configs/ruby/Ruby.py
M tests/configs/gpu-randomtest-ruby.py
M tests/configs/rubytest-ruby.py
14 files changed, 58 insertions(+), 94 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
Bobby R. Bruce: Looks good to me, approved
kokoro: Regressions pass
diff --git a/configs/example/ruby_direct_test.py
b/configs/example/ruby_direct_test.py
index 60defb9..163b38f 100644
--- a/configs/example/ruby_direct_test.py
+++ b/configs/example/ruby_direct_test.py
@@ -97,7 +97,13 @@
system.cpu = RubyDirectedTester(requests_to_complete = options.requests,
generator = generator)
-Ruby.create_system(options, False, system)
+# the ruby tester reuses num_cpus to specify the
+# number of cpu ports connected to the tester object, which
+# is stored in system.cpu. because there is only ever one
+# tester object, num_cpus is not necessarily equal to the
+# size of system.cpu
+cpu_list = [ system.cpu ] * options.num_cpus
+Ruby.create_system(options, False, system, cpus=cpu_list)
# Since Ruby runs at an independent frequency, create a seperate clock
system.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
diff --git a/configs/example/ruby_gpu_random_test.py
b/configs/example/ruby_gpu_random_test.py
index 133c13a..745ad02 100644
--- a/configs/example/ruby_gpu_random_test.py
+++ b/configs/example/ruby_gpu_random_test.py
@@ -249,8 +249,15 @@
#
# Create the Ruby system
#
+# the ruby tester reuses num_cpus to specify the
+# number of cpu ports connected to the tester object, which
+# is stored in system.cpu. because there is only ever one
+# tester object, num_cpus is not necessarily equal to the
+# size of system.cpu
+cpu_list = [ system.cpu ] * options.num_cpus
Ruby.create_system(options = options, full_system = False,
- system = system, dma_ports = system.dma_devices)
+ system = system, dma_ports = system.dma_devices,
+ cpus = cpu_list)
#
# The tester is most effective when randomization is turned on and
diff --git a/configs/example/ruby_random_test.py
b/configs/example/ruby_random_test.py
index dc76827..da82429 100644
--- a/configs/example/ruby_random_test.py
+++ b/configs/example/ruby_random_test.py
@@ -103,7 +103,13 @@
system.clk_domain = SrcClockDomain(clock = options.sys_clock,
voltage_domain = system.voltage_domain)
-Ruby.create_system(options, False, system)
+# the ruby tester reuses num_cpus to specify the
+# number of cpu ports connected to the tester object, which
+# is stored in system.cpu. because there is only ever one
+# tester object, num_cpus is not necessarily equal to the
+# size of system.cpu
+cpu_list = [ system.cpu ] * options.num_cpus
+Ruby.create_system(options, False, system, cpus=cpu_list)
# Create a seperate clock domain for Ruby
system.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
diff --git a/configs/ruby/CHI.py b/configs/ruby/CHI.py
index 0a49371..db686ed 100644
--- a/configs/ruby/CHI.py
+++ b/configs/ruby/CHI.py
@@ -646,7 +646,7 @@
def create_system(options, full_system, system, dma_ports, bootmem,
- ruby_system):
+ ruby_system, cpus):
if buildEnv['PROTOCOL'] != 'CHI':
m5.panic("This script requires the CHI build")
@@ -721,10 +721,10 @@
all_cntrls = []
# Creates on RNF per cpu with priv l2 caches
- assert(len(system.cpu) == options.num_cpus)
+ assert(len(cpus) == options.num_cpus)
ruby_system.rnf = [ CHI_RNF([cpu], ruby_system, L1ICache, L1DCache,
system.cache_line_size.value)
- for cpu in system.cpu ]
+ for cpu in cpus ]
for rnf in ruby_system.rnf:
rnf.addPrivL2Cache(L2Cache)
cpu_sequencers.extend(rnf.getSequencers())
diff --git a/configs/ruby/MESI_Three_Level.py
b/configs/ruby/MESI_Three_Level.py
index 91ccb58..bd0e97e 100644
--- a/configs/ruby/MESI_Three_Level.py
+++ b/configs/ruby/MESI_Three_Level.py
@@ -58,7 +58,7 @@
return
def create_system(options, full_system, system, dma_ports, bootmem,
- ruby_system):
+ ruby_system, cpus):
if buildEnv['PROTOCOL'] != 'MESI_Three_Level':
fatal("This script requires the MESI_Three_Level protocol to be\
@@ -108,17 +108,7 @@
start_index_bit = block_size_bits,
replacement_policy = LRURP())
- # the ruby random tester reuses num_cpus to specify the
- # number of cpu ports connected to the tester object, which
- # is stored in system.cpu. because there is only ever one
- # tester object, num_cpus is not necessarily equal to the
- # size of system.cpu; therefore if len(system.cpu) == 1
- # we use system.cpu[0] to set the clk_domain, thereby ensuring
- # we don't index off the end of the cpu list.
- if len(system.cpu) == 1:
- clk_domain = system.cpu[0].clk_domain
- else:
- clk_domain = system.cpu[i].clk_domain
+ clk_domain = cpus[i].clk_domain
# Ruby prefetcher
prefetcher = RubyPrefetcher(
diff --git a/configs/ruby/MESI_Three_Level_HTM.py
b/configs/ruby/MESI_Three_Level_HTM.py
index f39e457..946b641 100644
--- a/configs/ruby/MESI_Three_Level_HTM.py
+++ b/configs/ruby/MESI_Three_Level_HTM.py
@@ -58,7 +58,7 @@
return
def create_system(options, full_system, system, dma_ports, bootmem,
- ruby_system):
+ ruby_system, cpus):
if buildEnv['PROTOCOL'] != 'MESI_Three_Level_HTM':
fatal("This script requires the MESI_Three_Level protocol to be\
@@ -108,17 +108,7 @@
start_index_bit = block_size_bits,
replacement_policy = LRURP())
- # the ruby random tester reuses num_cpus to specify the
- # number of cpu ports connected to the tester object, which
- # is stored in system.cpu. because there is only ever one
- # tester object, num_cpus is not necessarily equal to the
- # size of system.cpu; therefore if len(system.cpu) == 1
- # we use system.cpu[0] to set the clk_domain, thereby ensuring
- # we don't index off the end of the cpu list.
- if len(system.cpu) == 1:
- clk_domain = system.cpu[0].clk_domain
- else:
- clk_domain = system.cpu[i].clk_domain
+ clk_domain = cpus[i].clk_domain
# Ruby prefetcher
prefetcher = RubyPrefetcher(
diff --git a/configs/ruby/MESI_Two_Level.py b/configs/ruby/MESI_Two_Level.py
index 96650e0..e6d91ce 100644
--- a/configs/ruby/MESI_Two_Level.py
+++ b/configs/ruby/MESI_Two_Level.py
@@ -42,7 +42,7 @@
return
def create_system(options, full_system, system, dma_ports, bootmem,
- ruby_system):
+ ruby_system, cpus):
if buildEnv['PROTOCOL'] != 'MESI_Two_Level':
fatal("This script requires the MESI_Two_Level protocol to be
built.")
@@ -80,17 +80,7 @@
prefetcher = RubyPrefetcher()
- # the ruby random tester reuses num_cpus to specify the
- # number of cpu ports connected to the tester object, which
- # is stored in system.cpu. because there is only ever one
- # tester object, num_cpus is not necessarily equal to the
- # size of system.cpu; therefore if len(system.cpu) == 1
- # we use system.cpu[0] to set the clk_domain, thereby ensuring
- # we don't index off the end of the cpu list.
- if len(system.cpu) == 1:
- clk_domain = system.cpu[0].clk_domain
- else:
- clk_domain = system.cpu[i].clk_domain
+ clk_domain = cpus[i].clk_domain
l1_cntrl = L1Cache_Controller(version = i, L1Icache = l1i_cache,
L1Dcache = l1d_cache,
diff --git a/configs/ruby/MI_example.py b/configs/ruby/MI_example.py
index 6e5c8b4..79259d9 100644
--- a/configs/ruby/MI_example.py
+++ b/configs/ruby/MI_example.py
@@ -41,7 +41,7 @@
return
def create_system(options, full_system, system, dma_ports, bootmem,
- ruby_system):
+ ruby_system, cpus):
if buildEnv['PROTOCOL'] != 'MI_example':
panic("This script requires the MI_example protocol to be built.")
@@ -73,17 +73,7 @@
start_index_bit = block_size_bits)
- # the ruby random tester reuses num_cpus to specify the
- # number of cpu ports connected to the tester object, which
- # is stored in system.cpu. because there is only ever one
- # tester object, num_cpus is not necessarily equal to the
- # size of system.cpu; therefore if len(system.cpu) == 1
- # we use system.cpu[0] to set the clk_domain, thereby ensuring
- # we don't index off the end of the cpu list.
- if len(system.cpu) == 1:
- clk_domain = system.cpu[0].clk_domain
- else:
- clk_domain = system.cpu[i].clk_domain
+ clk_domain = cpus[i].clk_domain
# Only one unified L1 cache exists. Can cache instructions and
data.
l1_cntrl = L1Cache_Controller(version=i, cacheMemory=cache,
diff --git a/configs/ruby/MOESI_CMP_directory.py
b/configs/ruby/MOESI_CMP_directory.py
index 5366fe7..1257f6d 100644
--- a/configs/ruby/MOESI_CMP_directory.py
+++ b/configs/ruby/MOESI_CMP_directory.py
@@ -59,7 +59,7 @@
return
def create_system(options, full_system, system, dma_ports, bootmem,
- ruby_system):
+ ruby_system, cpus):
if buildEnv['PROTOCOL'] != 'MOESI_CMP_directory':
panic("This script requires the MOESI_CMP_directory protocol to be
built.")
@@ -94,17 +94,7 @@
start_index_bit = block_size_bits,
is_icache = False)
- # the ruby random tester reuses num_cpus to specify the
- # number of cpu ports connected to the tester object, which
- # is stored in system.cpu. because there is only ever one
- # tester object, num_cpus is not necessarily equal to the
- # size of system.cpu; therefore if len(system.cpu) == 1
- # we use system.cpu[0] to set the clk_domain, thereby ensuring
- # we don't index off the end of the cpu list.
- if len(system.cpu) == 1:
- clk_domain = system.cpu[0].clk_domain
- else:
- clk_domain = system.cpu[i].clk_domain
+ clk_domain = cpus[i].clk_domain
l1_cntrl = L1Cache_Controller(version=i, L1Icache=l1i_cache,
L1Dcache=l1d_cache,
diff --git a/configs/ruby/MOESI_CMP_token.py
b/configs/ruby/MOESI_CMP_token.py
index 28ec52f..91d02a0 100644
--- a/configs/ruby/MOESI_CMP_token.py
+++ b/configs/ruby/MOESI_CMP_token.py
@@ -49,7 +49,7 @@
help="allow migratory sharing for atomic only accessed blocks")
def create_system(options, full_system, system, dma_ports, bootmem,
- ruby_system):
+ ruby_system, cpus):
if buildEnv['PROTOCOL'] != 'MOESI_CMP_token':
panic("This script requires the MOESI_CMP_token protocol to be
built.")
@@ -89,17 +89,7 @@
assoc = options.l1d_assoc,
start_index_bit = block_size_bits)
- # the ruby random tester reuses num_cpus to specify the
- # number of cpu ports connected to the tester object, which
- # is stored in system.cpu. because there is only ever one
- # tester object, num_cpus is not necessarily equal to the
- # size of system.cpu; therefore if len(system.cpu) == 1
- # we use system.cpu[0] to set the clk_domain, thereby ensuring
- # we don't index off the end of the cpu list.
- if len(system.cpu) == 1:
- clk_domain = system.cpu[0].clk_domain
- else:
- clk_domain = system.cpu[i].clk_domain
+ clk_domain = cpus[i].clk_domain
l1_cntrl = L1Cache_Controller(version=i, L1Icache=l1i_cache,
L1Dcache=l1d_cache,
diff --git a/configs/ruby/MOESI_hammer.py b/configs/ruby/MOESI_hammer.py
index 1e00f0f..adff1c9 100644
--- a/configs/ruby/MOESI_hammer.py
+++ b/configs/ruby/MOESI_hammer.py
@@ -52,7 +52,7 @@
help="Hammer: enable Full-bit Directory")
def create_system(options, full_system, system, dma_ports, bootmem,
- ruby_system):
+ ruby_system, cpus):
if buildEnv['PROTOCOL'] != 'MOESI_hammer':
panic("This script requires the MOESI_hammer protocol to be
built.")
@@ -88,17 +88,7 @@
assoc = options.l2_assoc,
start_index_bit = block_size_bits)
- # the ruby random tester reuses num_cpus to specify the
- # number of cpu ports connected to the tester object, which
- # is stored in system.cpu. because there is only ever one
- # tester object, num_cpus is not necessarily equal to the
- # size of system.cpu; therefore if len(system.cpu) == 1
- # we use system.cpu[0] to set the clk_domain, thereby ensuring
- # we don't index off the end of the cpu list.
- if len(system.cpu) == 1:
- clk_domain = system.cpu[0].clk_domain
- else:
- clk_domain = system.cpu[i].clk_domain
+ clk_domain = cpus[i].clk_domain
l1_cntrl = L1Cache_Controller(version=i, L1Icache=l1i_cache,
L1Dcache=l1d_cache, L2cache=l2_cache,
diff --git a/configs/ruby/Ruby.py b/configs/ruby/Ruby.py
index 2bed341..e7609f4 100644
--- a/configs/ruby/Ruby.py
+++ b/configs/ruby/Ruby.py
@@ -172,7 +172,7 @@
return topology
def create_system(options, full_system, system, piobus = None, dma_ports =
[],
- bootmem=None):
+ bootmem=None, cpus=None):
system.ruby = RubySystem()
ruby = system.ruby
@@ -185,12 +185,15 @@
Network.create_network(options, ruby)
ruby.network = network
+ if cpus is None:
+ cpus = system.cpu
+
protocol = buildEnv['PROTOCOL']
exec("from . import %s" % protocol)
try:
(cpu_sequencers, dir_cntrls, topology) = \
eval("%s.create_system(options, full_system, system,
dma_ports,\
- bootmem, ruby)"
+ bootmem, ruby, cpus)"
% protocol)
except:
print("Error: could not create sytem for ruby protocol %s" %
protocol)
diff --git a/tests/configs/gpu-randomtest-ruby.py
b/tests/configs/gpu-randomtest-ruby.py
index 3d088f4..246affa 100644
--- a/tests/configs/gpu-randomtest-ruby.py
+++ b/tests/configs/gpu-randomtest-ruby.py
@@ -100,7 +100,13 @@
system.mem_ranges = AddrRange('256MB')
-Ruby.create_system(options, False, system)
+# the ruby tester reuses num_cpus to specify the
+# number of cpu ports connected to the tester object, which
+# is stored in system.cpu. because there is only ever one
+# tester object, num_cpus is not necessarily equal to the
+# size of system.cpu
+cpu_list = [ system.cpu ] * options.num_cpus
+Ruby.create_system(options, False, system, cpus=cpu_list)
# Create a separate clock domain for Ruby
system.ruby.clk_domain = SrcClockDomain(clock = '1GHz',
diff --git a/tests/configs/rubytest-ruby.py b/tests/configs/rubytest-ruby.py
index 5c01cff..0db7e38 100644
--- a/tests/configs/rubytest-ruby.py
+++ b/tests/configs/rubytest-ruby.py
@@ -80,7 +80,13 @@
system.mem_ranges = AddrRange('256MB')
-Ruby.create_system(options, False, system)
+# the ruby tester reuses num_cpus to specify the
+# number of cpu ports connected to the tester object, which
+# is stored in system.cpu. because there is only ever one
+# tester object, num_cpus is not necessarily equal to the
+# size of system.cpu
+cpu_list = [ system.cpu ] * options.num_cpus
+Ruby.create_system(options, False, system, cpus=cpu_list)
# Create a separate clock domain for Ruby
system.ruby.clk_domain = SrcClockDomain(clock = '1GHz',
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/43287
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: Ibc06b920273cde4f7c394d61c0ca664a7143cd27
Gerrit-Change-Number: 43287
Gerrit-PatchSet: 4
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s