From 46e0ec221496469920fbabb91efd447f74da702f Mon Sep 17 00:00:00 2001 From: christindbose Date: Wed, 10 May 2023 14:15:37 -0400 Subject: Ported aerialvision to use python3 instead of python2 --- aerialvision/__pycache__/configs.cpython-310.pyc | Bin 0 -> 1444 bytes .../__pycache__/guiclasses.cpython-310.pyc | Bin 0 -> 69744 bytes aerialvision/__pycache__/lexyacc.cpython-310.pyc | Bin 0 -> 6623 bytes .../__pycache__/lexyaccbookmark.cpython-310.pyc | Bin 0 -> 2712 bytes .../__pycache__/lexyacctexteditor.cpython-310.pyc | Bin 0 -> 2825 bytes .../__pycache__/organizedata.cpython-310.pyc | Bin 0 -> 6305 bytes aerialvision/__pycache__/parsetab.cpython-310.pyc | Bin 0 -> 870 bytes aerialvision/__pycache__/startup.cpython-310.pyc | Bin 0 -> 24043 bytes .../__pycache__/variableclasses.cpython-310.pyc | Bin 0 -> 4892 bytes aerialvision/configs.py | 11 +-- aerialvision/guiclasses.py | 85 +++++++++++---------- aerialvision/lexyacc.py | 31 ++++---- aerialvision/lexyaccbookmark.py | 9 ++- aerialvision/lexyacctexteditor.py | 11 +-- aerialvision/organizedata.py | 35 ++++----- aerialvision/parser.out | 47 ++++++++++++ aerialvision/parsetab.py | 31 ++++++++ aerialvision/startup.py | 18 +++-- aerialvision/variableclasses.py | 16 ++-- 19 files changed, 193 insertions(+), 101 deletions(-) create mode 100644 aerialvision/__pycache__/configs.cpython-310.pyc create mode 100644 aerialvision/__pycache__/guiclasses.cpython-310.pyc create mode 100644 aerialvision/__pycache__/lexyacc.cpython-310.pyc create mode 100644 aerialvision/__pycache__/lexyaccbookmark.cpython-310.pyc create mode 100644 aerialvision/__pycache__/lexyacctexteditor.cpython-310.pyc create mode 100644 aerialvision/__pycache__/organizedata.cpython-310.pyc create mode 100644 aerialvision/__pycache__/parsetab.cpython-310.pyc create mode 100644 aerialvision/__pycache__/startup.cpython-310.pyc create mode 100644 aerialvision/__pycache__/variableclasses.cpython-310.pyc create mode 100644 aerialvision/parser.out create mode 100644 aerialvision/parsetab.py (limited to 'aerialvision') diff --git a/aerialvision/__pycache__/configs.cpython-310.pyc b/aerialvision/__pycache__/configs.cpython-310.pyc new file mode 100644 index 0000000..577be95 Binary files /dev/null and b/aerialvision/__pycache__/configs.cpython-310.pyc differ diff --git a/aerialvision/__pycache__/guiclasses.cpython-310.pyc b/aerialvision/__pycache__/guiclasses.cpython-310.pyc new file mode 100644 index 0000000..aaf967c Binary files /dev/null and b/aerialvision/__pycache__/guiclasses.cpython-310.pyc differ diff --git a/aerialvision/__pycache__/lexyacc.cpython-310.pyc b/aerialvision/__pycache__/lexyacc.cpython-310.pyc new file mode 100644 index 0000000..7ec78ee Binary files /dev/null and b/aerialvision/__pycache__/lexyacc.cpython-310.pyc differ diff --git a/aerialvision/__pycache__/lexyaccbookmark.cpython-310.pyc b/aerialvision/__pycache__/lexyaccbookmark.cpython-310.pyc new file mode 100644 index 0000000..689c13c Binary files /dev/null and b/aerialvision/__pycache__/lexyaccbookmark.cpython-310.pyc differ diff --git a/aerialvision/__pycache__/lexyacctexteditor.cpython-310.pyc b/aerialvision/__pycache__/lexyacctexteditor.cpython-310.pyc new file mode 100644 index 0000000..2ff3a80 Binary files /dev/null and b/aerialvision/__pycache__/lexyacctexteditor.cpython-310.pyc differ diff --git a/aerialvision/__pycache__/organizedata.cpython-310.pyc b/aerialvision/__pycache__/organizedata.cpython-310.pyc new file mode 100644 index 0000000..4c4e1c8 Binary files /dev/null and b/aerialvision/__pycache__/organizedata.cpython-310.pyc differ diff --git a/aerialvision/__pycache__/parsetab.cpython-310.pyc b/aerialvision/__pycache__/parsetab.cpython-310.pyc new file mode 100644 index 0000000..1cea68f Binary files /dev/null and b/aerialvision/__pycache__/parsetab.cpython-310.pyc differ diff --git a/aerialvision/__pycache__/startup.cpython-310.pyc b/aerialvision/__pycache__/startup.cpython-310.pyc new file mode 100644 index 0000000..4a6cd5f Binary files /dev/null and b/aerialvision/__pycache__/startup.cpython-310.pyc differ diff --git a/aerialvision/__pycache__/variableclasses.cpython-310.pyc b/aerialvision/__pycache__/variableclasses.cpython-310.pyc new file mode 100644 index 0000000..4b34893 Binary files /dev/null and b/aerialvision/__pycache__/variableclasses.cpython-310.pyc differ diff --git a/aerialvision/configs.py b/aerialvision/configs.py index f0389ac..01dba2e 100644 --- a/aerialvision/configs.py +++ b/aerialvision/configs.py @@ -61,7 +61,7 @@ # Vancouver, BC V6T 1Z4 -import ConfigParser, os +import configparser, os userSettingPath = os.path.join(os.environ['HOME'], '.gpgpu_sim', 'aerialvision') @@ -69,14 +69,14 @@ userSettingPath = os.path.join(os.environ['HOME'], '.gpgpu_sim', 'aerialvision') class AerialVisionConfig: def __init__(self): - self.config = ConfigParser.SafeConfigParser() + self.config = configparser.SafeConfigParser() self.config.read( os.path.join(userSettingPath, 'config.rc') ) def print_all(self): for section in self.config.sections(): for option in self.config.options(section): value = self.config.get(section, option) - print "\t%s.%s = %s" % (section, option, value); + print("\t%s.%s = %s" % (section, option, value)); def get_value(self, section, option, default): if (self.config.has_option(section, option)): @@ -90,10 +90,11 @@ avconfig = AerialVisionConfig() #Unit test / configviewer def main(): - print "AerialVision Options:" + print("AerialVision Options:") avconfig.print_all() - print ""; + print(""); if __name__ == "__main__": main() + diff --git a/aerialvision/guiclasses.py b/aerialvision/guiclasses.py index 04036a8..f4ecd29 100644 --- a/aerialvision/guiclasses.py +++ b/aerialvision/guiclasses.py @@ -64,10 +64,10 @@ import time import os import array -import Tkinter as Tk +import tkinter as Tk import matplotlib matplotlib.use('TkAgg') -from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg +from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk from matplotlib.figure import Figure import matplotlib as mpl from matplotlib.colors import colorConverter @@ -250,19 +250,19 @@ class formEntry: self.cXAxisData.delete(0, Tk.END) self.cYAxisData.delete(0, Tk.END) - + #filling in xAxis vars - for keys in self.data[self.fileChosen].keys(): + for keys in list(self.data[self.fileChosen].keys()): if keys == 'globalCycle': self.cXAxisData.insert(Tk.END, keys) #filling in yAxis vars #Need to fill up list alphabetically keysAlpha = [] - for key in self.data[self.fileChosen].keys(): + for key in list(self.data[self.fileChosen].keys()): if key not in ['globalCycle','CFLOG','EXTVARS']:#exclude hacks from list keysAlpha.append(key) - keysAlpha.sort(lambda x, y: cmp(x.lower(),y.lower())) + #keysAlpha.sort(key=lambda x, y: cmp(x.lower(),y.lower())) for keys in keysAlpha: self.cYAxisData.insert(Tk.END, keys) @@ -782,7 +782,7 @@ class graphManager: #self.plot = self.figure.add_subplot(111) self.canvas = FigureCanvasTkAgg(self.figure, master=self.graphArea) self.canvas.get_tk_widget().pack() - self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.toolbarArea) + self.toolbar = NavigationToolbar2Tk(self.canvas, self.toolbarArea) self.toolbar.update() self.plotData() @@ -931,7 +931,7 @@ class graphManager: - if self.simplerName.has_key('globalTotInsn') == 'False': + if ('globalTotInsn' in self.simplerName) == 'False': graphOption = 1 if (graphOption == 1): @@ -972,7 +972,7 @@ class graphManager: graphOption = "NULL" - if self.simplerName.has_key('globalTotInsn') == 'False': + if ('globalTotInsn' in self.simplerName) == 'False': graphOption = 1 if (graphOption == 1): @@ -1018,7 +1018,7 @@ class graphManager: #if there are kernals.. we need to adjust the x axis for proper labelling #Need to make changes here.. works for now though - if self.simplerName.has_key('globalTotInsn'): + if 'globalTotInsn' in self.simplerName: x = self.updateVarKernal(x) concentrationFactor = len(x) // 512 + 1 @@ -1038,7 +1038,7 @@ class graphManager: yoff = numpy.array([0.0] * numCols) #variable use to remember the last top location of a bar so that we may stack the proceeding bar on top of it #Legendname = ['UNUSED', 'UNUSED', 'FQPUSHED','ICNT_PUSHED','ICNT_INJECTED','ICNT_AT_DEST','DRAMQ','DRAM_PROCESSING_START','DRAM_PROCESSING_END','DRAM_OUTQ','2SH_ICNT_PUSHED','2SH_ICNT_INJECTED','2SH_ICNT_AT_DEST','2SH_FQ_POP','RETURN_Q']; Legendname = ['N/A', 'N/A','N/A','IcntInpBuf','N/A','Icnt2DRAM','N/A','N/A','N/A','DRAM','2Sh_IcntInpBuf','N/A','Icnt2shd','N/A','N/A']; - BarSequence = range(numRows-1,-1,-1) + BarSequence = list(range(numRows-1,-1,-1)) if yAxis == 'WarpDivergenceBreakdown': Legendname = [] @@ -1046,21 +1046,21 @@ class graphManager: Legendname.append('Data Hazard') Legendname.append('Stall') for c in range(2, numRows): - Legendname.append('W' + `4*(c-2)+1` + ':' + `4*(c-1)`) - BarSequence = range(0,numRows) + Legendname.append('W' + repr(4*(c-2)+1) + ':' + repr(4*(c-1))) + BarSequence = list(range(0,numRows)) if yAxis == 'WarpIssueSlotBreakdown': Legendname = [] for c in range(0, numRows): - Legendname.append('W' + `c`) - BarSequence = range(0,numRows) + Legendname.append('W' + repr(c)) + BarSequence = list(range(0,numRows)) dynamic_warp_resolution = 32 if yAxis == 'WarpIssueDynamicIdBreakdown': Legendname = [] for c in range(0, numRows): - Legendname.append('W' + `dynamic_warp_resolution*c` + ":" + `dynamic_warp_resolution*(c+1)`) - BarSequence = range(0,numRows) + Legendname.append('W' + repr(dynamic_warp_resolution*c) + ":" + repr(dynamic_warp_resolution*(c+1))) + BarSequence = list(range(0,numRows)) yoff_max = numpy.array([0.0] * numCols) for row in range(numRows-1,-1,-1): @@ -1102,10 +1102,10 @@ class graphManager: for label in self.plot.get_yticklabels(): label.set_fontsize(plotFormat.yticksFontSize) - self.canvas.show() + self.canvas.draw() def type4Variable(self, x, xAxis, y, yAxis, plotID): - keys = y.keys() + keys = list(y.keys()) keys.sort() if (self.dataPointer.graphChosen == self.possGraphs[3]): @@ -1251,7 +1251,7 @@ class graphManager: self.plot.set_title(self.plotFormatInfo[self.currPlot].title) self.plot.set_xlabel(self.plotFormatInfo[self.currPlot].xlabel, fontsize = self.plotFormatInfo[self.currPlot].labelFontSize) self.plot.set_ylabel(self.plotFormatInfo[self.currPlot].ylabel, fontsize = self.plotFormatInfo[self.currPlot].labelFontSize) - self.canvas.show() + self.canvas.draw() def plotMultVarLine(self, x, xAxis, y, yAxis): @@ -1261,7 +1261,7 @@ class graphManager: self.plotFormatInfo[self.currPlot].InitLabels(xlabel = xAxis, ylabel = yAxis, cbarlabel = '', title = '') self.plot.set_xlabel(self.plotFormatInfo[self.currPlot].xlabel, fontsize = self.plotFormatInfo[self.currPlot].labelFontSize) self.plot.set_ylabel(self.plotFormatInfo[self.currPlot].ylabel, fontsize = self.plotFormatInfo[self.currPlot].labelFontSize) - self.canvas.show() + self.canvas.draw() def plotScatter(self, x, xAxis, y, yAxis, plotID): @@ -1275,7 +1275,7 @@ class graphManager: self.plot.set_title(plotFormat.title, fontsize = plotFormat.labelFontSize) self.plot.set_xlabel(plotFormat.xlabel, fontsize = plotFormat.labelFontSize) self.plot.set_ylabel(plotFormat.ylabel, fontsize = plotFormat.labelFontSize) - self.canvas.show() + self.canvas.draw() def takeDerivativeMult(self,x,y): @@ -1347,12 +1347,12 @@ class graphManager: # put number on axis if there are more than one ticks if (self.xAxisStepsWilStack[self.currPlot] != 1): - for count in range(0,len(x),len(x)/self.xAxisStepsWilStack[self.currPlot]): + for count in range(0,len(x),int(len(x)/self.xAxisStepsWilStack[self.currPlot])): xlabelValues.append(x[count]) xlabelPos.append(xticksPos[count]) - print self.yAxisStepsWilStack[self.currPlot] - for count in range(0,len(y),len(y)/self.yAxisStepsWilStack[self.currPlot]): + print(self.yAxisStepsWilStack[self.currPlot]) + for count in range(0,len(y),int(len(y)/self.yAxisStepsWilStack[self.currPlot])): ylabelValues.append(yTicks[count]) ylabelPos.append(yticksPos[count]) @@ -1387,7 +1387,7 @@ class graphManager: xtickStep = x[1] - x[0] self.plot.set_xlim(0 / xtickStep - 0.5, self.xlim / xtickStep + 0.5) - self.canvas.show() + self.canvas.draw() def updateWilTicks(self, z): x= [] @@ -1480,7 +1480,7 @@ class graphManager: else: for iter in range(0, self.dataPointer.dydx): if self.simplerName[self.dataPointer.dataChosenY].type == 4: - keys = self.simplerName[self.dataPointer.dataChosenY].data.keys() + keys = list(self.simplerName[self.dataPointer.dataChosenY].data.keys()) keys.sort() y = [] for iter in keys: @@ -1523,7 +1523,7 @@ class graphManager: entry[self.currPlot] = (maxEntry, minEntry) cmap = self.plotFormatInfo[self.currPlot].cmap - plotCMap = apply(Tk.OptionMenu, (root[-1], cmap) + tuple(PlotFormatInfo.cmapOptions)) + plotCMap = Tk.OptionMenu(*(root[-1], cmap) + tuple(PlotFormatInfo.cmapOptions)) plotCMap.pack(side = Tk.LEFT, padx = 5) @@ -1612,7 +1612,7 @@ class graphManager: for self.currPlot in range(1,numPlots + 1): self.findKernalLocs() - if vars.has_key(str(self.currPlot)): + if str(self.currPlot) in vars: if vars[str(self.currPlot)].get() == 1: self.dataPointer.dydx += 1 @@ -1681,12 +1681,12 @@ class graphManager: if (self.yAxisStepsWilStack[plotToIncrease] == 1): self.yAxisStepsWilStack[plotToIncrease] = 2 self.yAxisStepsWilStack[plotToIncrease] = int(float(self.yAxisStepsWilStack[plotToIncrease])*1.50) - print self.yAxisStepsWilStack[plotToIncrease] + print(self.yAxisStepsWilStack[plotToIncrease]) self.plotDataForNewBinning(plotToIncrease) def collectDataDecreaseYBinning(self, currPlot, remove = False): plotToDecrease = int(currPlot[0]) - print self.yAxisStepsWilStack[plotToDecrease] + print(self.yAxisStepsWilStack[plotToDecrease]) if (remove == True): self.yAxisStepsWilStack[plotToDecrease] = 1 else: @@ -1751,7 +1751,7 @@ class graphManager: entries[self.currPlot].append(Tk.Entry(root, width = 50)) entries[self.currPlot][-1].grid(row = currentRow, column = 4, padx = 10) entries[self.currPlot][-1].insert(0, self.plot.get_xlabel()) - if self.colorbars.has_key(self.currPlot): + if self.currPlot in self.colorbars: plotLabel3 = Tk.Label(root, text = 'Colorbar: ', bg = 'white') plotLabel3.grid(row = currentRow, column = 5) entries[self.currPlot].append(Tk.Entry(root, width = 20)) @@ -1821,7 +1821,7 @@ class graphManager: self.plot.set_ylabel(plotFormat.ylabel, fontsize=plotFormat.labelFontSize) plotFormat.xlabel = entries[self.currPlot][1].get() self.plot.set_xlabel(plotFormat.xlabel, fontsize=plotFormat.labelFontSize) - if self.colorbars.has_key(self.currPlot): + if self.currPlot in self.colorbars: plotFormat.cbarlabel = entries[self.currPlot][2].get() self.colorbars[self.currPlot].set_label(plotFormat.cbarlabel, fontsize=plotFormat.labelFontSize) else: @@ -1841,7 +1841,7 @@ class graphManager: ytickslabels[n].set_fontsize(plotFormat.yticksFontSize) # change colorbar ticks label fontsize - if self.colorbars.has_key(self.currPlot): + if self.currPlot in self.colorbars: for label in self.colorbars[self.currPlot].ax.get_yticklabels(): label.set_fontsize(plotFormat.cticksFontSize) @@ -1851,7 +1851,7 @@ class graphManager: master.destroy() ## Now replot with changes..... - self.canvas.show() + self.canvas.draw() def zoomButton(self): #Variable initializations @@ -1980,7 +1980,7 @@ class graphManager: plot.set_xticks(xlabelPos) master.destroy() - self.canvas.show() + self.canvas.draw() class NaviPlotInfo: @@ -2224,6 +2224,7 @@ class newTextTab: countLines = 1 for lines in self.file.readlines(): + lines = lines.decode() self.textbox.insert(Tk.END, str(countLines) + '. ' + lines, ('normal')) countLines += 1 countLines -= 1 @@ -2232,7 +2233,7 @@ class newTextTab: figure = Figure(figsize=(22,5), dpi = 70) self.histArea = FigureCanvasTkAgg(figure, master= bottomFrame) self.histArea.get_tk_widget().pack() - toolbar = NavigationToolbar2TkAgg(self.histArea, toolbarFrame) + toolbar = NavigationToolbar2Tk(self.histArea, toolbarFrame) toolbar.update() self.histogram = figure.add_subplot(111) cid = figure.canvas.mpl_connect('button_press_event',self.onclick) @@ -2285,8 +2286,8 @@ class newTextTab: count += 1 def yview(self, *args): - apply(self.textbox.yview, args) - apply(self.statstextbox.yview, args) + self.textbox.yview(*args) + self.statstextbox.yview(*args) def onclick(self, event): if event.button == 3: @@ -2298,6 +2299,7 @@ class newTextTab: self.textbox.delete(0.0, Tk.END) self.file = open(self.fileChosen, 'r') for lines in self.file.readlines(): + lines=lines.decode() if (countLines < event.xdata - 1) or (countLines > event.xdata + 1): self.textbox.insert(Tk.END, str(countLines) + '. ' + lines, ('normal')) else: @@ -2317,8 +2319,8 @@ class newTextTab: - apply(self.textbox.yview, args) - apply(self.statstextbox.yview, args) + self.textbox.yview(*args) + self.statstextbox.yview(*args) def chooseFileCuda(self, *event): self.fileChosen = self.cAvailableCudaFiles.get('active') @@ -2572,3 +2574,4 @@ class newTextTab: + diff --git a/aerialvision/lexyacc.py b/aerialvision/lexyacc.py index d657383..53541ed 100644 --- a/aerialvision/lexyacc.py +++ b/aerialvision/lexyacc.py @@ -82,7 +82,7 @@ def import_user_defined_variables(variables): try: file = open(os.path.join(userSettingPath, 'variables.txt'),'r') except: - print "No variables.txt file found." + print("No variables.txt file found.") return #this can be replaced with a proper lex-yacc parser later @@ -96,7 +96,7 @@ def import_user_defined_variables(variables): continue # parse the line containing definition of a stat variable - s = line.split(",") + s = line.split(',') statName = s[0] statVar = vc.variable('', 1, 0) statVar.importFromString(line) @@ -104,8 +104,9 @@ def import_user_defined_variables(variables): # add parsed stat variable to the searchable map variables[statName] = statVar - except Exception, (e): - print "error:",e,", in variables.txt line:",line + except Exception as xxx_todo_changeme: + (e) = xxx_todo_changeme + print("error:",e,", in variables.txt line:",line) # Parses through a given log file for data def parseMe(filename): @@ -136,7 +137,7 @@ def parseMe(filename): t.lexer.lineno += t.value.count("\n") def t_error(t): - print "Illegal character '%s'" % t.value[0] + print("Illegal character '%s'" % t.value[0]) t.lexer.skip(1) lex.lex() @@ -202,14 +203,14 @@ def parseMe(filename): # generate a lookup table based on the specified name in log file for each stat stat_lookuptable = {} - for name, var in variables.iteritems(): + for name, var in variables.items(): if (name == 'CFLOG'): continue; if (var.lookup_tag != ''): stat_lookuptable[var.lookup_tag] = var else: stat_lookuptable[name.lower()] = var - + inputData = 'NULL' # a table containing all the metrics that has received the missing data warning @@ -218,19 +219,19 @@ def parseMe(filename): def p_sentence(p): '''sentence : WORD NUMBERSEQUENCE''' #print p[0], p[1],p[2] - num = p[2].split(" ") + num = p[2].split(' ') # detect empty data entry for particular metric and print a warning if p[2] == '': if not p[1] in stat_missing_warned: - print "WARNING: Sample entry for metric '%s' has no data. Skipping..." % p[1] + print("WARNING: Sample entry for metric '%s' has no data. Skipping..." % p[1]) stat_missing_warned[p[1]] = True return lookup_input = p[1].lower() if (lookup_input in stat_lookuptable): if (lookup_input == "globalcyclecount") and (int(num[0]) % 10000 == 0): - print "Processing global cycle %s" % num[0] + print("Processing global cycle %s" % num[0]) stat = stat_lookuptable[lookup_input] if (stat.type == 1): @@ -294,7 +295,7 @@ def parseMe(filename): def p_error(p): if p: - print("Syntax error at '%s'" % p.value) + print(("Syntax error at '%s'" % p.value)) else: print("Syntax error at EOF") @@ -306,11 +307,12 @@ def parseMe(filename): else: file = open(filename, 'r') while file: - line = file.readline() + line = file.readline().decode() + if not line : break - nameNdata = line.split(":") + nameNdata = line.split(':') if (len(nameNdata) != 2): - print("Syntax error at '%s'" % line) + print(("Syntax error at '%s'" % line)) namePart = nameNdata[0].strip() dataPart= nameNdata[1].strip() parts = [' ', namePart, dataPart] @@ -323,3 +325,4 @@ def parseMe(filename): + diff --git a/aerialvision/lexyaccbookmark.py b/aerialvision/lexyaccbookmark.py index 42c6b40..7aa2f80 100644 --- a/aerialvision/lexyaccbookmark.py +++ b/aerialvision/lexyaccbookmark.py @@ -108,7 +108,7 @@ def parseMe(): def t_error(t): - print "Illegal character '%s'" % t.value[0] + print("Illegal character '%s'" % t.value[0]) t.lexer.skip(1) lex.lex() @@ -150,7 +150,7 @@ def parseMe(): pass else: - print 'An Parsing Error has occurred' + print('An Parsing Error has occurred') @@ -159,7 +159,7 @@ def parseMe(): def p_error(p): if p: - print("Syntax error at '%s'" % p.value) + print(("Syntax error at '%s'" % p.value)) else: print("Syntax error at EOF") @@ -168,7 +168,7 @@ def parseMe(): try: file = open(os.environ['HOME'] + '/.gpgpu_sim/aerialvision/bookmarks.txt', 'r') inputData = file.readlines() - except IOError,e: + except IOError as e: if e.errno == 2: inputData = '' else: @@ -178,3 +178,4 @@ def parseMe(): yacc.parse(x[0:-1]) # ,debug=True) return listBookmarks + diff --git a/aerialvision/lexyacctexteditor.py b/aerialvision/lexyacctexteditor.py index 51d3ced..57b41db 100644 --- a/aerialvision/lexyacctexteditor.py +++ b/aerialvision/lexyacctexteditor.py @@ -88,7 +88,7 @@ def textEditorParseMe(filename): t.lexer.lineno += t.value.count("\n") def t_error(t): - print "Illegal character '%s'" % t.value[0] + print("Illegal character '%s'" % t.value[0]) t.lexer.skip(1) lex.lex() @@ -109,8 +109,8 @@ def textEditorParseMe(filename): def p_error(p): if p: - print("Syntax error at '%s'" % p.value) - print p + print(("Syntax error at '%s'" % p.value)) + print(p) else: print("Syntax error at EOF") @@ -152,17 +152,18 @@ def ptxToCudaMapping(filename): loc = int(m.group(2)) count += 1 - x = map.keys() + x = list(map.keys()) return map #Unit test / playground def main(): data = textEditorParseMe(sys.argv[1]) - print data[100] + print(data[100]) if __name__ == "__main__": main() + diff --git a/aerialvision/organizedata.py b/aerialvision/organizedata.py index 090b90f..f5d5312 100644 --- a/aerialvision/organizedata.py +++ b/aerialvision/organizedata.py @@ -99,7 +99,7 @@ def organizedata(fileVars): } data_type_char = {int:'I', float:'f'} - print "Organizing data into internal format..." + print("Organizing data into internal format...") # Organize globalCycle in advance because it is used as a reference if ('globalCycle' in fileVars): @@ -107,28 +107,28 @@ def organizedata(fileVars): fileVars['globalCycle'].data = organizeFunction[statData.organize](statData.data, data_type_char[statData.datatype]) # Organize other stat data into internal format - for statName, statData in fileVars.iteritems(): + for statName, statData in fileVars.items(): if (statName != 'CFLOG' and statName != 'globalCycle' and statData.organize != 'custom'): fileVars[statName].data = organizeFunction[statData.organize](statData.data, data_type_char[statData.datatype]) # Custom routines to organize stat data into internal format - if fileVars.has_key('averagemflatency'): + if 'averagemflatency' in fileVars: zeros = [] for count in range(len(fileVars['averagemflatency'].data),len(fileVars['globalCycle'].data)): zeros.append(0) fileVars['averagemflatency'].data = zeros + fileVars['averagemflatency'].data - if (skipCFLog == 0) and fileVars.has_key('CFLOG'): + if (skipCFLog == 0) and 'CFLOG' in fileVars: ptxFile = CFLOGptxFile statFile = CFLOGInsnInfoFile - print "PC Histogram to CUDA Src = %d" % convertCFLog2CUDAsrc + print("PC Histogram to CUDA Src = %d" % convertCFLog2CUDAsrc) parseCFLOGCUDA = convertCFLog2CUDAsrc if parseCFLOGCUDA == 1: - print "Obtaining PTX-to-CUDA Mapping from %s..." % ptxFile + print("Obtaining PTX-to-CUDA Mapping from %s..." % ptxFile) map = lexyacctexteditor.ptxToCudaMapping(ptxFile.rstrip()) - print "Obtaining Program Range from %s..." % statFile + print("Obtaining Program Range from %s..." % statFile) maxStats = max(lexyacctexteditor.textEditorParseMe(statFile.rstrip()).keys()) if parseCFLOGCUDA == 1: @@ -136,7 +136,7 @@ def organizedata(fileVars): for lines in map: for ptxLines in map[lines]: newMap[ptxLines] = lines - print " Total number of CUDA src lines = %s..." % len(newMap) + print(" Total number of CUDA src lines = %s..." % len(newMap)) markForDel = [] for ptxLines in newMap: @@ -144,7 +144,7 @@ def organizedata(fileVars): markForDel.append(ptxLines) for lines in markForDel: del newMap[lines] - print " Number of touched CUDA src lines = %s..." % len(newMap) + print(" Number of touched CUDA src lines = %s..." % len(newMap)) fileVars['CFLOGglobalPTX'] = vc.variable('',2,0) fileVars['CFLOGglobalCUDA'] = vc.variable('',2,0) @@ -152,7 +152,7 @@ def organizedata(fileVars): count = 0 for iter in fileVars['CFLOG']: - print "Organizing data for %s" % iter + print("Organizing data for %s" % iter) fileVars[iter + 'PTX'] = fileVars['CFLOG'][iter] fileVars[iter + 'PTX'].data = CFLOGOrganizePTX(fileVars['CFLOG'][iter].data, fileVars['CFLOG'][iter].maxPC) @@ -174,7 +174,7 @@ def organizedata(fileVars): for columns in range(0, len(fileVars[iter + 'CUDA'].data[rows])): fileVars['CFLOGglobalCUDA'].data[rows][columns] += fileVars[iter + 'CUDA'].data[rows][columns] except: - print "Error in generating globalCFLog data" + print("Error in generating globalCFLog data") count += 1 del fileVars['CFLOG'] @@ -231,10 +231,10 @@ def nullOrganizedStackedBar(nullVar, datatype_c): for row in range (0,len(organized)): newy = array.array(datatype_c, [0 for col in range(newLen)]) for col in range(0, len(organized[row])): - newcol = col / n_data + newcol = int(col / n_data) newy[newcol] += organized[row][col] for col in range(0, len(newy)): - newy[col] /= n_data + newy[col] = int(newy[col]/n_data) organized[row] = newy return organized @@ -320,15 +320,15 @@ def CFLOGOrganizeCuda(list, ptx2cudamap): nSamples = len(list[0]) # create a dictionary of empty data array (one array per cuda source line) - for ptxline, cudaline in ptx2cudamap.iteritems(): - if tmp.has_key(cudaline): + for ptxline, cudaline in ptx2cudamap.items(): + if cudaline in tmp: pass else: tmp[cudaline] = [0 for lengthData in range(nSamples)] for cudaline in tmp: - for ptxLines, mapped_cudaline in ptx2cudamap.iteritems(): + for ptxLines, mapped_cudaline in ptx2cudamap.items(): if mapped_cudaline == cudaline: for lengthData in range(nSamples): tmp[cudaline][lengthData] += list[ptxLines][lengthData] @@ -336,7 +336,7 @@ def CFLOGOrganizeCuda(list, ptx2cudamap): final = [] for iter in range(min(tmp.keys()),max(tmp.keys())): - if tmp.has_key(iter): + if iter in tmp: final.append(tmp[iter]) else: final.append([0 for lengthData in range(nSamples)]) @@ -356,3 +356,4 @@ def CFLOGOrganizeCuda(list, ptx2cudamap): # return organized + diff --git a/aerialvision/parser.out b/aerialvision/parser.out new file mode 100644 index 0000000..809874f --- /dev/null +++ b/aerialvision/parser.out @@ -0,0 +1,47 @@ +Created by PLY version 3.11 (http://www.dabeaz.com/ply) + +Grammar + +Rule 0 S' -> sentence +Rule 1 sentence -> WORD NUMBERSEQUENCE + +Terminals, with rules where they appear + +NUMBERSEQUENCE : 1 +WORD : 1 +error : + +Nonterminals, with rules where they appear + +sentence : 0 + +Parsing method: LALR + +state 0 + + (0) S' -> . sentence + (1) sentence -> . WORD NUMBERSEQUENCE + + WORD shift and go to state 2 + + sentence shift and go to state 1 + +state 1 + + (0) S' -> sentence . + + + +state 2 + + (1) sentence -> WORD . NUMBERSEQUENCE + + NUMBERSEQUENCE shift and go to state 3 + + +state 3 + + (1) sentence -> WORD NUMBERSEQUENCE . + + $end reduce using rule 1 (sentence -> WORD NUMBERSEQUENCE .) + diff --git a/aerialvision/parsetab.py b/aerialvision/parsetab.py new file mode 100644 index 0000000..47a3884 --- /dev/null +++ b/aerialvision/parsetab.py @@ -0,0 +1,31 @@ + +# parsetab.py +# This file is automatically generated. Do not edit. +# pylint: disable=W,C,R +_tabversion = '3.10' + +_lr_method = 'LALR' + +_lr_signature = 'NUMBERSEQUENCE WORDsentence : WORD NUMBERSEQUENCE' + +_lr_action_items = {'WORD':([0,],[2,]),'$end':([1,3,],[0,-1,]),'NUMBERSEQUENCE':([2,],[3,]),} + +_lr_action = {} +for _k, _v in _lr_action_items.items(): + for _x,_y in zip(_v[0],_v[1]): + if not _x in _lr_action: _lr_action[_x] = {} + _lr_action[_x][_k] = _y +del _lr_action_items + +_lr_goto_items = {'sentence':([0,],[1,]),} + +_lr_goto = {} +for _k, _v in _lr_goto_items.items(): + for _x, _y in zip(_v[0], _v[1]): + if not _x in _lr_goto: _lr_goto[_x] = {} + _lr_goto[_x][_k] = _y +del _lr_goto_items +_lr_productions = [ + ("S' -> sentence","S'",1,None,None,None), + ('sentence -> WORD NUMBERSEQUENCE','sentence',2,'p_sentence','lexyacc.py',220), +] diff --git a/aerialvision/startup.py b/aerialvision/startup.py index ae14fd3..d261c0c 100644 --- a/aerialvision/startup.py +++ b/aerialvision/startup.py @@ -62,11 +62,11 @@ import sys -import Tkinter as Tk +import tkinter as Tk import Pmw import lexyacc import guiclasses -import tkFileDialog as Fd +import tkinter.filedialog as Fd import organizedata import os import os.path @@ -160,7 +160,7 @@ def fileInput(cl_files=None): tmprecentfile = tmprecentfile.split('/') for iter in range(1,len(tmprecentfile) - 1): recentfile = recentfile + '/' + tmprecentfile[iter] - except IOError,e: + except IOError as e: if e.errno == 2: # recentfiles.txt does not exist, ignore and use CWD recentfile = '.' @@ -313,7 +313,7 @@ def loadRecentFile(entry): try: loadfile = open(os.path.join(userSettingPath, 'recentfiles.txt'), 'r') recentfiles = loadfile.readlines() - except IOError,e: + except IOError as e: if e.errno == 2: recentfiles = '' else: @@ -323,7 +323,7 @@ def loadRecentFile(entry): recentFileWindow.pack(side = Tk.TOP) scrollbar = Tk.Scrollbar(recentFileWindow, orient = Tk.VERTICAL) cRecentFile = Tk.Listbox(recentFileWindow, width = 100, height = 15, yscrollcommand = scrollbar.set) - cRecentFile.bind("", lambda(event): recentFileInsert(entry, cRecentFile.get('active'), instance)) + cRecentFile.bind("", lambda event: recentFileInsert(entry, cRecentFile.get('active'), instance)) cRecentFile.pack(side = Tk.LEFT) scrollbar.config(command = cRecentFile.yview) scrollbar.pack(side = Tk.LEFT, fill = Tk.Y) @@ -391,9 +391,9 @@ def addListToListbox(listbox,list): Filenames.append(string) listbox.insert(Tk.END, string) else: - print 'Could not open file: ' + string + print('Could not open file: ' + string) except: - print 'Could not open file: ' + file + print('Could not open file: ' + file) def errorMsg(string): @@ -447,6 +447,7 @@ def submitClicked(instance, num, skipcflog, cflog2cuda, listboxes): startup(res, [TEFiles, TEPTXFiles, TEStatFiles]) def graphAddTab(vars, graphTabs,res, entry): + TabsForGraphs.append(guiclasses.formEntry(graphTabs, str(len(TabsForGraphs) + 1), vars, res, entry)) entry.delete(0, Tk.END) @@ -586,7 +587,7 @@ def startup(res, TEFILES): organizedata.setCFLOGInfoFiles(TEFILES) for files in Filenames: vars[files] = organizedata.organizedata(vars[files]) - + graphAddTab(vars, graphTabs, res, eAddTab) @@ -873,3 +874,4 @@ def manageFilesSubmit(window, listbox): + diff --git a/aerialvision/variableclasses.py b/aerialvision/variableclasses.py index 18850a1..30d8d2d 100644 --- a/aerialvision/variableclasses.py +++ b/aerialvision/variableclasses.py @@ -102,8 +102,9 @@ class variable: assert(self.organize == 'idx2DVec') elif (self.type == 5): assert(self.organize == 'sparse') - except Exception, (e): - print "Error in creating new stat variable from string: %s" % string_spec + except Exception as xxx_todo_changeme: + (e) = xxx_todo_changeme + print("Error in creating new stat variable from string: %s" % string_spec) raise e def initSparseMatrix(self): @@ -133,7 +134,7 @@ def loadLineStatName(filename): global lineStatName file = open(filename, 'r') while file: - line = file.readline() + line = file.readline().decode() if not line : break if (line.startswith('kernel line :')) : line = line.strip() @@ -171,7 +172,7 @@ class cudaLineNo: except: tmp = 0 if cudaLineNo.debug: - print 'Exception in cudaLineNo.takeMax()', self.stats[key] + print('Exception in cudaLineNo.takeMax()', self.stats[key]) return tmp def takeRatioSums(self, key1,key2): @@ -182,9 +183,9 @@ class cudaLineNo: return tmp1/tmp2 except: if cudaLineNo.debug: - print tmp1, tmp2 + print(tmp1, tmp2) if tmp2 == 0 and cudaLineNo.debug: - print 'infinite' + print('infinite') return 0 @@ -209,7 +210,7 @@ class ptxLineNo: return tmp1/tmp2 except: if tmp2 == 0 and ptxLineNo.debug: - print 'infinite' + print('infinite') return 0 @@ -221,3 +222,4 @@ class ptxLineNo: + -- cgit v1.3