Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions simulator/SConstruct
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions simulator/misc/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,...]
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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'):
Expand Down
11 changes: 6 additions & 5 deletions simulator/misc/ffControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function
import os, sys, subprocess
from optparse import OptionParser

Expand All @@ -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)

3 changes: 2 additions & 1 deletion simulator/misc/gitver.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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]))
14 changes: 7 additions & 7 deletions simulator/misc/lint_includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.


from __future__ import print_function
import os, sys

#dryRun = True
Expand Down Expand Up @@ -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")]

Expand All @@ -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 = []
Expand All @@ -95,4 +95,4 @@ def prefix(l):
f.write(outTxt)
f.close()

print "Done!"
print("Done!")
3 changes: 2 additions & 1 deletion simulator/misc/list_syscalls.py
Original file line number Diff line number Diff line change
@@ -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) + '"')
13 changes: 7 additions & 6 deletions simulator/misc/patchRoot/genPatchRoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function
import os, string, sys

class XTemplate(string.Template):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"))
Expand Down
1 change: 1 addition & 0 deletions simulator/scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions simulator/scripts/genMeshNetwork.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/python

from __future__ import print_function
import sys, os;

f = open("network", "w");
Expand Down Expand Up @@ -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
Expand All @@ -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;

Expand All @@ -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();
11 changes: 6 additions & 5 deletions simulator/scripts/genMeshNetworkOriginal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/python

from __future__ import print_function
import sys, os;

f = open("network", "w");
Expand Down Expand Up @@ -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
Expand All @@ -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;

Expand All @@ -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();
7 changes: 4 additions & 3 deletions simulator/scripts/generate_config_files.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import sys
import os
import errno
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion simulator/scripts/get_stats_per_app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import os
import csv
import sys
Expand Down Expand Up @@ -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):
Expand Down
9 changes: 9 additions & 0 deletions simulator/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading