diff --git a/simulator/SConstruct b/simulator/SConstruct
index 12af06f..3a6ed68 100644
--- a/simulator/SConstruct
+++ b/simulator/SConstruct
@@ -1,14 +1,14 @@
+from __future__ import print_function
import os, sys
from os.path import join as joinpath
useIcc = False
-#useIcc = True
def buildSim(cppFlags, dir, type, pgo=None):
''' Build the simulator with a specific base buid dir and config type'''
buildDir = joinpath(dir, type)
- print "Building " + type + " zsim at " + buildDir
+ print("Building " + type + " zsim at " + buildDir)
env = Environment(ENV = os.environ, tools = ['default', 'textfile'])
env["CPPFLAGS"] = cppFlags
@@ -45,7 +45,7 @@ def buildSim(cppFlags, dir, type, pgo=None):
if "PINPATH" in os.environ:
PINPATH = os.environ["PINPATH"]
else:
- print "ERROR: You need to define the $PINPATH environment variable with Pin's path"
+ print("ERROR: You need to define the $PINPATH environment variable with Pin's path")
sys.exit(1)
ROOT = Dir('.').abspath
@@ -177,19 +177,19 @@ def buildSim(cppFlags, dir, type, pgo=None):
env["CPPFLAGS"] += ' -DHDF5INCPREFIX="hdf5/serial/"'
else:
if conf.CheckLib('hdf5_serial'):
- print "Found hdf5_serial"
+ print("Found hdf5_serial")
else:
- print "Couldn't find hdf5_serial"
-
+ print("Couldn't find hdf5_serial")
+
if conf.CheckLib('hdf5_serial_hl'):
- print "Found hdf5_serial_hl"
+ print("Found hdf5_serial_hl")
else:
- print "Couldn't find hdf5_serial_hl"
-
+ print("Couldn't find hdf5_serial_hl")
+
env["PINLIBS"] += ["hdf5_serial", "hdf5_serial_hl"]
env["CPPFLAGS"] += ' -DHDF5INCPREFIX="hdf5/serial/"'
-
- print "ERROR: You need to install libhdf5 in the system"
+
+ print("ERROR: You need to install libhdf5 in the system")
#sys.exit(1)
# Harness needs these defined
@@ -243,11 +243,11 @@ pgoPhase = GetOption('pgoPhase')
# when you move the files. Check the repo for a version that tries this.
if GetOption('pgoBuild'):
for type in buildTypes:
- print "Building PGO binary"
+ print("Building PGO binary")
root = Dir('.').abspath
testsDir = joinpath(root, "tests")
trainCfgs = [f for f in os.listdir(testsDir) if f.startswith("pgo")]
- print "Using training configs", trainCfgs
+ print("Using training configs", trainCfgs)
baseDir = joinpath(baseBuildDir, "pgo-" + type)
genCmd = "scons -j16 --pgoPhase=generate-" + type
diff --git a/simulator/misc/cpplint.py b/simulator/misc/cpplint.py
index 119cfeb..28121fd 100755
--- a/simulator/misc/cpplint.py
+++ b/simulator/misc/cpplint.py
@@ -88,6 +88,9 @@
import sys
import unicodedata
+if sys.version_info[0] == 3:
+ xrange = range
+
_USAGE = """
Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
@@ -251,7 +254,7 @@
'algo.h', 'builtinbuf.h', 'bvector.h', 'cassert', 'cctype',
'cerrno', 'cfloat', 'ciso646', 'climits', 'clocale', 'cmath',
'complex', 'complex.h', 'csetjmp', 'csignal', 'cstdarg', 'cstddef',
- 'cstdio', 'cstdlib', 'cstring', 'ctime', 'cwchar', 'cwctype',
+ 'cstdio', 'cstdint', 'cstdlib', 'cstring', 'ctime', 'cwchar', 'cwctype',
'defalloc.h', 'deque.h', 'editbuf.h', 'exception', 'fstream',
'fstream.h', 'hashtable.h', 'heap.h', 'indstream.h', 'iomanip',
'iomanip.h', 'ios', 'iosfwd', 'iostream', 'iostream.h', 'istream',
@@ -2775,7 +2778,7 @@ def GetLineWidth(line):
The width of the line in column positions, accounting for Unicode
combining characters and wide characters.
"""
- if isinstance(line, unicode):
+ if sys.version_info[0] == 2 and isinstance(line, unicode):
width = 0
for uc in unicodedata.normalize('NFC', line):
if unicodedata.east_asian_width(uc) in ('W', 'F'):
diff --git a/simulator/misc/ffControl.py b/simulator/misc/ffControl.py
index 65914cd..f640650 100755
--- a/simulator/misc/ffControl.py
+++ b/simulator/misc/ffControl.py
@@ -22,6 +22,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see .
+from __future__ import print_function
import os, sys, subprocess
from optparse import OptionParser
@@ -38,19 +39,19 @@
try:
line = sys.stdin.readline()
except:
- print "stdin done, exiting"
+ print("stdin done, exiting")
break
if line.startswith("[H] Global segment shmid = "):
targetShmid = int(line.split("=")[1].lstrip().rstrip())
- print "Target shmid is", targetShmid
+ print("Target shmid is", targetShmid)
if line.find(opts.lineMatch) >= 0:
if targetShmid >= 0:
- print "Match, calling fftoggle"
+ print("Match, calling fftoggle")
matches += 1
subprocess.call([os.path.join(opts.fftogglePath, "fftoggle"), str(targetShmid), str(opts.procIdx)])
else:
- print "Match but shmid is not valid, not sending signal (are you sure you specified procIdx correctly? it's not the PID)"
-print "Done, %d matches" % matches
+ print("Match but shmid is not valid, not sending signal (are you sure you specified procIdx correctly? it's not the PID)")
+print("Done, %d matches" % matches)
diff --git a/simulator/misc/gitver.py b/simulator/misc/gitver.py
index 6068b7e..ec4336e 100644
--- a/simulator/misc/gitver.py
+++ b/simulator/misc/gitver.py
@@ -1,4 +1,5 @@
# Return a pretty-printed short git version (like hg/svnversion)
+from __future__ import print_function
import os
def cmd(c): return os.popen(c).read().strip()
branch = cmd("git rev-parse --abbrev-ref HEAD")
@@ -11,4 +12,4 @@ def cmd(c): return os.popen(c).read().strip()
.replace(" deletions(-)", "-").replace(" deletion(-)", "-") \
.replace(",", "")
diff = "clean" if len(dfstat) == 0 else shstat + " " + dfhash
-print ":".join([branch, revnum, rshort, diff])
+print(":".join([branch, revnum, rshort, diff]))
diff --git a/simulator/misc/lint_includes.py b/simulator/misc/lint_includes.py
index ad18009..7a54381 100755
--- a/simulator/misc/lint_includes.py
+++ b/simulator/misc/lint_includes.py
@@ -22,7 +22,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see .
-
+from __future__ import print_function
import os, sys
#dryRun = True
@@ -53,7 +53,7 @@ def prefix(l):
f.close()
bName = os.path.basename(src).split(".")[0]
- print bName
+ print(bName)
lines = [l for l in txt.split("\n")]
@@ -70,17 +70,17 @@ def prefix(l):
includeBlocks.append((blockStart, i))
blockStart = -1
- print src, len(includeBlocks), "blocks"
+ print(src, len(includeBlocks), "blocks")
newIncludes = [(s , e, sortIncludes(lines[s:e], bName)) for (s, e) in includeBlocks]
for (s , e, ii) in newIncludes:
# Print?
if ii == lines[s:e]:
- print "Block in lines %d-%d matches" % (s, e-1)
+ print("Block in lines %d-%d matches" % (s, e-1))
continue
for i in range(s, e):
- print "%3d: %s%s | %s" % (i, lines[i], " "*(40 - len(lines[i][:39])), ii[i-s] if i-s < len(ii) else "")
- print ""
+ print("%3d: %s%s | %s" % (i, lines[i], " "*(40 - len(lines[i][:39])), ii[i-s] if i-s < len(ii) else ""))
+ print("")
prevIdx = 0
newLines = []
@@ -95,4 +95,4 @@ def prefix(l):
f.write(outTxt)
f.close()
-print "Done!"
+print("Done!")
diff --git a/simulator/misc/list_syscalls.py b/simulator/misc/list_syscalls.py
index dab0524..1d9bcaf 100755
--- a/simulator/misc/list_syscalls.py
+++ b/simulator/misc/list_syscalls.py
@@ -1,9 +1,10 @@
#!/usr/bin/python
# Produces a list of syscalls in the current system
+from __future__ import print_function
import os, re
syscallCmd = "gcc -E -dD /usr/include/asm/unistd.h | grep __NR"
syscallDefs = os.popen(syscallCmd).read()
sysList = [(int(numStr), name) for (name, numStr) in re.findall("#define __NR_(.*?) (\d+)", syscallDefs)]
denseList = ["INVALID"]*(max([num for (num, name) in sysList]) + 1)
for (num, name) in sysList: denseList[num] = name
-print '"' + '",\n"'.join(denseList) + '"'
+print('"' + '",\n"'.join(denseList) + '"')
diff --git a/simulator/misc/patchRoot/genPatchRoot.py b/simulator/misc/patchRoot/genPatchRoot.py
index d6fccb5..f41faf2 100755
--- a/simulator/misc/patchRoot/genPatchRoot.py
+++ b/simulator/misc/patchRoot/genPatchRoot.py
@@ -22,6 +22,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see .
+from __future__ import print_function
import os, string, sys
class XTemplate(string.Template):
@@ -64,23 +65,23 @@ def getMask(start, end):
root = options.dir
progDir = os.path.dirname(os.path.abspath(__file__)) + "/"
-print "Will produce a tree for %d CPUs/cores in %s" % (ncpus, root)
+print("Will produce a tree for %d CPUs/cores in %s" % (ncpus, root))
if ncpus < 1:
- print "ERROR: Need >= 1 cpus!"
+ print("ERROR: Need >= 1 cpus!")
sys.exit(1)
if os.path.exists(root) and not options.force:
- print "ERROR: Dir already exists, aborting"
+ print("ERROR: Dir already exists, aborting")
sys.exit(1)
if len(args):
- print "ERROR: No positional arguments taken, aborting"
+ print("ERROR: No positional arguments taken, aborting")
sys.exit(1)
cmd("mkdir -p " + root)
if not os.path.exists(root):
- print "ERROR: Could not create %s, aborting" % root
+ print("ERROR: Could not create %s, aborting" % root)
sys.exit(1)
## /proc
@@ -122,7 +123,7 @@ def getMask(start, end):
td = d + "topology/"
cmd("mkdir -p " + td)
if maxCpus > 255:
- print "WARN: These many cpus have not been tested, x2APIC systems may be different..."
+ print("WARN: These many cpus have not been tested, x2APIC systems may be different...")
cmd("echo %d > %s" % (cpu, td + "core_id"))
cmd("echo %s > %s" % (cpuList, td + "core_siblings_list"))
cmd("echo %d > %s" % (cpu, td + "thread_siblings_list"))
diff --git a/simulator/scripts/compile.sh b/simulator/scripts/compile.sh
index 2d6374a..39e91af 100755
--- a/simulator/scripts/compile.sh
+++ b/simulator/scripts/compile.sh
@@ -6,6 +6,7 @@ DRAMSIMPATH="$ZSIMPATH/DRAMSim2"
RAMULATORPATH="$ZSIMPATH/ramulator"
NUMCPUS=$(grep -c ^processor /proc/cpuinfo)
+cd $LIBCONFIGPATH && autoreconf -f -i && cd -
if [ "$1" = "z" ]
then
diff --git a/simulator/scripts/genMeshNetwork.py b/simulator/scripts/genMeshNetwork.py
index f170169..afe280f 100644
--- a/simulator/scripts/genMeshNetwork.py
+++ b/simulator/scripts/genMeshNetwork.py
@@ -1,5 +1,6 @@
#!/usr/bin/python
+from __future__ import print_function
import sys, os;
f = open("network", "w");
@@ -69,10 +70,10 @@
l3 = l3Prefix+str(i);
mem = "mem";
dist = 0; # latency is already measured in cache
- print "Connecting "+l1i+" to "+l2;
+ print("Connecting "+l1i+" to "+l2)
f.write(l1i+" "+l2+" "+"0 0\n");
- print "Connecting "+l1d+" to "+l2;
+ print("Connecting "+l1d+" to "+l2)
f.write(l1d+" "+l2+" "+"0 0\n");
# Calculate min distance from L3 bank to mesh edge
@@ -83,7 +84,7 @@
for mc in memControllers:
dist = abs(l3x - mc[0])+abs(l3y - mc[1]);
for c in range(channelsPerController):
- print "Connecting "+l3+" to mem-"+str(channel)+", dist "+str(dist);
+ print("Connecting "+l3+" to mem-"+str(channel)+", dist "+str(dist))
f.write(l3+" mem-"+str(channel)+" 1 "+str(l3x)+" "+str(l3y)+" "+str(mc[0])+" "+str(mc[1])+"\n");
channel = channel + 1;
@@ -96,12 +97,12 @@
l3y = cores[j][1];
dist = abs(l2x - l3x)+abs(l2y-l3y);
lat = dist*(linkLat+routerLat);
- print "Connecting "+l2+" ("+str(l2x)+", "+str(l2y)+") to "+l3+" ("+str(l3x)+", "+str(l3y)+") = "+str(dist)+", "+str(lat)+" cycles";
+ print("Connecting "+l2+" ("+str(l2x)+", "+str(l2y)+") to "+l3+" ("+str(l3x)+", "+str(l3y)+") = "+str(dist)+", "+str(lat)+" cycles")
if((added.count(l2+l3) == 0) and (added.count(l3+l2) == 0)):
added.append(l2+l3);
added.append(l3+l2);
f.write(l2+" "+l3+" 1 "+str(l2x)+" "+str(l2y)+" "+str(l3x)+" "+str(l3y)+"\n");
else:
- print "ERROR";
+ print("ERROR")
sys.exit();
diff --git a/simulator/scripts/genMeshNetworkOriginal.py b/simulator/scripts/genMeshNetworkOriginal.py
index 5bfb11f..568dd82 100644
--- a/simulator/scripts/genMeshNetworkOriginal.py
+++ b/simulator/scripts/genMeshNetworkOriginal.py
@@ -1,5 +1,6 @@
#!/usr/bin/python
+from __future__ import print_function
import sys, os;
f = open("network", "w");
@@ -66,10 +67,10 @@
l3 = l3Prefix+str(i);
mem = "mem";
dist = 0; # latency is already measured in cache
- print "Connecting "+l1i+" to "+l2;
+ print("Connecting "+l1i+" to "+l2)
f.write(l1i+" "+l2+" "+"0 0\n");
- print "Connecting "+l1d+" to "+l2;
+ print("Connecting "+l1d+" to "+l2)
f.write(l1d+" "+l2+" "+"0 0\n");
# Calculate min distance from L3 bank to mesh edge
@@ -80,7 +81,7 @@
for mc in memControllers:
dist = abs(l3x - mc[0])+abs(l3y - mc[1]);
for c in range(channelsPerController):
- print "Connecting "+l3+" to mem-"+str(channel)+", dist "+str(dist);
+ print("Connecting "+l3+" to mem-"+str(channel)+", dist "+str(dist))
f.write(l3+" mem-"+str(channel)+" 1 "+str(l3x)+" "+str(l3y)+" "+str(mc[0])+" "+str(mc[1])+"\n");
channel = channel + 1;
@@ -93,12 +94,12 @@
l3y = cores[j][1];
dist = abs(l2x - l3x)+abs(l2y-l3y);
lat = dist*(linkLat+routerLat);
- print "Connecting "+l2+" ("+str(l2x)+", "+str(l2y)+") to "+l3+" ("+str(l3x)+", "+str(l3y)+") = "+str(dist)+", "+str(lat)+" cycles";
+ print("Connecting "+l2+" ("+str(l2x)+", "+str(l2y)+") to "+l3+" ("+str(l3x)+", "+str(l3y)+") = "+str(dist)+", "+str(lat)+" cycles")
if((added.count(l2+l3) == 0) and (added.count(l3+l2) == 0)):
added.append(l2+l3);
added.append(l3+l2);
f.write(l2+" "+l3+" 1 "+str(l2x)+" "+str(l2y)+" "+str(l3x)+" "+str(l3y)+"\n");
else:
- print "ERROR";
+ print("ERROR")
sys.exit();
diff --git a/simulator/scripts/generate_config_files.py b/simulator/scripts/generate_config_files.py
index f15b1b0..0f5e7f7 100755
--- a/simulator/scripts/generate_config_files.py
+++ b/simulator/scripts/generate_config_files.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import sys
import os
import errno
@@ -87,8 +88,8 @@ def create_pim_configs(benchmark, application, function, command, version):
if(len(sys.argv) < 2):
- print "Usage python generate_config_files.py command_file"
- print "command_file: benckmark,applicationm,function,command"
+ print("Usage python generate_config_files.py command_file")
+ print("command_file: benckmark,applicationm,function,command")
exit(1)
with open(sys.argv[1], "r") as command_file:
@@ -98,7 +99,7 @@ def create_pim_configs(benchmark, application, function, command, version):
application = line[1]
function = line[2]
command = line[3]
- print line
+ print(line)
command = command.replace('\n','')
### Fixed LLC Size
diff --git a/simulator/scripts/get_stats_per_app.py b/simulator/scripts/get_stats_per_app.py
index 3e5ef65..4a3243c 100644
--- a/simulator/scripts/get_stats_per_app.py
+++ b/simulator/scripts/get_stats_per_app.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import os
import csv
import sys
@@ -100,7 +101,7 @@
if(line.find("# GETS misses")!=-1 or line.find("# GETX I->M misses")!=-1):
l3_misses += int(line.split()[1])
except:
- print "Couldn't read some stat"
+ print("Couldn't read some stat")
# ====================== CPU Metrics ======================
if(len(cycles_list)!=0):
diff --git a/simulator/scripts/setup.sh b/simulator/scripts/setup.sh
index 76c0fae..d7ca311 100755
--- a/simulator/scripts/setup.sh
+++ b/simulator/scripts/setup.sh
@@ -14,3 +14,12 @@ apt-get -y install libhdf5-dev
apt-get -y install libelf-dev
ln -s /usr/include/asm-generic /usr/include/asm
+
+if ! which lrztar > /dev/null; then
+ echo "Installing the lrztar tool ..."
+ apt-get -y install tar git zlib1g-dev libbz2-dev liblzo2-dev liblz4-dev coreutils nasm libtool
+ cd ~ && git clone -v https://github.com/ckolivas/lrzip.git && cd -
+ cd ~/lrzip && ./autogen.sh && ./configure && make -j `nproc` && make install && cd -
+else
+ echo "lrztar is already installed."
+fi
diff --git a/simulator/src/locality.h b/simulator/src/locality.h
index c52f7a9..093e9b2 100755
--- a/simulator/src/locality.h
+++ b/simulator/src/locality.h
@@ -4,6 +4,7 @@
#include