Jason Lowe-Power has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/58449 )

Change subject: configs: Replace buildEnv with getRubyProtocol
......................................................................

configs: Replace buildEnv with getRubyProtocol

Instead of using `buildEnv['PROTOCOL']` use the new function
`getRubyProtocol()`.

*User-facing change!*
We are deprecating the use of buildEnv['PROTOCOL'] when transitioning to
enable multiple Ruby protocols in a single binary. If you have any
configuration scripts that rely on buildEnv['PROTOCOL'] they should be
updated as shown below.

`buildEnv['PROTOCOL']` -> `getRubyProtocol()`

Change-Id: Ic4d010f93a027be03767d5306c2eee6c13ed9511
Signed-off-by: Jason Lowe-Power <ja...@lowepower.com>
---
M configs/common/FSConfig.py
M configs/example/apu_se.py
M configs/example/gpufs/Disjoint_VIPER.py
M configs/example/ruby_random_test.py
M configs/learning_gem5/part3/msi_caches.py
M configs/learning_gem5/part3/ruby_caches_MI_example.py
M configs/learning_gem5/part3/test_caches.py
M configs/ruby/AMD_Base_Constructor.py
M configs/ruby/CHI.py
M configs/ruby/GPU_VIPER.py
M configs/ruby/Garnet_standalone.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_AMD_Base.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 configs/topologies/CustomMesh.py
M tests/configs/gpu-randomtest-ruby.py
M tests/configs/gpu-ruby.py
M tests/configs/rubytest-ruby.py
24 files changed, 72 insertions(+), 49 deletions(-)



diff --git a/configs/common/FSConfig.py b/configs/common/FSConfig.py
index a7ba815..61d8958 100644
--- a/configs/common/FSConfig.py
+++ b/configs/common/FSConfig.py
@@ -41,6 +41,7 @@
 import m5
 from m5.objects import *
 from m5.util import *
+from m5.defines import *
 from common.Benchmarks import *
 from common import ObjectList

@@ -339,7 +340,7 @@
         self.system_port = self.membus.cpu_side_ports

     if ruby:
-        if buildEnv['PROTOCOL'] == 'MI_example' and num_cpus > 1:
+        if getRubyProtocol() == 'MI_example' and num_cpus > 1:
             fatal("The MI_example protocol cannot implement Load/Store "
                   "Exclusive operations. Multicore ARM systems configured "
                   "with the MI_example protocol will not work properly.")
diff --git a/configs/example/apu_se.py b/configs/example/apu_se.py
index b5fb9ff..6bb4151 100644
--- a/configs/example/apu_se.py
+++ b/configs/example/apu_se.py
@@ -34,6 +34,7 @@

 import m5
 from m5.objects import *
+from m5.defines import buildEnv, getRubyProtocol
 from m5.util import addToPath

 addToPath('../')
@@ -211,7 +212,7 @@
 ########################## Sanity Check ########################

 # Currently the gpu model requires ruby
-if buildEnv['PROTOCOL'] == 'None':
+if getRubyProtocol() == 'None':
     fatal("GPU model requires ruby")

 # Currently the gpu model requires only timing or detailed CPU
@@ -252,7 +253,7 @@
# means pipeline initiates a acquire/release operation at kernel launch/end.
 # VIPER protocol is write-through based, and thus only impl_kern_launch_acq
 # needs to set.
-if (buildEnv['PROTOCOL'] == 'GPU_VIPER'):
+if (getRubyProtocol() == 'GPU_VIPER'):
     shader.impl_kern_launch_acq = True
     shader.impl_kern_end_rel = False
 else:
diff --git a/configs/example/gpufs/Disjoint_VIPER.py b/configs/example/gpufs/Disjoint_VIPER.py
index 8ddaeac..65d3d2f 100644
--- a/configs/example/gpufs/Disjoint_VIPER.py
+++ b/configs/example/gpufs/Disjoint_VIPER.py
@@ -27,7 +27,7 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.

-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from m5.objects import *
 from m5.util import fatal

@@ -45,7 +45,7 @@

 class Disjoint_VIPER(RubySystem):
     def __init__(self):
-        if buildEnv['PROTOCOL'] != "GPU_VIPER":
+        if getRubyProtocol() != "GPU_VIPER":
             fatal("This ruby config only supports the GPU_VIPER protocol")

         super(Disjoint_VIPER, self).__init__()
diff --git a/configs/example/ruby_random_test.py b/configs/example/ruby_random_test.py
index edc8ee8..7849cae 100644
--- a/configs/example/ruby_random_test.py
+++ b/configs/example/ruby_random_test.py
@@ -27,7 +27,7 @@

 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from m5.util import addToPath
 import os, argparse, sys

@@ -79,7 +79,7 @@

 # Check the protocol
 check_flush = False
-if buildEnv['PROTOCOL'] == 'MOESI_hammer':
+if getRubyProtocol() == 'MOESI_hammer':
     check_flush = True

 tester = RubyTester(check_flush = check_flush,
diff --git a/configs/learning_gem5/part3/msi_caches.py b/configs/learning_gem5/part3/msi_caches.py
index 5abfff0..fb5e976 100644
--- a/configs/learning_gem5/part3/msi_caches.py
+++ b/configs/learning_gem5/part3/msi_caches.py
@@ -37,7 +37,7 @@

 import math

-from m5.defines import buildEnv
+from m5.defines import buildEnv, getRubyProtocol
 from m5.util import fatal, panic

 from m5.objects import *
@@ -45,7 +45,7 @@
 class MyCacheSystem(RubySystem):

     def __init__(self):
-        if buildEnv['PROTOCOL'] != 'MSI':
+        if getRubyProtocol() != 'MSI':
             fatal("This system assumes MSI from learning gem5!")

         super(MyCacheSystem, self).__init__()
diff --git a/configs/learning_gem5/part3/ruby_caches_MI_example.py b/configs/learning_gem5/part3/ruby_caches_MI_example.py
index 9e5f9cf..be12fae 100644
--- a/configs/learning_gem5/part3/ruby_caches_MI_example.py
+++ b/configs/learning_gem5/part3/ruby_caches_MI_example.py
@@ -39,7 +39,7 @@

 import math

-from m5.defines import buildEnv
+from m5.defines import buildEnv, getRubyProtocol
 from m5.util import fatal, panic

 from m5.objects import *
@@ -47,7 +47,7 @@
 class MyCacheSystem(RubySystem):

     def __init__(self):
-        if buildEnv['PROTOCOL'] != 'MI_example':
+        if getRubyProtocol() != 'MI_example':
             fatal("This system assumes MI_example!")

         super(MyCacheSystem, self).__init__()
diff --git a/configs/learning_gem5/part3/test_caches.py b/configs/learning_gem5/part3/test_caches.py
index 00a1fe3..0d5fc75 100644
--- a/configs/learning_gem5/part3/test_caches.py
+++ b/configs/learning_gem5/part3/test_caches.py
@@ -35,7 +35,7 @@

 """

-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from m5.util import fatal

 from m5.objects import *
@@ -45,7 +45,7 @@
 class TestCacheSystem(RubySystem):

     def __init__(self):
-        if buildEnv['PROTOCOL'] != 'MSI':
+        if getRubyProtocol() != 'MSI':
             fatal("This system assumes MSI from learning gem5!")

         super(TestCacheSystem, self).__init__()
diff --git a/configs/ruby/AMD_Base_Constructor.py b/configs/ruby/AMD_Base_Constructor.py
index 93907a3..f968837 100644
--- a/configs/ruby/AMD_Base_Constructor.py
+++ b/configs/ruby/AMD_Base_Constructor.py
@@ -30,7 +30,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from m5.util import addToPath, convert
 from .CntrlBase import *

@@ -100,7 +100,7 @@
     parser.add_argument("--cpu-to-dir-latency", type=int, default=15)

 def construct(options, system, ruby_system):
-    if buildEnv['PROTOCOL'] != 'GPU_VIPER':
+    if getRubyProtocol() != 'GPU_VIPER':
         panic("This script requires VIPER based protocols \
         to be built.")
     cpu_sequencers = []
diff --git a/configs/ruby/CHI.py b/configs/ruby/CHI.py
index 3fe8b26..3cccc25 100644
--- a/configs/ruby/CHI.py
+++ b/configs/ruby/CHI.py
@@ -35,7 +35,7 @@

 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from .Ruby import create_topology

 def define_options(parser):
@@ -56,7 +56,7 @@
 def create_system(options, full_system, system, dma_ports, bootmem,
                   ruby_system, cpus):

-    if buildEnv['PROTOCOL'] != 'CHI':
+    if getRubyProtocol() != 'CHI':
         m5.panic("This script requires the CHI build")

     if options.num_dirs < 1:
diff --git a/configs/ruby/GPU_VIPER.py b/configs/ruby/GPU_VIPER.py
index 9f341c5..2b0b321 100644
--- a/configs/ruby/GPU_VIPER.py
+++ b/configs/ruby/GPU_VIPER.py
@@ -30,7 +30,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from m5.util import addToPath
 from .Ruby import create_topology
 from .Ruby import send_evicts
@@ -796,7 +796,7 @@

 def create_system(options, full_system, system, dma_devices, bootmem,
                   ruby_system, cpus):
-    if buildEnv['PROTOCOL'] != 'GPU_VIPER':
+    if getRubyProtocol() != 'GPU_VIPER':
         panic("This script requires the GPU_VIPER protocol to be built.")

     cpu_sequencers = []
diff --git a/configs/ruby/Garnet_standalone.py b/configs/ruby/Garnet_standalone.py
index f8e21fc..9a702f5 100644
--- a/configs/ruby/Garnet_standalone.py
+++ b/configs/ruby/Garnet_standalone.py
@@ -27,7 +27,7 @@

 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from m5.util import addToPath
 from .Ruby import create_topology, create_directories

@@ -41,7 +41,7 @@

 def create_system(options, full_system, system, dma_ports, bootmem,
                   ruby_system, cpus):
-    if buildEnv['PROTOCOL'] != 'Garnet_standalone':
+    if getRubyProtocol() != 'Garnet_standalone':
panic("This script requires Garnet_standalone protocol to be built.")

     cpu_sequencers = []
diff --git a/configs/ruby/MESI_Three_Level.py b/configs/ruby/MESI_Three_Level.py
index c184e57..e91301b 100644
--- a/configs/ruby/MESI_Three_Level.py
+++ b/configs/ruby/MESI_Three_Level.py
@@ -30,7 +30,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from .Ruby import create_topology, create_directories
 from .Ruby import send_evicts
 from common import FileSystemConfig
@@ -62,7 +62,7 @@
 def create_system(options, full_system, system, dma_ports, bootmem,
                   ruby_system, cpus):

-    if buildEnv['PROTOCOL'] != 'MESI_Three_Level':
+    if getRubyProtocol() != 'MESI_Three_Level':
         fatal("This script requires the MESI_Three_Level protocol to be\
                built.")

diff --git a/configs/ruby/MESI_Three_Level_HTM.py b/configs/ruby/MESI_Three_Level_HTM.py
index 974cd7e..cc55213 100644
--- a/configs/ruby/MESI_Three_Level_HTM.py
+++ b/configs/ruby/MESI_Three_Level_HTM.py
@@ -30,7 +30,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from .Ruby import create_topology, create_directories
 from .Ruby import send_evicts
 from common import FileSystemConfig
@@ -61,7 +61,7 @@
 def create_system(options, full_system, system, dma_ports, bootmem,
                   ruby_system, cpus):

-    if buildEnv['PROTOCOL'] != 'MESI_Three_Level_HTM':
+    if getRubyProtocol() != 'MESI_Three_Level_HTM':
         fatal("This script requires the MESI_Three_Level protocol to be\
                built.")

diff --git a/configs/ruby/MESI_Two_Level.py b/configs/ruby/MESI_Two_Level.py
index e1bb9e7..5988e76 100644
--- a/configs/ruby/MESI_Two_Level.py
+++ b/configs/ruby/MESI_Two_Level.py
@@ -28,7 +28,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from .Ruby import create_topology, create_directories
 from .Ruby import send_evicts

@@ -44,7 +44,7 @@
 def create_system(options, full_system, system, dma_ports, bootmem,
                   ruby_system, cpus):

-    if buildEnv['PROTOCOL'] != 'MESI_Two_Level':
+    if getRubyProtocol() != 'MESI_Two_Level':
fatal("This script requires the MESI_Two_Level protocol to be built.")

     cpu_sequencers = []
diff --git a/configs/ruby/MI_example.py b/configs/ruby/MI_example.py
index a46a9e9..8fcb06d 100644
--- a/configs/ruby/MI_example.py
+++ b/configs/ruby/MI_example.py
@@ -28,7 +28,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from .Ruby import create_topology, create_directories
 from .Ruby import send_evicts

@@ -43,7 +43,7 @@
 def create_system(options, full_system, system, dma_ports, bootmem,
                   ruby_system, cpus):

-    if buildEnv['PROTOCOL'] != 'MI_example':
+    if getRubyProtocol() != 'MI_example':
         panic("This script requires the MI_example protocol to be built.")

     cpu_sequencers = []
diff --git a/configs/ruby/MOESI_AMD_Base.py b/configs/ruby/MOESI_AMD_Base.py
index 0833915..10a6a35 100644
--- a/configs/ruby/MOESI_AMD_Base.py
+++ b/configs/ruby/MOESI_AMD_Base.py
@@ -30,7 +30,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from m5.util import addToPath
 from .Ruby import create_topology
 from .Ruby import send_evicts
@@ -206,7 +206,7 @@

 def create_system(options, full_system, system, dma_devices, bootmem,
                   ruby_system):
-    if buildEnv['PROTOCOL'] != 'MOESI_AMD_Base':
+    if getRubyProtocol() != 'MOESI_AMD_Base':
         panic("This script requires the MOESI_AMD_Base protocol.")

     cpu_sequencers = []
diff --git a/configs/ruby/MOESI_CMP_directory.py b/configs/ruby/MOESI_CMP_directory.py
index dcab1e4..8584f19 100644
--- a/configs/ruby/MOESI_CMP_directory.py
+++ b/configs/ruby/MOESI_CMP_directory.py
@@ -40,7 +40,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from .Ruby import create_topology, create_directories
 from .Ruby import send_evicts

@@ -61,7 +61,7 @@
 def create_system(options, full_system, system, dma_ports, bootmem,
                   ruby_system, cpus):

-    if buildEnv['PROTOCOL'] != 'MOESI_CMP_directory':
+    if getRubyProtocol() != 'MOESI_CMP_directory':
panic("This script requires the MOESI_CMP_directory protocol to be built.")

     cpu_sequencers = []
diff --git a/configs/ruby/MOESI_CMP_token.py b/configs/ruby/MOESI_CMP_token.py
index d23c5ed..6b74e0e 100644
--- a/configs/ruby/MOESI_CMP_token.py
+++ b/configs/ruby/MOESI_CMP_token.py
@@ -28,7 +28,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from .Ruby import create_topology, create_directories
 from .Ruby import send_evicts

@@ -55,7 +55,7 @@
 def create_system(options, full_system, system, dma_ports, bootmem,
                   ruby_system, cpus):

-    if buildEnv['PROTOCOL'] != 'MOESI_CMP_token':
+    if getRubyProtocol() != 'MOESI_CMP_token':
panic("This script requires the MOESI_CMP_token protocol to be built.")

     #
diff --git a/configs/ruby/MOESI_hammer.py b/configs/ruby/MOESI_hammer.py
index 15a6c68..4267208 100644
--- a/configs/ruby/MOESI_hammer.py
+++ b/configs/ruby/MOESI_hammer.py
@@ -28,7 +28,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from .Ruby import create_topology, create_directories
 from .Ruby import send_evicts
 from common import FileSystemConfig
@@ -54,7 +54,7 @@
 def create_system(options, full_system, system, dma_ports, bootmem,
                   ruby_system, cpus):

-    if buildEnv['PROTOCOL'] != 'MOESI_hammer':
+    if getRubyProtocol() != 'MOESI_hammer':
panic("This script requires the MOESI_hammer protocol to be built.")

     cpu_sequencers = []
diff --git a/configs/ruby/Ruby.py b/configs/ruby/Ruby.py
index ba94c15..aa50cff 100644
--- a/configs/ruby/Ruby.py
+++ b/configs/ruby/Ruby.py
@@ -40,7 +40,7 @@
 import math
 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import buildEnv, getRubyProtocol
 from m5.util import addToPath, fatal

 addToPath('../')
@@ -94,7 +94,7 @@
         "--recycle-latency", type=int, default=10,
         help="Recycle latency for ruby controller input buffers")

-    protocol = buildEnv['PROTOCOL']
+    protocol = getRubyProtocol()
     exec("from . import %s" % protocol)
     eval("%s.define_options(parser)" % protocol)
     Network.define_options(parser)
@@ -195,7 +195,7 @@
     if cpus is None:
         cpus = system.cpu

-    protocol = buildEnv['PROTOCOL']
+    protocol = getRubyProtocol()
     exec("from . import %s" % protocol)
     try:
         (cpu_sequencers, dir_cntrls, topology) = \
diff --git a/configs/topologies/CustomMesh.py b/configs/topologies/CustomMesh.py
index 70bf55d..d85d91d 100644
--- a/configs/topologies/CustomMesh.py
+++ b/configs/topologies/CustomMesh.py
@@ -40,8 +40,8 @@
 from m5.params import *
 from m5.objects import *

-from m5.defines import buildEnv
-if buildEnv['PROTOCOL'] == 'CHI':
+from m5.defines import getRubyProtocol
+if getRubyProtocol() == 'CHI':
     import ruby.CHI_config as CHI

 from topologies.BaseTopology import SimpleTopology
@@ -218,7 +218,7 @@
#--------------------------------------------------------------------------

     def makeTopology(self, options, network, IntLink, ExtLink, Router):
-        assert(buildEnv['PROTOCOL'] == 'CHI')
+        assert(getRubyProtocol() == 'CHI')

         num_rows = options.num_rows
         num_cols = options.num_cols
diff --git a/tests/configs/gpu-randomtest-ruby.py b/tests/configs/gpu-randomtest-ruby.py
index ff4071c..4179284 100644
--- a/tests/configs/gpu-randomtest-ruby.py
+++ b/tests/configs/gpu-randomtest-ruby.py
@@ -30,7 +30,7 @@

 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from m5.util import addToPath
 import os, argparse, sys

@@ -76,7 +76,7 @@

# Check to for the GPU_RfO protocol. Other GPU protocols are non-SC and will
 # not work with the Ruby random tester.
-assert(buildEnv['PROTOCOL'] == 'GPU_RfO')
+assert(getRubyProtocol() == 'GPU_RfO')

 #
 # create the tester and system, including ruby
diff --git a/tests/configs/gpu-ruby.py b/tests/configs/gpu-ruby.py
index 391b98d..1e4d25a 100644
--- a/tests/configs/gpu-ruby.py
+++ b/tests/configs/gpu-ruby.py
@@ -30,7 +30,7 @@

 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from m5.util import addToPath
 import os, argparse, sys, math, glob

@@ -187,7 +187,7 @@
 # the acquire/release operation depending on this impl_kern_boundary_sync
 # flag. This flag=true means pipeline initiates a acquire/release operation
 # at kernel boundary.
-if buildEnv['PROTOCOL'] == 'GPU_RfO':
+if getRubyProtocol() == 'GPU_RfO':
     shader.impl_kern_boundary_sync = False
 else:
     shader.impl_kern_boundary_sync = True
diff --git a/tests/configs/rubytest-ruby.py b/tests/configs/rubytest-ruby.py
index b68ff92..d56c090 100644
--- a/tests/configs/rubytest-ruby.py
+++ b/tests/configs/rubytest-ruby.py
@@ -27,7 +27,7 @@

 import m5
 from m5.objects import *
-from m5.defines import buildEnv
+from m5.defines import getRubyProtocol
 from m5.util import addToPath
 import os, argparse, sys

@@ -60,7 +60,7 @@

 # Turn on flush check for the hammer protocol
 check_flush = False
-if buildEnv['PROTOCOL'] == 'MOESI_hammer':
+if getRubyProtocol() == 'MOESI_hammer':
     check_flush = True

 #

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/58449
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: Ic4d010f93a027be03767d5306c2eee6c13ed9511
Gerrit-Change-Number: 58449
Gerrit-PatchSet: 1
Gerrit-Owner: Jason Lowe-Power <power...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to