resources: Upgrade gem5 configs of npb-tests to python3
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Change-Id: Ibcb1dcc5e4c2a91a7239f75fc5fe579b2457ab3b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5-resources/+/30774
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: Bobby R. Bruce <bbruce@ucdavis.edu>
diff --git a/src/npb/configs/system/MESI_Two_Level.py b/src/npb/configs/system/MESI_Two_Level.py
index 39af672..82d0bb8 100755
--- a/src/npb/configs/system/MESI_Two_Level.py
+++ b/src/npb/configs/system/MESI_Two_Level.py
@@ -34,8 +34,8 @@
"""
-from __future__ import print_function
-from __future__ import absolute_import
+
+
import math
diff --git a/src/npb/configs/system/MI_example_caches.py b/src/npb/configs/system/MI_example_caches.py
index 309ad89..9558f58 100755
--- a/src/npb/configs/system/MI_example_caches.py
+++ b/src/npb/configs/system/MI_example_caches.py
@@ -38,8 +38,8 @@
"""
-from __future__ import print_function
-from __future__ import absolute_import
+
+
import math
diff --git a/src/npb/configs/system/__init__.py b/src/npb/configs/system/__init__.py
index 3b71680..94e676f 100755
--- a/src/npb/configs/system/__init__.py
+++ b/src/npb/configs/system/__init__.py
@@ -27,5 +27,5 @@
#
# Authors: Jason Lowe-Power
-from system import MySystem
-from ruby_system import MyRubySystem
+from .system import MySystem
+from .ruby_system import MyRubySystem
diff --git a/src/npb/configs/system/ruby_system.py b/src/npb/configs/system/ruby_system.py
index 37be01e..98feef1 100755
--- a/src/npb/configs/system/ruby_system.py
+++ b/src/npb/configs/system/ruby_system.py
@@ -30,7 +30,7 @@
import m5
from m5.objects import *
from m5.util import convert
-from fs_tools import *
+from .fs_tools import *
class MyRubySystem(System):
@@ -72,13 +72,13 @@
# Create the cache hierarchy for the system.
if mem_sys == 'MI_example':
- from MI_example_caches import MIExampleSystem
+ from .MI_example_caches import MIExampleSystem
self.caches = MIExampleSystem()
elif mem_sys == 'MESI_Two_Level':
- from MESI_Two_Level import MESITwoLevelCache
+ from .MESI_Two_Level import MESITwoLevelCache
self.caches = MESITwoLevelCache()
elif mem_sys == 'MOESI_CMP_directory':
- from MOESI_CMP_directory import MOESICMPDirCache
+ from .MOESI_CMP_directory import MOESICMPDirCache
self.caches = MOESICMPDirCache()
self.caches.setup(self, self.cpu, self.mem_cntrls,
[self.pc.south_bridge.ide.dma, self.iobus.master],
@@ -102,6 +102,10 @@
def totalInsts(self):
return sum([cpu.totalInsts() for cpu in self.cpu])
+ def createCPUThreads(self, cpu):
+ for c in cpu:
+ c.createThreads()
+
def createCPU(self, num_cpus):
# Note KVM needs a VM and atomic_noncaching
@@ -109,21 +113,21 @@
for i in range(num_cpus)]
self.kvm_vm = KvmVM()
self.mem_mode = 'atomic_noncaching'
- map(lambda c: c.createThreads(), self.cpu)
+ self.createCPUThreads(self.cpu)
self.atomicCpu = [AtomicSimpleCPU(cpu_id = i,
switched_out = True)
for i in range(num_cpus)]
- map(lambda c: c.createThreads(), self.atomicCpu)
+ self.createCPUThreads(self.atomicCpu)
self.timingCpu = [TimingSimpleCPU(cpu_id = i,
switched_out = True)
for i in range(num_cpus)]
- map(lambda c: c.createThreads(), self.timingCpu)
+ self.createCPUThreads(self.timingCpu)
def switchCpus(self, old, new):
assert(new[0].switchedOut())
- m5.switchCpus(self, zip(old, new))
+ m5.switchCpus(self, list(zip(old, new)))
def setDiskImages(self, img_path_1, img_path_2):
disk0 = CowDisk(img_path_1)
diff --git a/src/npb/configs/system/system.py b/src/npb/configs/system/system.py
index 4b154df..ff1fa5e 100755
--- a/src/npb/configs/system/system.py
+++ b/src/npb/configs/system/system.py
@@ -30,8 +30,8 @@
import m5
from m5.objects import *
from m5.util import convert
-from fs_tools import *
-from caches import *
+from .fs_tools import *
+from .caches import *
class MySystem(System):
@@ -79,7 +79,7 @@
self.setDiskImages(disk, disk)
- if opts.second_disk:
+ if opts.second_disk:
self.setDiskImages(disk, opts.second_disk)
else:
self.setDiskImages(disk, disk)
@@ -123,35 +123,39 @@
def totalInsts(self):
return sum([cpu.totalInsts() for cpu in self.cpu])
+ def createCPUThreads(self, cpu):
+ for c in cpu:
+ c.createThreads()
+
def createCPU(self, num_cpus):
if self._no_kvm:
self.cpu = [AtomicSimpleCPU(cpu_id = i, switched_out = False)
for i in range(num_cpus)]
- map(lambda c: c.createThreads(), self.cpu)
+ self.createCPUThreads(self.cpu)
self.mem_mode = 'timing'
else:
# Note KVM needs a VM and atomic_noncaching
self.cpu = [X86KvmCPU(cpu_id = i)
for i in range(num_cpus)]
- map(lambda c: c.createThreads(), self.cpu)
+ self.createCPUThreads(self.cpu)
self.kvm_vm = KvmVM()
self.mem_mode = 'atomic_noncaching'
self.atomicCpu = [AtomicSimpleCPU(cpu_id = i,
switched_out = True)
for i in range(num_cpus)]
- map(lambda c: c.createThreads(), self.atomicCpu)
+ self.createCPUThreads(self.atomicCpu)
self.timingCpu = [TimingSimpleCPU(cpu_id = i,
switched_out = True)
- for i in range(num_cpus)]
+ for i in range(num_cpus)]
- map(lambda c: c.createThreads(), self.timingCpu)
+ self.createCPUThreads(self.timingCpu)
def switchCpus(self, old, new):
assert(new[0].switchedOut())
- m5.switchCpus(self, zip(old, new))
+ m5.switchCpus(self, list(zip(old, new)))
def setDiskImages(self, img_path_1, img_path_2):
disk0 = CowDisk(img_path_1)