resources: Upgrade scripts of gapbs to python3

Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Change-Id: I3260037ceb513b6d376c8c70402cc8719e94f34d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5-resources/+/30854
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/gapbs/configs/system/MESI_Two_Level.py b/src/gapbs/configs/system/MESI_Two_Level.py
index bb07456..102ec57 100644
--- a/src/gapbs/configs/system/MESI_Two_Level.py
+++ b/src/gapbs/configs/system/MESI_Two_Level.py
@@ -32,8 +32,8 @@
 This system support the memory size of up to 3GB.
 """
 
-from __future__ import print_function
-from __future__ import absolute_import
+
+
 
 import math
 
diff --git a/src/gapbs/configs/system/MI_example_caches.py b/src/gapbs/configs/system/MI_example_caches.py
index 2a7e975..c588e0d 100644
--- a/src/gapbs/configs/system/MI_example_caches.py
+++ b/src/gapbs/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/gapbs/configs/system/__init__.py b/src/gapbs/configs/system/__init__.py
index 3b71680..94e676f 100755
--- a/src/gapbs/configs/system/__init__.py
+++ b/src/gapbs/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/gapbs/configs/system/ruby_system.py b/src/gapbs/configs/system/ruby_system.py
index b661ace..b642d97 100755
--- a/src/gapbs/configs/system/ruby_system.py
+++ b/src/gapbs/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):
 
@@ -71,10 +71,10 @@
         # 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()
 
         self.caches.setup(self, self.cpu, self.mem_cntrls,
@@ -95,6 +95,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, cpu_type, num_cpus):
         self.cpu = [X86KvmCPU(cpu_id = i)
                         for i in range(num_cpus)]
@@ -104,28 +108,29 @@
             self.timingCpu = [AtomicSimpleCPU(cpu_id = i,
                                         switched_out = True)
                               for i in range(num_cpus)]
-            map(lambda c: c.createThreads(), self.timingCpu)
+            self.createCPUThreads(self.timingCpu)
         elif cpu_type == "o3":
             self.timingCpu = [DerivO3CPU(cpu_id = i,
                                         switched_out = True)
                         for i in range(num_cpus)]
-            map(lambda c: c.createThreads(), self.timingCpu)
+            self.createCPUThreads(self.timingCpu)
         elif cpu_type == "simple":
             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)
         elif cpu_type == "kvm":
             pass
         else:
             m5.fatal("No CPU type {}".format(cpu_type))
 
-        map(lambda c: c.createThreads(), self.cpu)
-        map(lambda c: c.createInterruptController(), self.cpu)
+        self.createCPUThreads(self.cpu)
+        for cpu in self.cpu:
+            cpu.createInterruptController()
 
     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/gapbs/configs/system/system.py b/src/gapbs/configs/system/system.py
index 3843b5a..ba87399 100755
--- a/src/gapbs/configs/system/system.py
+++ b/src/gapbs/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):
 
@@ -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, cpu_type, num_cpus):
         self.cpu = [X86KvmCPU(cpu_id = i)
                         for i in range(num_cpus)]
@@ -111,28 +115,29 @@
             self.timingCpu = [AtomicSimpleCPU(cpu_id = i,
                                         switched_out = True)
                               for i in range(num_cpus)]
-            map(lambda c: c.createThreads(), self.timingCpu)
+            self.createCPUThreads(self.timingCpu)
         elif cpu_type == "o3":
             self.timingCpu = [DerivO3CPU(cpu_id = i,
                                         switched_out = True)
                         for i in range(num_cpus)]
-            map(lambda c: c.createThreads(), self.timingCpu)
+            self.createCPUThreads(self.timingCpu)
         elif cpu_type == "simple":
             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)
         elif cpu_type == "kvm":
             pass
         else:
             m5.fatal("No CPU type {}".format(cpu_type))
 
-        map(lambda c: c.createThreads(), self.cpu)
-        map(lambda c: c.createInterruptController(), self.cpu)
+        self.createCPUThreads(self.cpu)
+        for cpu in self.cpu:
+            cpu.createInterruptController()
 
     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)