Giacomo Travaglini has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/43287 )

Change subject: configs, tests: create_system ruby option
......................................................................

configs, tests: create_system ruby 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.

Since the only use of the system.cpu list is to provide the clock
domain to the private L1 cache controllers, we are allowing
client scripts to provide the domain 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]>
---
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/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
13 files changed, 56 insertions(+), 92 deletions(-)



diff --git a/configs/example/ruby_direct_test.py b/configs/example/ruby_direct_test.py
index 60defb9..11e34e9 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_clk_domains = [ system.cpu.clk_domain ] * options.num_cpus
+Ruby.create_system(options, False, system, cpu_clk=cpu_clk_domains)

 # 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..4c0b434 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_clk_domains = [ system.cpu.clk_domain ] * 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,
+                   cpu_clk = cpu_clk_domains)

 #
 # 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..99780b5 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_clk_domains = [ system.cpu.clk_domain ] * options.num_cpus
+Ruby.create_system(options, False, system, cpu_clk=cpu_clk_domains)

 # Create a seperate clock domain for Ruby
 system.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
diff --git a/configs/ruby/MESI_Three_Level.py b/configs/ruby/MESI_Three_Level.py
index 91ccb58..dfb8995 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, cpu_clk):

     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 = cpu_clk[i]

             # Ruby prefetcher
             prefetcher = RubyPrefetcher(
diff --git a/configs/ruby/MESI_Three_Level_HTM.py b/configs/ruby/MESI_Three_Level_HTM.py
index 89ca93c..f8d96a0 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, cpu_clk):

     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 = cpu_clk[i]

             # Ruby prefetcher
             prefetcher = RubyPrefetcher(
diff --git a/configs/ruby/MESI_Two_Level.py b/configs/ruby/MESI_Two_Level.py
index 96650e0..08b3add 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, cpu_clk):

     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 = cpu_clk[i]

         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..4305cbe 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, cpu_clk):

     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 = cpu_clk[i]

# 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..cdb8352 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, cpu_clk):

     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 = cpu_clk[i]

         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..1f918b7 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, cpu_clk):

     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 = cpu_clk[i]

         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..e20c00f 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, cpu_clk):

     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 = cpu_clk[i]

         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..a6c90f1 100644
--- a/configs/ruby/Ruby.py
+++ b/configs/ruby/Ruby.py
@@ -171,8 +171,8 @@
     topology = eval("Topo.%s(controllers)" % options.topology)
     return topology

-def create_system(options, full_system, system, piobus = None, dma_ports = [],
-                  bootmem=None):
+def create_system(options, full_system, system, piobus=None,
+                  dma_ports =[], bootmem=None, cpu_clk=None):

     system.ruby = RubySystem()
     ruby = system.ruby
@@ -185,12 +185,15 @@
         Network.create_network(options, ruby)
     ruby.network = network

+    if cpu_clk is None:
+        cpu_clk = [ cpu.clk_domain for cpu in 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, cpu_clk)"
                   % 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..4551934 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_clk_domains = [ system.cpu.clk_domain ] * options.num_cpus
+Ruby.create_system(options, False, system, clk_domain=cpu_clk_domains)

 # 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..951b815 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_clk_domains = [ system.cpu.clk_domain ] * options.num_cpus
+Ruby.create_system(options, False, system, cpu_clk=cpu_clk_domains)

 # 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: 1
Gerrit-Owner: Giacomo Travaglini <[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

Reply via email to