diff options
Diffstat (limited to 'aerialvision')
| -rw-r--r-- | aerialvision/README | 2 | ||||
| -rw-r--r-- | aerialvision/configs.py | 99 | ||||
| -rw-r--r-- | aerialvision/guiclasses.py | 2543 | ||||
| -rwxr-xr-x | aerialvision/installscript.py | 113 | ||||
| -rw-r--r-- | aerialvision/lexyacc.py | 307 | ||||
| -rw-r--r-- | aerialvision/lexyaccbookmark.py | 180 | ||||
| -rw-r--r-- | aerialvision/lexyacctexteditor.py | 171 | ||||
| -rw-r--r-- | aerialvision/organizedata.py | 331 | ||||
| -rw-r--r-- | aerialvision/startup.py | 875 | ||||
| -rw-r--r-- | aerialvision/variableclasses.py | 213 |
10 files changed, 4834 insertions, 0 deletions
diff --git a/aerialvision/README b/aerialvision/README new file mode 100644 index 0000000..f19a85a --- /dev/null +++ b/aerialvision/README @@ -0,0 +1,2 @@ +See the file AerialVision-Manual.pdf in the doc directory for +installation and usage instructions. diff --git a/aerialvision/configs.py b/aerialvision/configs.py new file mode 100644 index 0000000..f0389ac --- /dev/null +++ b/aerialvision/configs.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python + +# Copyright (C) 2009 by Wilson W. L. Fung +# and the University of British Columbia, Vancouver, +# BC V6T 1Z4, All Rights Reserved. +# +# THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE +# TERMS AND CONDITIONS. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h +# are derived from the CUDA Toolset available from http://www.nvidia.com/cuda +# (property of NVIDIA). The files benchmarks/BlackScholes/ and +# benchmarks/template/ are derived from the CUDA SDK available from +# http://www.nvidia.com/cuda (also property of NVIDIA). The files from +# src/intersim/ are derived from Booksim (a simulator provided with the +# textbook "Principles and Practices of Interconnection Networks" available +# from http://cva.stanford.edu/books/ppin/). As such, those files are bound by +# the corresponding legal terms and conditions set forth separately (original +# copyright notices are left in files from these sources and where we have +# modified a file our copyright notice appears before the original copyright +# notice). +# +# Using this version of GPGPU-Sim requires a complete installation of CUDA +# which is distributed seperately by NVIDIA under separate terms and +# conditions. To use this version of GPGPU-Sim with OpenCL requires a +# recent version of NVIDIA's drivers which support OpenCL. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the University of British Columbia nor the names of +# its contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# 4. This version of GPGPU-SIM is distributed freely for non-commercial use only. +# +# 5. No nonprofit user may place any restrictions on the use of this software, +# including as modified by the user, by any other authorized user. +# +# 6. GPGPU-SIM was developed primarily by Tor M. Aamodt, Wilson W. L. Fung, +# Ali Bakhoda, George L. Yuan, at the University of British Columbia, +# Vancouver, BC V6T 1Z4 + + +import ConfigParser, os + +userSettingPath = os.path.join(os.environ['HOME'], '.gpgpu_sim', 'aerialvision') + +# Globally available configuration options for AerialVision +class AerialVisionConfig: + + def __init__(self): + 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); + + def get_value(self, section, option, default): + if (self.config.has_option(section, option)): + return self.config.get(section, option) + else: + return default + +# This is the object containing all the options +avconfig = AerialVisionConfig() + + +#Unit test / configviewer +def main(): + print "AerialVision Options:" + avconfig.print_all() + print ""; + +if __name__ == "__main__": + main() + diff --git a/aerialvision/guiclasses.py b/aerialvision/guiclasses.py new file mode 100644 index 0000000..aef7e51 --- /dev/null +++ b/aerialvision/guiclasses.py @@ -0,0 +1,2543 @@ +#!/usr/bin/env python + +# Copyright (C) 2009 by Aaron Ariel, Wilson W. L. Fung, Tor M. Aamodt, Andrew +# Turner and the University of British Columbia, Vancouver, +# BC V6T 1Z4, All Rights Reserved. +# +# THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE +# TERMS AND CONDITIONS. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h +# are derived from the CUDA Toolset available from http://www.nvidia.com/cuda +# (property of NVIDIA). The files benchmarks/BlackScholes/ and +# benchmarks/template/ are derived from the CUDA SDK available from +# http://www.nvidia.com/cuda (also property of NVIDIA). The files from +# src/intersim/ are derived from Booksim (a simulator provided with the +# textbook "Principles and Practices of Interconnection Networks" available +# from http://cva.stanford.edu/books/ppin/). As such, those files are bound by +# the corresponding legal terms and conditions set forth separately (original +# copyright notices are left in files from these sources and where we have +# modified a file our copyright notice appears before the original copyright +# notice). +# +# Using this version of GPGPU-Sim requires a complete installation of CUDA +# which is distributed seperately by NVIDIA under separate terms and +# conditions. To use this version of GPGPU-Sim with OpenCL requires a +# recent version of NVIDIA's drivers which support OpenCL. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the University of British Columbia nor the names of +# its contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# 4. This version of GPGPU-SIM is distributed freely for non-commercial use only. +# +# 5. No nonprofit user may place any restrictions on the use of this software, +# including as modified by the user, by any other authorized user. +# +# 6. GPGPU-SIM was developed primarily by Tor M. Aamodt, Wilson W. L. Fung, +# Ali Bakhoda, George L. Yuan, at the University of British Columbia, +# Vancouver, BC V6T 1Z4 + + +import time +import os +import Tkinter as Tk +import matplotlib +matplotlib.use('TkAgg') +from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg +from matplotlib.figure import Figure +from matplotlib import mpl +from matplotlib.colors import colorConverter +import Pmw +import numpy +import startup +import lexyaccbookmark +import copy +import lexyacc +import organizedata +import lexyacctexteditor +import variableclasses +from configs import avconfig + +class formEntry: + + #This class is essentially a form placed inside a tab. It collects all the data from the user required for graphing. It then instantiates a new object that takes care of all the graphing + + + def __init__(self, graphTabs, numb, vars, res, entry): + + #Variable Initializations + self.data = vars + self.subBool = 0 + self.possGraphs = ['Line', 'Histogram', 'Bar Chart', 'Parallel Intensity Plot', 'Stacked Bar Chart', 'Parallel Intensity Plot (Sum)'] + self.res = res + self.subplots = [] + self.dataChosenX = "globalCycle" + self.dataChosenY = "" + self.dydx = 0 + self.fileChosen = "" + self.graphChosen = '' + self.num = 0 + + #Setting a title to this tab + if entry.get() == "TabTitle?": + self.tabnum = "Page " + numb + else: + self.tabnum = entry.get() + self.page = graphTabs.add(self.tabnum) + + + #Size of the self.background depending on how large the user screen is + if res == "small": + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 700, width = 1200); + self.formArea = Tk.Frame(self.background, bg = "white") + elif res == 'medium': + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 943, width = 1530); + self.formArea = Tk.Frame(self.background, bg = "white") + else: + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 943, width = 1530); + self.formArea = Tk.Frame(self.background, bg = "white") + chosenVars = Tk.Frame(self.background, bg = 'white') + self.background.pack() + # self.background.pack_propagate(0) + self.formArea.pack(side = Tk.LEFT, anchor = Tk.N) + chosenVars.pack(side = Tk.LEFT, anchor = Tk.N, padx = 15) + + + # Frame and listboxes for choosing what file you want to use data from + whichFileFrame = Tk.Frame(self.formArea, bg= 'white') + whichFileFrame.pack(side = Tk.TOP, anchor = Tk.W, pady = 5) + lwhichFileFrame = Tk.Label(whichFileFrame, text = 'Choose a File:', font = ("Gills Sans MT", 12), bg = "white") + lwhichFileFrame.pack(side = Tk.LEFT) + self.cWhichFile= Tk.Listbox(whichFileFrame, width = 85, height = 4) + self.cWhichFile.pack(side =Tk.LEFT) + self.cWhichFile.bind("<Double-Button-1>", self.chooseFile) + + #Placing the available filenames in the self.cWhichFileFrame Listbox + for files in sorted(self.data): + self.cWhichFile.insert(Tk.END, files) + + # move to end of lines to actually see the filenames + self.cWhichFile.xview_moveto(1) + + #Favourites Button + self.bFavourites = Tk.Button(whichFileFrame, text = "Favourites", state = Tk.DISABLED, command = self.chooseFavourite ) + self.bFavourites.pack(side = Tk.LEFT, padx = 5) + + + #Frame for choosing what data you are going to plot + chooseDataFrame = Tk.Frame(self.formArea, bg = "white") + chooseDataFrame.pack(side = Tk.TOP, anchor = Tk.W) + lchooseDataFrame = Tk.Label(chooseDataFrame, text= 'Data to be Plotted:', font = ("Gills Sans MT", 12), bg = "white") + lchooseDataFrame.pack(side= Tk.LEFT); + bQchooseDataFrameHelp = Tk.Button(chooseDataFrame, text = " ? -->", command = (lambda: self.helpMsg('Double-Click on the metric to select it for plotting.'))) + bQchooseDataFrameHelp.pack(side =Tk.LEFT, padx = 5) + XListbox = Tk.Frame(chooseDataFrame, bg= 'white') + XListbox.pack(side = Tk.LEFT) + XTitle = Tk.Label(XListbox, text = "X Vars", bg= 'white') + XTitle.pack(side = Tk.TOP) + self.cXAxisData = Tk.Listbox(XListbox, width = 19, height = 5, selectmode = Tk.MULTIPLE) + self.cXAxisData.bind("<Double-Button-1>", self.chooseDataX) + YListbox = Tk.Frame(chooseDataFrame, bg = 'white') + YListbox.pack(side = Tk.LEFT) + YFrameForScrollbar = Tk.Frame(YListbox, bg= 'white') + YFrameForScrollbar.pack(side = Tk.BOTTOM) + scrollYAxisData = Tk.Scrollbar(YFrameForScrollbar, orient = Tk.VERTICAL) + YTitle = Tk.Label(YListbox, text = 'Y Vars', bg= 'white') + YTitle.pack(side = Tk.TOP) + self.cYAxisData = Tk.Listbox(YFrameForScrollbar,width = 19, height = 5, yscrollcommand=scrollYAxisData.set) + self.cYAxisData.bind("<Double-Button-1>", self.chooseDataY) + scrollYAxisData.config(command=self.cYAxisData.yview) + self.cXAxisData.pack(side = Tk.BOTTOM) + self.cYAxisData.pack(side = Tk.LEFT) + scrollYAxisData.pack(side=Tk.LEFT, fill = 'y') + + # The Take Derivative Checkbutton + self.var0 = Tk.IntVar() + checkbDyDx = Tk.Checkbutton(chooseDataFrame, text= "dy/dx", variable= self.var0, bg = 'white', command = (lambda: self.checkDyDx())) + checkbDyDx.pack(side= Tk.LEFT, padx = 5) + + #Frame for choosing what type of graph + typeGraph = Tk.Frame(self.formArea, bg = "white") + typeGraph.pack(side = Tk.TOP, anchor = Tk.W, pady = 10) + lTypeGraph = Tk.Label(typeGraph, text= 'Type of Graph:', font = ("Gills Sans MT", 12), bg = "white") + lTypeGraph.pack(side= Tk.LEFT); + bQTypeGraphHelp = Tk.Button(typeGraph, text = " ? -->", command = (lambda: self.helpMsg('Double-Click on the graph type to select it.'))) + bQTypeGraphHelp.pack(side =Tk.LEFT, padx = 5) + self.cTypeGraph = Tk.Listbox(typeGraph, width = 50, height = 3) + self.cTypeGraph.bind("<Double-Button-1>", self.chooseGraph) + self.cTypeGraph.pack(side = Tk.LEFT) + + subplotWindow = Tk.Frame(self.formArea, bg = "white") + subplotWindow.pack(side = Tk.TOP, anchor = Tk.W) + lSubplot = Tk.Label(subplotWindow, bg = "white", text = "Add Subplot:", font = ("Gills Sans MT", 12)) + lSubplot.pack(side =Tk.LEFT, anchor = Tk.N) + lnumSubplot = Tk.Label(subplotWindow, bg= 'white', text= "# Subplots -") + lnumSubplot.pack(side = Tk.LEFT, anchor = Tk.S) + subplotSlider = Tk.Scale(subplotWindow, from_=1, to=5, orient = Tk.HORIZONTAL, bg= 'white') + subplotSlider.pack(side = Tk.LEFT, anchor = Tk.N) + bSubplotSlider = Tk.Button(subplotWindow, text = "Submit", command = lambda: (self.addSubplot(subplotSlider.get()))) + bSubplotSlider.pack(side = Tk.LEFT) + bcancelSubplot = Tk.Button(subplotWindow, text= "Cancel", command = lambda: self.removeSubplotWindow()) + bcancelSubplot.pack(side = Tk.LEFT) + + #Button for graphing + graphButton = Tk.Frame(chosenVars, bg = "white") + graphButton.pack(side = Tk.TOP, fill = Tk.X) + bGraphButton = Tk.Button(graphButton,borderwidth = 5, bg = 'green', text = "GraphMe!",font = ("Gills Sans MT", 14), command = (lambda: self.setupPlotData())) + bGraphButton.pack(side = Tk.RIGHT, pady = 5) + + #Frame that will have the textbox that lists everything the user has chosen to do + ChosenVarsTitle = Tk.Label(chosenVars, text = 'Options Chosen', font = ("Gills Sans MT", 12), bg = "white") + ChosenVarsTitle.pack(side = Tk.TOP) + innerChosenVarsFrame = Tk.Frame(chosenVars, bg= 'white') + innerChosenVarsFrame.pack(side = Tk.TOP, pady = 10, fill = Tk.Y) + ChosenVarsTextboxScrollbar = Tk.Scrollbar(innerChosenVarsFrame, orient = Tk.VERTICAL) + ChosenVarsTextboxScrollbar.pack(side = Tk.RIGHT, fill = Tk.Y) + self.ChosenVarsTextbox = Tk.Text(innerChosenVarsFrame, height = 41, width = 45, yscrollcommand = ChosenVarsTextboxScrollbar.set) + self.ChosenVarsTextbox.pack(fill = Tk.Y) + ChosenVarsTextboxScrollbar.config(command = self.ChosenVarsTextbox.yview) + + + #Setting up subplot stuff + self.subplotWindow = Tk.Frame(self.formArea, bg='green', height = 300, width = 700) + self.subplotWindow.pack(side = Tk.TOP, pady = 10) + self.subplotWindow.pack_propagate(0) + self.subplotTabs = Pmw.NoteBook(self.subplotWindow) + self.subplotTabs.pack(fill='both',expand = 'True') + tmpInnerSubplotWindow = self.subplotTabs.add('No Subplots Chosen Yet') + tmpInnerSubplotWindow.pack() + tmpInnerSubplotWindow1 = Tk.Frame(tmpInnerSubplotWindow, bg = 'white', height = 300, width = 300) + tmpInnerSubplotWindow1.pack(fill = 'both') + tmpInnerSubplotWindow1.pack_propagate(0) + tmpInnerSubplotWindow1Title = Tk.Label(tmpInnerSubplotWindow1, text = 'You have not chosen to have any subplots', bg= 'white') + tmpInnerSubplotWindow1Title.pack() + + self.updateChosen() + + + def chooseFile(self, *event): + try: + self.bFavourites.config( state = Tk.NORMAL ) + except: + pass + self.fileChosen = self.cWhichFile.get('active') + #Initialize both 'cXAxisData' and 'self.cYAxisData' to empty listboxes + self.cXAxisData.delete(0, Tk.END) + self.cYAxisData.delete(0, Tk.END) + + + #filling in xAxis vars + for keys in 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(): + if key not in ['globalCycle','CFLOG','EXTVARS']:#exclude hacks from list + keysAlpha.append(key) + keysAlpha.sort(lambda x, y: cmp(x.lower(),y.lower())) + for keys in keysAlpha: + self.cYAxisData.insert(Tk.END, keys) + + self.updateChosen() + + + def chooseDataX(self, *event): + self.dataChosenX = self.cXAxisData.get('active') + self.cTypeGraph.delete(0,Tk.END) + + + if ((self.dataChosenX != "") and (self.dataChosenY != "")): + if self.data[self.fileChosen][self.dataChosenY].type == 1 or self.data[self.fileChosen][self.dataChosenY].type == 2 or self.data[self.fileChosen][self.dataChosenY].type == 4: + self.cTypeGraph.insert(Tk.END, self.possGraphs[0]) + self.cTypeGraph.insert(Tk.END, self.possGraphs[3]) + else: + self.cTypeGraph.insert(Tk.END, self.possGraphs[4]) + + + + + self.updateChosen() + + def chooseDataY(self, *event): + self.dataChosenY = self.cYAxisData.get('active') + self.cTypeGraph.delete(0,Tk.END) + + + if ((self.dataChosenX != "") and (self.dataChosenY != "")): + if self.data[self.fileChosen][self.dataChosenY].type == 1 or self.data[self.fileChosen][self.dataChosenY].type == 2: + self.cTypeGraph.insert(Tk.END, self.possGraphs[0]) + self.cTypeGraph.insert(Tk.END, self.possGraphs[3]) + elif self.data[self.fileChosen][self.dataChosenY].type == 4: + self.cTypeGraph.insert(Tk.END, self.possGraphs[0]) + self.cTypeGraph.insert(Tk.END, self.possGraphs[3]) + self.cTypeGraph.insert(Tk.END, self.possGraphs[5]) + else: + self.cTypeGraph.insert(Tk.END, self.possGraphs[4]) + + + self.updateChosen() + + + + def checkDyDx(self): + self.dydx = self.var0.get() + + + self.updateChosen() + + def chooseGraph(self,num): + self.graphChosen = self.cTypeGraph.get('active') + self.updateChosen() + + def updateChosen(self): + self.ChosenVarsTextbox.tag_config('title', font = ("Gills Sans MT", 12), justify = 'center', spacing1 = 0.5, underline = 1) + self.ChosenVarsTextbox.tag_config('complete', background = 'green') + self.ChosenVarsTextbox.tag_config('incomplete', background= 'red') + if self.dydx == 1: + check = 'YES' + else: + check = 'NO' + if self.num == 0: + self.ChosenVarsTextbox.delete(0.0, Tk.END) + self.ChosenVarsTextbox.insert(Tk.END, 'Plot: \n', ("title")) + if self.fileChosen == '': + self.ChosenVarsTextbox.insert(Tk.END, 'FileChosen: ' + self.fileChosen + '\n', ('incomplete')) + else: + self.ChosenVarsTextbox.insert(Tk.END, 'FileChosen: ' + self.fileChosen + '\n', ('complete')) + if self.dataChosenX == '': + self.ChosenVarsTextbox.insert(Tk.END, 'XAxis: ' + self.dataChosenX + '\n', ('incomplete')) + else: + self.ChosenVarsTextbox.insert(Tk.END, 'XAxis: ' + self.dataChosenX + '\n', ('complete')) + if self.dataChosenY == '': + self.ChosenVarsTextbox.insert(Tk.END, 'YAxis: ' + self.dataChosenY + '\n', ('incomplete')) + else: + self.ChosenVarsTextbox.insert(Tk.END, 'YAxis: ' + self.dataChosenY + '\n', ('complete')) + if self.graphChosen == '': + self.ChosenVarsTextbox.insert(Tk.END, 'graphChosen: ' + self.graphChosen + '\n', ('incomplete')) + else: + self.ChosenVarsTextbox.insert(Tk.END, 'graphChosen: ' + self.graphChosen + '\n', ('complete')) + self.ChosenVarsTextbox.insert(Tk.END, 'dydx: ' + check + '\n') + else: + if self.ChosenVarsTextbox.search('Subplot0', index = 0.0) != '': + self.ChosenVarsTextbox.delete(self.ChosenVarsTextbox.search('Subplot0', index = 0.0), Tk.END) + for iter in self.subplots: + if iter.dydx == 1: + check = 'YES' + else: + check = 'NO' + self.ChosenVarsTextbox.insert(Tk.END, '\n') + self.ChosenVarsTextbox.insert(Tk.END, 'Subplot' + str(self.subplots.index(iter)) + ': \n', ("title")) + if iter.fileChosen == '': + self.ChosenVarsTextbox.insert(Tk.END, 'FileChosen: ' + iter.fileChosen + '\n', ('incomplete')) + else: + self.ChosenVarsTextbox.insert(Tk.END, 'FileChosen: ' + iter.fileChosen + '\n', ('complete')) + if iter.dataChosenX == '': + self.ChosenVarsTextbox.insert(Tk.END, 'XAxis: ' + iter.dataChosenX + '\n', ('incomplete')) + else: + self.ChosenVarsTextbox.insert(Tk.END, 'XAxis: ' + iter.dataChosenX + '\n', ('complete')) + if iter.dataChosenY == '': + self.ChosenVarsTextbox.insert(Tk.END, 'YAxis: ' + iter.dataChosenY + '\n', ('incomplete')) + else: + self.ChosenVarsTextbox.insert(Tk.END, 'YAxis: ' + iter.dataChosenY + '\n', ('complete')) + if iter.graphChosen == '': + self.ChosenVarsTextbox.insert(Tk.END, 'graphChosen: ' + iter.graphChosen + '\n', ('incomplete')) + else: + self.ChosenVarsTextbox.insert(Tk.END, 'graphChosen: ' + iter.graphChosen + '\n', ('complete')) + + self.ChosenVarsTextbox.insert(Tk.END, 'dydx: ' + check + '\n') + + + + + def addSubplot(self, subNum): + self.removeSubplotWindow() + self.subplots = [] + if self.subBool == 1: + pass + else: + self.subplotTabs.delete(Pmw.SELECT) + subplotFrames = [] + for subplotForms in range(0,subNum): + subplotFrames.append(self.subplotTabs.add('Subplot' + str(subplotForms))) + self.subplots.append(subplotInstance(subplotFrames[-1], self.data, self, subplotForms + 1)) + self.updateChosen() + + def modSubplot(self, oldNum, subNum): + if (oldNum > subNum): #trucate + self.subplots = self.subplots[:subNum] + return + if (oldNum == subNum): #nothing needs doing + return + if (oldNum > 0): #some subplots have been specified add remaining + for subplotForms in range(oldNum,subNum): + subplotFrames = [] + subplotFrames.append(self.subplotTabs.add('Subplot' + str(subplotForms))) + self.subplots.append(subplotInstance(subplotFrames[-1], self.data, self, subplotForms + 1)) + self.updateChosen() + return + #there are no subplots, add them: + self.removeSubplotWindow() + self.subplots = [] + self.subplotTabs.delete(Pmw.SELECT) + subplotFrames = [] + for subplotForms in range(0,subNum): + subplotFrames.append(self.subplotTabs.add('Subplot' + str(subplotForms))) + self.subplots.append(subplotInstance(subplotFrames[-1], self.data, self, subplotForms + 1)) + self.updateChosen() + + + def removeSubplotWindow(self): + self.subplotWindow.destroy() + #Setting up subplot stuff + self.subplotWindow = Tk.Frame(self.formArea, bg='green', height = 300, width = 700) + self.subplotWindow.pack(side = Tk.TOP, pady = 10) + self.subplotWindow.pack_propagate(0) + self.subplotTabs = Pmw.NoteBook(self.subplotWindow) + self.subplotTabs.pack(fill='both',expand = 'True') + tmpInnerSubplotWindow = self.subplotTabs.add('No Subplots Chosen Yet') + tmpInnerSubplotWindow.pack() + tmpInnerSubplotWindow1 = Tk.Frame(tmpInnerSubplotWindow, bg = 'white', height = 300, width = 300) + tmpInnerSubplotWindow1.pack(fill = 'both') + tmpInnerSubplotWindow1.pack_propagate(0) + tmpInnerSubplotWindow1Title = Tk.Label(tmpInnerSubplotWindow1, text = 'You have not chosen to have any subplots', bg= 'white') + tmpInnerSubplotWindow1Title.pack() + self.subplots = [] + self.updateChosen() + + + def setupPlotData(self): + bool = 1 + error = 0 + for iter in self.subplots: + if iter.dataChosenX == '' or iter.dataChosenY == '' or iter.graphChosen == '' or iter.fileChosen == '': + bool = 0 + error = 1 + + if self.dataChosenX == '' or self.dataChosenY == '' or self.graphChosen == '' or self.fileChosen == '': + bool = 0 + error = 1 + + if error == 1: + self.errorMsg('You must choose from all fields before you may graph') + + if bool == 1: + self.background.destroy() + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 943, width = 1530); + self.background.pack() + self.background.pack_propagate(0) + THEGRAPH = graphManager(self.background, self.data, self.res, [self, self.subplots]) + + def favouriteDescription(self): + self.tDescription.delete(1.0, Tk.END) + favouriteChosen = self.cFavourites.get('active') + for count in range(0,len(self.bookmarks)): + if favouriteChosen == self.bookmarks[count].title: + bookmarkNum = count + description = self.bookmarks[bookmarkNum].description + + self.tDescription.insert(1.0, description ) + + + def chooseFavourite(self): + self.favouriteWindow = Tk.Toplevel(bg = 'white') + self.favouriteWindow.title("Favourites") + above = Tk.Frame(self.favouriteWindow, bg = 'white') + above.pack(side = Tk.TOP, padx = 100) + topLabel = Tk.Label(above, text = "Available Options", font = ("Gills Sans MT", 20, "underline", "bold"), bg = 'white') + topLabel.pack(pady = 20, padx = 20) + subLabel = Tk.Label(above, text = "*Note: to display favourites that have subplots, you must first choose a subplot file", bg = 'white') + subLabel.pack(side = Tk.TOP, padx = 20) + subLabel1 = Tk.Label(above, text = "*Currently only displaying favourites that are composed of " + str(len(self.subplots) + 1) + ' plots', bg = 'white') + subLabel1.pack(side = Tk.TOP, padx = 20) + listboxFrames = Tk.Frame(self.favouriteWindow, bg = 'white') + listboxFrames.pack(side = Tk.TOP, anchor = Tk.W) + self.cFavourites = Tk.Listbox(listboxFrames, width = 30, height = 10) + self.cFavourites.pack(side = Tk.LEFT, padx = 20, pady = 20) + self.cFavourites.bind("<Double-Button-1>", self.chooseFavourites1) + bDescription = Tk.Button(listboxFrames, text = "Description -->", command = self.favouriteDescription) + bDescription.pack(side = Tk.LEFT) + self.tDescription = Tk.Text(listboxFrames, bg = 'white', width = 50, height = 10) + self.tDescription.pack(side = Tk.LEFT, padx = 20) + + + self.bQuit = Tk.Button(self.favouriteWindow, text= "Quit Window", command = (lambda: self.favouriteWindow.destroy())) + self.bQuit.pack(side = Tk.TOP, padx = 10, pady = 10) + self.bookmarks = lexyaccbookmark.parseMe() + for iter in self.bookmarks: + #if len(iter.graphChosen) == len(self.subplots) + 1: + # bool = 1 + # if len(self.subplots) > 0: + # for iter1 in self.subplots: + # if iter1.fileChosen == "": + # iter1.fileCosen = self.fileChosen + # else: + # bool = 1 + # if bool == 1: + # self.cFavourites.insert(Tk.END, iter.title) + self.cFavourites.insert(Tk.END, iter.title) + + def chooseFavourites1(self, *event): + self.favouriteChosen = self.cFavourites.get('active') + for count in range(0,len(self.bookmarks)): + if self.favouriteChosen == self.bookmarks[count].title: + bookmarkNum = count + + + + self.dataChosenX = self.bookmarks[bookmarkNum].dataChosenX[0] + self.dataChosenY = self.bookmarks[bookmarkNum].dataChosenY[0] + self.graphChosen = self.bookmarks[bookmarkNum].graphChosen[0] + self.dydx = int(self.bookmarks[bookmarkNum].dydx[0]) + + self.modSubplot(len(self.subplots),len(self.bookmarks[bookmarkNum].graphChosen)-1) + + if self.subplots > 0: + for iter in range(0, len(self.subplots)): + if self.subplots[iter].fileChosen == '': + self.subplots[iter].fileChosen = self.fileChosen + self.subplots[iter].dataChosenX = self.bookmarks[bookmarkNum].dataChosenX[iter+1] + self.subplots[iter].dataChosenY = self.bookmarks[bookmarkNum].dataChosenY[iter+1] + self.subplots[iter].graphChosen = self.bookmarks[bookmarkNum].graphChosen[iter+1] + self.subplots[iter].dydx = int(self.bookmarks[bookmarkNum].dydx[iter+1]) + + self.favouriteWindow.destroy() + self.background.destroy() + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 943, width = 1530); + self.background.pack() + self.background.pack_propagate(0) + THEGRAPH = graphManager(self.background, self.data, self.res, [self, self.subplots]) + + def errorMsg(self, string): + error = Tk.Toplevel(bg = 'white') + error.title("Error Message") + tError = Tk.Label(error, text = "Error", font = ("Gills Sans MT", 20, "underline", "bold"), bg = "red") + tError.pack(side = Tk.TOP, pady = 20) + lError = Tk.Label(error, text = string, font = ("Gills Sans MT", 15, "bold"), bg = 'white') + lError.pack(pady = 10, padx = 10) + bError = Tk.Button(error, text = "OK", font = ("Times New Roman", 14), command = (lambda: error.destroy())) + bError.pack(pady = 10) + + + def helpMsg(self, string): + helpTip = Tk.Toplevel(bg = 'white') + helpTip.title("Helping Tip") + lHelpTip = Tk.Label(helpTip, text = string, font = ("Gills Sans MT", 15, "bold"), bg = 'white') + lHelpTip.pack(pady = 10, padx = 10) + bHelpTip = Tk.Button(helpTip, text = "OK", font = ("Times New Roman", 14), command = (lambda: helpTip.destroy())) + bHelpTip.pack(pady = 10) + + +class subplotInstance(formEntry): + + def __init__(self, master,data,plotInstance, subNum): + frame = Tk.Frame(master, width = 700, height = 300, bg ='white') + frame.pack() + frame.pack_propagate(0) + + #Variable Initializations + self.fileChosen = '' + self.dataChosenX = 'globalCycle' + self.dataChosenY = '' + self.graphChosen = '' + self.data = data + self.var0 = Tk.IntVar() + self.possGraphs = ['Line', 'Histogram', 'Bar Chart', 'Parallel Intensity Plot', 'Stacked Bar Chart', 'Parallel Intensity Plot (Sum)'] + self.dydx = 0 + self.ChosenVarsTextbox = plotInstance.ChosenVarsTextbox + self.num = subNum + self.subplots = plotInstance.subplots + + + # Frame and listboxes for choosing what file you want to use data from + whichFileFrame = Tk.Frame(frame, bg= 'white') + whichFileFrame.pack(side = Tk.TOP, anchor = Tk.W, pady = 5) + lwhichFileFrame = Tk.Label(whichFileFrame, text = 'Choose a File:', font = ("Gills Sans MT", 12), bg = "white") + lwhichFileFrame.pack(side = Tk.LEFT) + self.cWhichFile= Tk.Listbox(whichFileFrame, width = 85, height = 4) + self.cWhichFile.pack(side =Tk.LEFT) + self.cWhichFile.bind("<Double-Button-1>", self.chooseFile) + + #Placing the available filenames in the self.cWhichFileFrame Listbox + for files in sorted(self.data): + self.cWhichFile.insert(Tk.END, files) + + # move to end of lines to actually see the filenames + self.cWhichFile.xview_moveto(1) + + #Frame for choosing what data you are going to plot + chooseDataFrame = Tk.Frame(frame, bg = "white") + chooseDataFrame.pack(side = Tk.TOP, anchor = Tk.W) + lchooseDataFrame = Tk.Label(chooseDataFrame, text= 'Data to be Plotted:', font = ("Gills Sans MT", 12), bg = "white") + lchooseDataFrame.pack(side= Tk.LEFT); + bQchooseDataFrameHelp = Tk.Button(chooseDataFrame, text = " ? -->", command = (lambda: self.helpMsg('Double-Click on the metric to select it for plotting.'))) + bQchooseDataFrameHelp.pack(side =Tk.LEFT, padx = 5) + XListbox = Tk.Frame(chooseDataFrame, bg= 'white') + XListbox.pack(side = Tk.LEFT) + XTitle = Tk.Label(XListbox, text = "X Vars", bg= 'white') + XTitle.pack(side = Tk.TOP) + self.cXAxisData = Tk.Listbox(XListbox, width = 19, height = 5, selectmode = Tk.MULTIPLE) + self.cXAxisData.bind("<Double-Button-1>", self.chooseDataX) + YListbox = Tk.Frame(chooseDataFrame, bg = 'white') + YListbox.pack(side = Tk.LEFT) + YFrameForScrollbar = Tk.Frame(YListbox, bg= 'white') + YFrameForScrollbar.pack(side = Tk.BOTTOM) + scrollYAxisData = Tk.Scrollbar(YFrameForScrollbar, orient = Tk.VERTICAL) + YTitle = Tk.Label(YListbox, text = 'Y Vars', bg= 'white') + YTitle.pack(side = Tk.TOP) + self.cYAxisData = Tk.Listbox(YFrameForScrollbar,width = 19, height = 5, yscrollcommand=scrollYAxisData.set) + self.cYAxisData.bind("<Double-Button-1>", self.chooseDataY) + scrollYAxisData.config(command=self.cYAxisData.yview) + self.cXAxisData.pack(side = Tk.BOTTOM) + self.cYAxisData.pack(side = Tk.LEFT) + scrollYAxisData.pack(side=Tk.LEFT, fill = 'y') + + # The Take Derivative Checkbutton + self.var0 = Tk.IntVar() + checkbDyDx = Tk.Checkbutton(chooseDataFrame, text= "dy/dx", variable= self.var0, bg = 'white', command = (lambda: self.checkDyDx())) + checkbDyDx.pack(side= Tk.LEFT, padx = 5) + + #Frame for choosing what type of graph + typeGraph = Tk.Frame(frame, bg = "white") + typeGraph.pack(side = Tk.TOP, anchor = Tk.W, pady = 10) + lTypeGraph = Tk.Label(typeGraph, text= 'Type of Graph:', font = ("Gills Sans MT", 12), bg = "white") + lTypeGraph.pack(side= Tk.LEFT); + bQTypeGraphHelp = Tk.Button(typeGraph, text = " ? -->", command = (lambda: self.helpMsg('Double-Click on the graph type to select it.'))) + bQTypeGraphHelp.pack(side =Tk.LEFT, padx = 5) + self.cTypeGraph = Tk.Listbox(typeGraph, width = 50, height = 3) + self.cTypeGraph.bind("<Double-Button-1>", self.chooseGraph) + self.cTypeGraph.pack(side = Tk.LEFT) + + +# Class holding all the format information of a plot +class PlotFormatInfo: + + # names of available colormaps + cmapOptions = ['gist_heat_r', 'gist_heat', 'hot_r', 'hot', 'gray', 'gray_r', 'spectral', 'bone', 'bone_r', 'GnBu', 'GnBu_r', 'gist_earth', 'gist_earth_r', 'zero_dark', 'zero_white'] + + # custom color maps + zero_dark = {'red': ((0.0, 0.0, 0.0), (0.0001, 1.0, 1.0), (1.0, 0.0, 1.0)), + 'green':((0.0, 0.0, 0.0), (0.0001, 0.0, 0.0), (0.5, 1.0, 1.0), (1.0, 0.0, 1.0)), + 'blue': ((0.0, 0.0, 0.0), (0.0001, 0.0, 0.0), (0.25, 0.0, 0.0), (1.0, 1.0, 1.0))} + zero_dark_cmap = mpl.colors.LinearSegmentedColormap('zero_dark', zero_dark, 1024) + + zero_white = {'red': ((0.0, 1.0, 1.0), (0.0001, 1.0, 1.0), (1.0, 0.0, 1.0)), + 'green':((0.0, 1.0, 1.0), (0.0001, 1.0, 0.0), (0.5, 1.0, 1.0), (1.0, 0.0, 1.0)), + 'blue': ((0.0, 1.0, 1.0), (0.0001, 1.0, 0.0), (0.25, 0.0, 0.0), (1.0, 1.0, 1.0))} + zero_white_cmap = mpl.colors.LinearSegmentedColormap('zero_white', zero_white, 1024) + + custom_cmaps = {'zero_dark': zero_dark_cmap, 'zero_white': zero_white_cmap } + + strNoDisplay = 'NULL:0x0000' + + optionSection = 'TimeLapseView' + + def __init__(self, plotID, + title = strNoDisplay, + xlabel = strNoDisplay, + ylabel = strNoDisplay, + cbarlabel = strNoDisplay, + rotation = avconfig.get_value(optionSection, 'xTicksRotation', 'horizontal'), + labelFontSize = avconfig.get_value(optionSection, 'labelFontSize', 13), + cticksFontSize = avconfig.get_value(optionSection, 'cTicksFontSize', 10), + xticksFontSize = avconfig.get_value(optionSection, 'xTicksFontSize', 10), + yticksFontSize = avconfig.get_value(optionSection, 'yTicksFontSize', 10)): + + self.plotID = plotID # for debugging purpose + + self.title = title + self.xlabel = xlabel + self.ylabel = ylabel + self.cbarlabel = cbarlabel + self.rotation = rotation + self.labelFontSize = labelFontSize + self.cticksFontSize = cticksFontSize + self.xticksFontSize = xticksFontSize + self.yticksFontSize = yticksFontSize + + self.cmap = Tk.StringVar() + self.cmap.set(PlotFormatInfo.cmapOptions[0]) + + self.norm = mpl.colors.Normalize() + + def InitLabels(self, xlabel, ylabel, cbarlabel, title = ''): + + if (self.xlabel == PlotFormatInfo.strNoDisplay): + self.xlabel = xlabel + + if (self.ylabel == PlotFormatInfo.strNoDisplay): + self.ylabel = ylabel + + if (self.cbarlabel == PlotFormatInfo.strNoDisplay): + self.cbarlabel = cbarlabel + + if (self.title == PlotFormatInfo.strNoDisplay): + self.title = title + + # Obtain the matplotlib colormap that will be used for the parallel intensity plot + def GetColorMap(self): + cmapName = self.cmap.get() + if (cmapName in PlotFormatInfo.custom_cmaps): + cmap = PlotFormatInfo.custom_cmaps[cmapName] + else: + cmap = mpl.cm.get_cmap(name=cmapName) + return cmap + +class graphManager: + + def __init__(self, master, data, res, dataChosen): + + self.normalizePlotColors = '' + self.master = master + #Variable initializations + self.cycleStep = 0 + self.wilLeft = '' + self.res =res + self.dataChosen = dataChosen + self.data = data + self.disconnect = 0 + self.possGraphs = ['Line', 'Histogram', 'Bar Chart', 'Parallel Intensity Plot', 'Stacked Bar Chart', 'Parallel Intensity Plot (Sum)'] + self.xlim = 0 + self.xAxisStepsWilStack = {} + self.cbarAxes = {} + self.plotRef = {} + self.plotFormatInfo = {} + + if self.res == "small": + self.underneathGraph = Tk.Frame(master, borderwidth = 5, relief = Tk.GROOVE, height = 100, width = 1225); + elif self.res == 'medium': + self.underneathGraph = Tk.Frame(master, borderwidth = 5, relief = Tk.GROOVE, height = 100, width = 1572); + else: + self.underneathGraph = Tk.Frame(master, borderwidth = 5, relief = Tk.GROOVE, height = 100, width = 1572); + self.underneathGraph.pack(side = Tk.BOTTOM, fill = Tk.X ) + + if self.res == "small": + self.graphArea = Tk.Canvas(master, bg = "black", borderwidth = 5, relief = Tk.GROOVE, width = 1200); + elif self.res == 'medium': + self.graphArea = Tk.Canvas(master, bg = "black", borderwidth = 5, relief = Tk.GROOVE, width = 1513, height = 800); + else: + self.graphArea = Tk.Canvas(master, bg = "black", borderwidth = 5, relief = Tk.GROOVE, width = 1513, height = 800); + self.graphArea.pack(side = Tk.BOTTOM, fill = Tk.BOTH, expand = 1) + + ## Allow user to choose specific graph options + + self.leftMostUnderneath = Tk.Frame(self.underneathGraph); + self.leftMostUnderneath.pack(side = Tk.LEFT, anchor = Tk.N) + self.toolbarArea = Tk.Frame(self.leftMostUnderneath, borderwidth = 1, relief = Tk.GROOVE, bg = 'black') + self.toolbarArea.pack(anchor = Tk.N) + bDyDx = Tk.Button(self.underneathGraph, text = 'dy/dx', command = self.takeDerivativeButton) + bDyDx.pack(side = Tk.RIGHT, anchor = Tk.N) + bAddToFavourites = Tk.Button(self.underneathGraph, text = "Add to Favourites", command = self.addToFavourites) + bAddToFavourites.pack(side = Tk.RIGHT, anchor = Tk.N) + bRefreshInputFiles = Tk.Button(self.underneathGraph, text= "Refresh Input Files", command = self.refreshInputs) + bRefreshInputFiles.pack(side = Tk.RIGHT, anchor = Tk.N) + bChangeColorMapMaxMin = Tk.Button(self.underneathGraph, text = "Change Colormap Max/Min", command = self.changeColorMapMaxMin) + bChangeColorMapMaxMin.pack(side = Tk.RIGHT, anchor = Tk.N) + bChangeBinning = Tk.Button(self.underneathGraph, text = 'Change Binning', command = self.changeBinning) + bChangeBinning.pack(side = Tk.RIGHT, anchor = Tk.N) + bEditLabels = Tk.Button(self.underneathGraph, text = 'Edit Labels', command = self.editLabelsButton) + bEditLabels.pack(side = Tk.RIGHT, anchor = Tk.N) + bZoom = Tk.Button(self.underneathGraph, text = 'Zoom', command = self.zoomButton) + bZoom.pack(side = Tk.RIGHT, anchor = Tk.N) + + + if self.res == "small": + self.figure = Figure(figsize=(17,9), dpi=96) + elif self.res == 'medium': + self.figure = Figure(figsize=(20,9), dpi=96) + else: + self.figure = Figure(figsize=(22,13), dpi=96) + + #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.update() + self.plotData() + + def addToFavourites(self): + self.addFavourite = Tk.Toplevel(bg = 'white') + self.addFavourite.title("Add Favourite") + fTitle = Tk.Frame(self.addFavourite, bg = 'white') + fTitle.pack(side = Tk.TOP, padx= 100, pady = 10) + lTitle = Tk.Label(fTitle, text = "Title of new favourite: ", bg = 'white') + lTitle.pack(side = Tk.LEFT) + self.eTitle = Tk.Entry(fTitle, width = 50, bg = 'white') + self.eTitle.pack(side = Tk.LEFT, padx = 3) + fDescription = Tk.Frame(self.addFavourite, bg = 'white') + fDescription.pack(side = Tk.TOP, padx= 100, pady = 10) + lDescription = Tk.Label(fDescription, text = "Description of favourite: ", bg = 'white') + lDescription.pack(side = Tk.LEFT) + self.eDescription = Tk.Text(fDescription, width = 50, height = 10, bg = 'white') + self.eDescription.pack(side = Tk.LEFT) + fSubCanc = Tk.Frame(self.addFavourite, bg = 'white') + fSubCanc.pack(side = Tk.BOTTOM) + bSubmit = Tk.Button(fSubCanc, text = "Submit", command = self.addFavouriteTitDesc) + bSubmit.pack(side = Tk.LEFT) + bCancel = Tk.Button(fSubCanc, text = "Cancel", command = (lambda: self.addFavourite.destroy())) + + def addFavouriteTitDesc(self): + bool = 1 + self.favouriteTitle = self.eTitle.get() + self.favouriteDesc = self.eDescription.get(1.0,Tk.END) + self.favouriteDesc = str(self.favouriteDesc) + test = [] + test.append(self.favouriteDesc) + self.addFavourite.destroy() + self.favouriteDesc = self.favouriteDesc.rstrip() + test.append(self.favouriteDesc) + + if self.favouriteTitle == "": + self.errorMsg("You need to at least submit a title, try again...") + bool = 0 + + numPlots = len(self.dataChosen[1]) + 1 + self.dataPointer = self.dataChosen[0] + + if bool: + file = open(os.environ['HOME'] + "/.gpgpu_sim/aerialvision/bookmarks.txt", 'a') + file.write('START = "TRUE"\n') + file.write('title = "' + self.favouriteTitle + '"\n') + file.write('description = "' + self.favouriteDesc + '"\n') + for self.currPlot in range(1,numPlots + 1): + file.write('dataChosenX = "' + self.dataPointer.dataChosenX + '"\n') + file.write('dataChosenY = "' + self.dataPointer.dataChosenY + '"\n') + file.write('graphChosen = "' + self.dataPointer.graphChosen + '"\n') + file.write('dydx = "' + str(self.dataPointer.dydx) + '"\n') + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + + file.close() + + def format_coordWilson(self,x, y): + col = int(x)*(self.simplerName[self.dataPointer.dataChosenX].data[1]) + row = int(y+0.5) + numrows = len(self.simplerName[self.dataPointer.dataChosenY].data) + try: + numcols = len(self.simplerName[self.dataPointer.dataChosenY].data[0]) + except: + numcols = 1 + if x>=0 and x<numcols and y>=0 and y<numrows: + #z = self.simplerName[self.dataPointer.dataChosenY].data[int(y)][int(x)] + #return 'x=%d, y=%d, z=%1.3f'%(col, row, z) + return 'x=%d, y=%d'%(col, row) + else: + return 'x=%d, y=%d'%(col, row) + + + + + + def plotData(self): + + #Variable initializations + self.currPlot = 1 + numPlots = len(self.dataChosen[1]) + 1 + self.xAxisStepsWilStack = ['null'] + self.yAxisStepsWilStack = ['null'] + #need to scale all plots to the same length + self.dataPointer = self.dataChosen[0] + self.simplerName = self.data[self.dataPointer.fileChosen] + self.colorbars = {} + + for self.currPlot in range(1,numPlots + 1): + self.xAxisStepsWilStack.append(20) + self.yAxisStepsWilStack.append('null') + self.findKernalLocs() + tmp = self.updateVarKernal(self.simplerName[self.dataPointer.dataChosenX].data) + if tmp[-1] > self.xlim: + self.xlim = tmp[-1] + self.cycleStep = tmp[1] + else: + pass + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + self.simplerName = self.data[self.dataPointer.fileChosen] + + # initialize format info of this plot + if self.currPlot not in self.plotFormatInfo: + self.plotFormatInfo[self.currPlot] = PlotFormatInfo(self.currPlot) + + + self.dataPointer = self.dataChosen[0] + self.simplerName = self.data[self.dataPointer.fileChosen] + + for self.currPlot in range(1,numPlots + 1): + self.findKernalLocs() + if (self.currPlot in self.plotRef): + self.figure.delaxes(self.plotRef[self.currPlot]) + self.plot = self.figure.add_subplot(numPlots,1,self.currPlot) + self.plotRef[self.currPlot] = self.plot + self.plotFormatInfo[self.currPlot].graphType = self.dataPointer.graphChosen + if self.dataPointer.graphChosen == 'Parallel Intensity Plot': + self.plot.format_coord = self.format_coordWilson + if self.simplerName[self.dataPointer.dataChosenY].type == 1: + self.type1Variable(self.simplerName[self.dataPointer.dataChosenX].data , self.dataPointer.dataChosenX, self.simplerName[self.dataPointer.dataChosenY].data, self.dataPointer.dataChosenY, self.simplerName[self.dataPointer.dataChosenY].bool, self.currPlot) + elif self.simplerName[self.dataPointer.dataChosenY].type == 2: + self.type2Variable(self.simplerName[self.dataPointer.dataChosenX].data,self.dataPointer.dataChosenX, self.simplerName[self.dataPointer.dataChosenY].data,self.dataPointer.dataChosenY, self.currPlot) + elif self.simplerName[self.dataPointer.dataChosenY].type == 3: + self.type3Variable(self.simplerName[self.dataPointer.dataChosenX].data,self.dataPointer.dataChosenX,self.simplerName[self.dataPointer.dataChosenY].data,self.dataPointer.dataChosenY, self.currPlot) + else: + self.type4Variable(self.simplerName[self.dataPointer.dataChosenX].data,self.dataPointer.dataChosenX,self.simplerName[self.dataPointer.dataChosenY].data,self.dataPointer.dataChosenY, self.currPlot) + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + self.simplerName = self.data[self.dataPointer.fileChosen] + + #self.figure.subplots_adjust(top = 0.80) + + + def type1Variable(self, x, xAxis, y, yAxis, boolK, plotID): + + graphOption = 'NULL' + + + + if self.simplerName.has_key('globalTotInsn') == 'False': + graphOption = 1 + + if (graphOption == 1): + if (self.dataPointer.dydx >= 1): + for iter in range(0, self.dataPointer.dydx): + y = self.takeDerivative(x, y) + + yAxis = yAxis + '/Cycle' + + if (self.graphChosen == self.possGraphs[3]): + self.plotWilson(x, xAxis, [y], yAxis, yAxis, [1], plotID) + else: + self.plot2VarLine(x, xAxis, y, yAxis) + + + else: + x = self.updateVarKernal(x) + + if boolK: + y = self.updateVarKernal(y) + + if (self.dataPointer.dydx >= 1): + for iter in range(0, self.dataPointer.dydx): + y = self.takeDerivative(x, y) + yAxis = yAxis + '/Cycle' + + + if (self.dataPointer.graphChosen == self.possGraphs[3]): + self.plotWilson(x, xAxis, [y], yAxis, yAxis, [1], plotID) + else: + #Label and plot Line Graph + self.labelKernals(x,y) + self.plot2VarLine(x, xAxis, y, yAxis) + + + + def type2Variable(self, x, xAxis, y, yAxis, plotID): + + graphOption = "NULL" + + if self.simplerName.has_key('globalTotInsn') == 'False': + graphOption = 1 + + if (graphOption == 1): + + if (self.dataPointer.dydx >= 1): + for iter in range(0, self.dataPointer.dydx): + y = self.takeDerivativeMult(x,y) + + yAxis = yAxis + '/Cycle' + + if (self.dataPointer.graphChosen == self.possGraphs[3]): + yTicks = [n for n in range(len(y))] + self.plotWilson(x, xAxis, y, yAxis, yAxis, yTicks, plotID) + else: + self.plotMultVarLine(x, xAxis, y, yAxis) + + + else: + + x = self.updateVarKernal(x) + + if (self.dataPointer.dydx >= 1): + for iter in range(0, self.dataPointer.dydx): + y = self.takeDerivativeMult(x,y) + + yAxis = yAxis + '/Cycle' + + + if (self.dataPointer.graphChosen == self.possGraphs[3]): + yTicks = [n for n in range(len(y))] + self.plotWilson(x, xAxis, y, yAxis, yAxis, yTicks, plotID) + + else: + #Label and Plot + self.labelKernalsMult(x, y) + self.plotMultVarLine(x,xAxis, y,yAxis) + + + + + def type3Variable(self, x, xAxis, y, yAxis, plotID): + #Type 3 variables are currently those that are used for STACKED BAR PLOTS + + #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'): + x = self.updateVarKernal(x) + + concentrationFactor = 1 + if len(y[0]) > 512: + concentrationFactor = len(y[0]) // 512 + 1 + newLen = 512 + for row in range (0,len(y)): + newy = [0 for col in range(newLen)] + for col in range(0, len(y[row])): + newcol = col/concentrationFactor + newy[newcol] += y[row][col] + y[row] = newy + + #Scalar Vars + numCols = len(y[0]) #the number of columns in the stacked bar plot + width = 1.0 #Our bars will occupy 100% of the space allocated to them + numRows = len(y) #The number of stacks + colours = mpl.cm.get_cmap('RdBu', numRows) #discretizing a matplotlib color scheme to serve as the various colors of our stacked bar plot + + + #Labelling the xAxis with the name of the variable and also the file that the data was chosen from + self.plot.set_xlabel(xAxis) + + #Non-Scalar Vars + ind = [tmp for tmp in range(0,numCols)] #the location of the bar and the x axis labels + 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']; + + yoff_max = numpy.array([0.0] * numCols) + for row in range(numRows-1,-1,-1): + yoff_max += y[row] + + if yAxis == 'WarpDivergenceBreakdown': + for row in range(0,numRows): + row1 = float(row) #Used to select a new color from the colormap.. need to be a float thats why a new variable was made + yoff = yoff + y[row] #updating the yoff variable + if row == 0: + self.plot.bar(ind, y[row], width, bottom = yoff_max-yoff, color=colours(row1/numRows), edgecolor=colours(row1/numRows), label = 'Fetch Stalled' ) + elif row == 1: + self.plot.bar(ind, y[row], width, bottom = yoff_max-yoff, color=colours(row1/numRows), edgecolor=colours(row1/numRows), label = 'W0' ) + else: # next line: 4=warp_size/8 + self.plot.bar(ind, y[row], width, bottom = yoff_max-yoff, color=colours(row1/numRows), edgecolor=colours(row1/numRows), label = 'W' + `4*(row-2)+1` + ':' + `4*(row-1)`) + else: + for row in range(numRows-1,-1,-1): + row1 = float(row) #Used to select a new color from the colormap.. need to be a float thats why a new variable was made + yoff = yoff + y[row] #updating the yoff variable + self.plot.bar(ind, y[row], width, bottom = yoff_max-yoff, color=colours(row1/numRows), edgecolor=colours(row1/numRows), label = Legendname[row]) #plotting each set of bar plots individually + + + plotFormat = self.plotFormatInfo[plotID] + plotFormat.InitLabels(xlabel = xAxis, ylabel = yAxis, cbarlabel = '', + title = yAxis + ' vs ' + xAxis + ' ...' + self.dataPointer.fileChosen[-80:]) + self.plot.set_title(plotFormat.title) + + # More Labelling + self.plot.set_xlabel(plotFormat.xlabel, fontsize = plotFormat.labelFontSize) + self.plot.set_ylabel(plotFormat.ylabel, fontsize = plotFormat.labelFontSize) + + matplotlib.rcParams['legend.fontsize'] = plotFormat.yticksFontSize + self.plot.legend(loc=(1.01,0.1)) + + labelValues = [] + labelPos = [] + try: + for count in range(0,len(x)/concentrationFactor,len(x)/20/concentrationFactor): + labelValues.append(x[count * concentrationFactor]) + labelPos.append(ind[count]) + except: + pass + + + xlim = self.type3findxlim(ind[-1], x[1]) + self.plot.set_xlim(0,xlim / concentrationFactor) + + self.plot.set_xticklabels(labelValues, rotation = plotFormat.rotation, fontsize = plotFormat.xticksFontSize) + self.plot.set_xticks(labelPos) + for label in self.plot.get_yticklabels(): + label.set_fontsize(plotFormat.yticksFontSize) + + self.canvas.show() + + def type4Variable(self, x, xAxis, y, yAxis, plotID): + keys = y.keys() + keys.sort() + + if (self.dataPointer.graphChosen == self.possGraphs[3]): + image = [] + for iter in keys: + image.append(y[iter]) + + if self.dataPointer.dydx >= 1: + for iter in range(0, self.dataPointer.dydx): + image = self.takeDerivativeMult(x, image) + + elif (self.dataPointer.graphChosen == self.possGraphs[5]): + # collect a set of majorkeys (assuming format m.n in key) + majorKeys = set() + dataLength = 0 + for k in keys: + majork, minork = k.split('.') + majorKeys.add(majork) + dataLength = len(y[k]) + majorKeys = list(majorKeys) + majorKeys.sort() + + # define a (dataLength x #MajorKeys) array + image = [[0 for t in range(dataLength)] for s in range(len(majorKeys))] + for k in keys: + majork, minork = k.split('.') + imageArray = image[int(majork)] + dataArray = y[k] + for pt in range(dataLength): + imageArray[pt] += dataArray[pt] + + if self.dataPointer.dydx >= 1: + for iter in range(0, self.dataPointer.dydx): + image = self.takeDerivativeMult(x, image) + + keys = majorKeys + else: + pass + + + self.plotWilson(x, xAxis, image, yAxis, yAxis, keys, plotID) + + + def updateVarKernal(self,var): + var = [val for val in var] + if self.disconnect == 0: + for cycleNum in range(0,len(self.simplerName[self.dataPointer.dataChosenX].data)): + if (self.xIsKernal(cycleNum,self.kernalLocs)): + for cycleSum in range(self.kernalLocs[self.kernalLocs.index(cycleNum) + 1] - 1, cycleNum - 1, -1): + if cycleNum == 0: + continue + var[cycleSum] += var[cycleNum - 1] + return var + else: + return var + + + def xIsKernal(self,x,kernalStarts): + bool = 0 + for y in kernalStarts: + if (y == x): + bool = 1 + return bool + + def findKernalLocs(self): + + self.kernalLocs = [] + prevCycle = -1 + countIter = 0 + for cycle in self.simplerName[self.dataPointer.dataChosenX].data: + if (prevCycle >= cycle): + self.kernalLocs.append(countIter) + prevCycle = cycle + countIter += 1 + self.kernalLocs.append(len(self.simplerName[self.dataPointer.dataChosenX].data)) + + def labelKernalsMult(self,x, y): + countKernal = 0 + label = "" + sum = [] + maximum = 0 + sumAve = [] + + for values in range(0,len(y[0])): + sum.append(0) + for chip in range(0,len(y)): + sum[values] += y[chip][values] + sumAve.append(sum[values]/len(y)) + + for vectors in range(0,len(y)): + if max(y[vectors]) > max(y[maximum]): + maximum = vectors + + + for a in self.kernalLocs: + a = a - 1 + countKernal += 1 + label = " EndKern" + str(countKernal) + self.plot.text(x[a],sum[a]/len(y), label, fontsize = 13) + tmpx = [] + tmpy = [] + for num in (y[maximum] + [max(y[maximum]) + max(sumAve)/10]): + tmpx.append(x[a]) + tmpy.append(num) + self.plot.plot(tmpx, tmpy, 'k:' ) + + + + def labelKernals(self,x, y): + countKernal = 0 + label = "" + + + for cycleNum in range(0,len(x)): + if(self.xIsKernal(cycleNum,self.kernalLocs)): + countKernal += 1 + label = " EndKern" + str(countKernal) + self.plot.text(x[self.kernalLocs[self.kernalLocs.index(cycleNum)] - 1], y[self.kernalLocs[self.kernalLocs.index(cycleNum)] - 1], label, fontsize = 10) + + tmpx = [] + tmpy = [] + for num in (y + [max(y) + max(y)/10]): + tmpx.append(x[self.kernalLocs[self.kernalLocs.index(cycleNum)] - 1]) + tmpy.append(num) + # tmpx, tmpy + self.plot.plot(tmpx, tmpy, 'k:' ) + countKernal += 1 + label = " EndKern" + str(countKernal) + self.plot.text(x[-1], y[-1], label, fontsize = 10) + tmpx = [] + tmpy = [] + for num in (y + [max(y) + max(y)/10]): + tmpx.append(x[-1]) + tmpy.append(num) + self.plot.plot(tmpx, tmpy, 'k:' ) + + + def plot2VarLine(self, x, xAxis, y, yAxis): + self.plot.plot(x, y) + self.plot.set_xlim(0, self.xlim) + self.plotFormatInfo[self.currPlot].InitLabels(xlabel = xAxis, ylabel = yAxis, cbarlabel = '', title = xAxis + ' vs ' + yAxis + ' ...' + self.dataPointer.fileChosen[-80:]) + 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() + + + def plotMultVarLine(self, x, xAxis, y, yAxis): + for num in range(0,len(y)): + self.plot.plot(x, y[num]) + self.plot.set_xlim(0, self.xlim) + 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.plot.set_xlabel(xAxis) + #self.plot.set_ylabel(yAxis) + #self.plot.set_title(self.dataChosen) + self.canvas.show() + + def takeDerivativeMult(self,x,y): + multDerivative = [] + + cycleStep = self.simplerName[self.dataPointer.dataChosenX].data[1] - self.simplerName[self.dataPointer.dataChosenX].data[0] + + + for num in range(0,len(y)): + multDerivative.append(self.takeDerivative(x,y[num])) + return multDerivative + + + def takeDerivative(self,x,y,b_acc=1): #both variables have to already be organized for this to work!!! + x = [val for val in x] + y = [val for val in y] + derivative = [] + prevY = 0 + + cycleStep = x[1] - x[0] + if (cycleStep < 0): + prevCycle = 0 + for cycle in self.simplerName[self.dataPointer.dataChosenX].data: + cycleStep = cycle - prevCycle + if cycleStep == 0: + continue + else: + break + prevCycle = cycle + # fill up self.globalIPC list + for yNum in y: + if (b_acc == 1 and yNum < prevY): + prevY = 0 + derivative.append(float(yNum - prevY)/cycleStep) + prevY = yNum + return derivative + + + def plotWilson(self, x, xAxis, y, yAxis, colorAxis, yTicks, plotID): + # Obtain plot format info + plotFormat = self.plotFormatInfo[plotID] + + # Obtain the matplotlib colormap that we will use for the parallel intensity plot + cmap = plotFormat.GetColorMap() + + #The yAxis/xAxis Labels and their corresponding positions + yticks, yticksPos = self.updateWilTicks(y) + #currently not using the variable xticks. we want to use values from the x input parameter and place them at 'xticksPos' + xticks, xticksPos = self.updateWilTicks(x) + + #Limits the number of xAxis labels to 20 otherwise the labels will become too cluttered + xlabelValues = [] + xlabelPos = [] + ylabelValues = [] + ylabelPos = [] + + if self.xAxisStepsWilStack[self.currPlot] < 1: + self.xAxisStepsWilStack[self.currPlot] = 1 + if self.xAxisStepsWilStack[self.currPlot] > len(x): + self.xAxisStepsWilStack[self.currPlot] = len(x) + + if self.yAxisStepsWilStack[self.currPlot] == 'null': + self.yAxisStepsWilStack[self.currPlot] = 32 + if self.yAxisStepsWilStack[self.currPlot] < 1: + self.yAxisStepsWilStack[self.currPlot] = 1 + if self.yAxisStepsWilStack[self.currPlot] > len(y): + self.yAxisStepsWilStack[self.currPlot] = len(y) + + + # 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]): + 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]): + ylabelValues.append(yTicks[count]) + ylabelPos.append(yticksPos[count]) + + #Now that we have all of our axis labels, lets set them + self.plot.set_yticklabels(ylabelValues, fontsize = plotFormat.yticksFontSize) + self.plot.set_yticks(ylabelPos) + self.plot.set_xticklabels(xlabelValues, rotation = plotFormat.rotation, fontsize = plotFormat.xticksFontSize) + self.plot.set_xticks(xlabelPos) + + y = self.wilsonScaleX(y) + + # interpolation = 'lanczos' + interpolation = 'nearest' + norm = plotFormat.norm + im = self.plot.imshow(y, cmap = cmap, interpolation = interpolation, aspect = 'auto', norm = norm ) + tmp = im.get_axes().get_position().get_points() + + if (plotID in self.cbarAxes): + self.figure.delaxes(self.cbarAxes[plotID]) + cax = self.figure.add_axes([0.91, tmp[0][1], 0.01, tmp[1][1] - tmp[0][1]]) + cbar = self.figure.colorbar(im, cax = cax, orientation = 'vertical') + self.cbarAxes[plotID]= cax # use for cleanup + self.colorbars[self.currPlot] = cbar + + # scaleTicks = self.updateWilScaleTicks(y) + + self.plotFormatInfo[plotID].InitLabels( cbarlabel = 'Scale: ' + colorAxis, xlabel = xAxis + ' ...' + self.dataPointer.fileChosen[-80:], ylabel = yAxis ) + cbar.set_label( plotFormat.cbarlabel, fontsize = plotFormat.labelFontSize) + for label in cbar.ax.get_yticklabels(): + label.set_fontsize(plotFormat.cticksFontSize) + self.plot.set_xlabel(plotFormat.xlabel, fontsize = plotFormat.labelFontSize) + self.plot.set_ylabel(plotFormat.ylabel, fontsize = plotFormat.labelFontSize) + #self.plot.set_title(self.dataChosenY) + self.canvas.show() + + def updateWilTicks(self, z): + x= [] + pos = [] + for y in range(0,len(z)): + x.append(y) + pos.append(y) + return x, pos + + def updateWilScaleTicks(self, z): + x= [] + pos = [] + for y in range(0,len(z)): + x.append(y) + pos.append(y) + return x, pos + + def refreshInputs(self): + + numPlots = len(self.dataChosen[1]) + 1 + self.dataPointer = self.dataChosen[0] + for self.currPlot in range(1,numPlots + 1): + del self.data[self.dataPointer.fileChosen] + self.data[self.dataPointer.fileChosen] = lexyacc.parseMe(self.dataPointer.fileChosen) + + markForDel = [] + for variables in self.data[self.dataPointer.fileChosen]: + if self.checkEmpty(self.data[self.dataPointer.fileChosen][variables].data) == 0: + markForDel.append(variables) + + for variables in markForDel: + del self.data[self.dataPointer.fileChosen][variables] + + self.data[self.dataPointer.fileChosen] = organizedata.organizedata(self.data[self.dataPointer.fileChosen]) + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + self.simplerName = self.data[self.dataPointer.fileChosen] + + self.graphArea.destroy() + self.underneathGraph.destroy() + self.currPlot = 1 + self.__init__(self.master, self.data, self.res, self.dataChosen) + + def checkEmpty(self,list): + bool = 0 + for x in list: + if ((x != 0) and (x != 'NULL')): + bool = 1 + return bool + + def type3findxlim(self, max, cycleStep): + cycleStep = float(cycleStep) + factor = 1.0/cycleStep + newXlim = self.xlim*factor + return newXlim + + def wilsonScaleX(self, yshort): + numPixels = self.xlim/self.cycleStep + if len(yshort[0]) < numPixels: + length = len(yshort[0]) + for rows in range(0,len(yshort)): + for count in range(0, numPixels - length): + yshort[rows].append(0) + return yshort + + + def changeColorMapMaxMin(self): + #Variable initializations + NEWFRAME = Tk.Toplevel(self.master, bg = 'white') + self.currPlot = 1 + numPlots = len(self.dataChosen[1]) + 1 + absoluteMax = 0 + + root = [] + entry = {} + #need to scale all plots to the same length + self.dataPointer = self.dataChosen[0] + self.simplerName = self.data[self.dataPointer.fileChosen] + + for self.currPlot in range(1,numPlots + 1): + self.findKernalLocs() + if 'Parallel Intensity Plot' in self.dataPointer.graphChosen: + if self.simplerName[self.dataPointer.dataChosenY].type != 1: + if self.dataPointer.dydx == 0: + y = self.simplerName[self.dataPointer.dataChosenY].data + 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.sort() + y = [] + for iter in keys: + y.append(self.simplerName[self.dataPointer.dataChosenY].data[iter]) + y = self.takeDerivativeMult(self.simplerName[self.dataPointer.dataChosenX].data, y) + else: + y = self.takeDerivativeMult(self.simplerName[self.dataPointer.dataChosenX].data, self.simplerName[self.dataPointer.dataChosenY].data) + locMax = 0 + locMin = 99999999999999999999999999999 + for iter in y: + if max(iter) > locMax: + locMax = max(iter) + if locMax > absoluteMax: + absoluteMax = locMax + for iter in y: + if min(iter) < locMin: + locMin = min(iter) + else: + if self.dataPointer.dydx == 0: + y = self.simplerName[self.dataPointer.dataChosenY].data + else: + for iter in range(0, self.dataPointer.dydx): + y = self.takeDerivative(self.simplerName[self.dataPointer.dataChosenX].data, self.simplerName[self.dataPointer.dataChosenY].data) + locMax = max(y) + locMin = min(y) + if locMax > absoluteMax: + absoluteMax = locMax + root.append(Tk.Frame(NEWFRAME, bg = 'white')) + root[-1].pack(side = Tk.TOP, anchor = Tk.W, pady = 10) + plotLabel = Tk.Label(root[-1], text= '\n' + self.dataPointer.dataChosenY + ' vs ' + self.dataPointer.dataChosenX + '\t Current Max: ' + str(locMax) + ' \t New Max: ', bg= 'white') + plotLabel.pack(side = Tk.LEFT) + maxEntry = Tk.Entry(root[-1]) + maxEntry.insert(0, str(locMax)) + maxEntry.pack(side = Tk.LEFT) + plotLabel1 = Tk.Label(root[-1], text = '\t Current Min: ' + str(locMin) + '\t New Min: ', bg= 'white') + plotLabel1.pack(side = Tk.LEFT) + minEntry = Tk.Entry(root[-1]) + minEntry.insert(0, str(locMin)) + minEntry.pack(side = Tk.LEFT, padx = 15) + entry[self.currPlot] = (maxEntry, minEntry) + + cmap = self.plotFormatInfo[self.currPlot].cmap + plotCMap = apply(Tk.OptionMenu, (root[-1], cmap) + tuple(PlotFormatInfo.cmapOptions)) + plotCMap.pack(side = Tk.LEFT, padx = 5) + + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + self.simplerName = self.data[self.dataPointer.fileChosen] + + bottomFrame = Tk.Frame(NEWFRAME, bg = 'white') + bottomFrame.pack(side = Tk.BOTTOM, pady = 15) + note = Tk.Label(bottomFrame, text = '*Leave with default values to reset', bg= 'white') + note.pack(side = Tk.BOTTOM) + bDONE = Tk.Button(bottomFrame, text= 'Submit Changes', bg = 'green', command = lambda: self.collectDataChangeColormaps(entry,NEWFRAME)) + bDONE.pack(side = Tk.BOTTOM) + bSetToGlobalMax = Tk.Button(bottomFrame, text = 'Normalize all Subplots', command = lambda: self.normalizeSubplots(absoluteMax, entry, NEWFRAME)) + bSetToGlobalMax.pack(side = Tk.BOTTOM) + bCancel = Tk.Button(bottomFrame, text = 'Cancel', command = lambda: NEWFRAME.destroy()) + bCancel.pack(side = Tk.BOTTOM) + + def normalizeSubplots(self, absoluteMax, dict, master): + listKeys = list(dict.keys()) + for plotID in listKeys: + self.plotFormatInfo[plotID].norm.vmax = int(absoluteMax) + self.plotFormatInfo[plotID].norm.vmin = 0 + master.destroy() + self.plotData() + + def collectDataChangeColormaps(self, dict, master): + listKeys = list(dict.keys()) + for plotID in listKeys: + maxEntry, minEntry = dict[plotID] + maxValue = maxEntry.get() + if maxValue != '': + self.plotFormatInfo[plotID].norm.vmax = float(maxValue) + minValue = minEntry.get() + if minValue != '': + self.plotFormatInfo[plotID].norm.vmin = float(minValue) + master.destroy() + self.plotData() # Now replot with changes..... + + def takeDerivativeButton(self): + #Variable initializations + NEWFRAME = Tk.Toplevel(self.master, bg = 'white') + self.currPlot = 1 + numPlots = len(self.dataChosen[1]) + 1 + + root = [] + checkButton = {} + vars = {} + #need to scale all plots to the same length + self.dataPointer = self.dataChosen[0] + self.simplerName = self.data[self.dataPointer.fileChosen] + + for self.currPlot in range(1,numPlots + 1): + self.findKernalLocs() + if self.dataPointer.graphChosen == 'Parallel Intensity Plot' or self.dataPointer.graphChosen == 'Line': + root.append(Tk.Frame(NEWFRAME, bg = 'white')) + root[-1].pack(side = Tk.TOP, anchor = Tk.W, pady = 10) + plotLabel = Tk.Label(root[-1], text= '\n' + self.dataPointer.dataChosenY + ' vs ' + self.dataPointer.dataChosenX + '\t \t TakeDiv:', bg= 'white') + plotLabel.pack(side = Tk.LEFT) + vars[str(self.currPlot)] = Tk.IntVar() + checkButton[str(self.currPlot)] = Tk.Checkbutton(root[-1], bg = 'white', variable = vars[str(self.currPlot)]) + checkButton[str(self.currPlot)].pack(side = Tk.LEFT, padx = 10) + + + + + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + self.simplerName = self.data[self.dataPointer.fileChosen] + + bottomFrame = Tk.Frame(NEWFRAME, bg = 'white') + bottomFrame.pack(side = Tk.BOTTOM, pady = 15) + bDONE = Tk.Button(bottomFrame, text= 'Submit Changes', bg = 'green', command = lambda: self.collectDataChangeDiv(vars,NEWFRAME)) + bDONE.pack(side = Tk.BOTTOM) + bCancel = Tk.Button(bottomFrame, text = 'Cancel', command = lambda: NEWFRAME.destroy()) + bCancel.pack(side = Tk.BOTTOM) + + + def collectDataChangeDiv(self, vars,master): + + self.dataPointer = self.dataChosen[0] + self.simplerName = self.data[self.dataPointer.fileChosen] + numPlots = len(self.dataChosen[1]) + 1 + + for self.currPlot in range(1,numPlots + 1): + self.findKernalLocs() + + if vars.has_key(str(self.currPlot)): + if vars[str(self.currPlot)].get() == 1: + self.dataPointer.dydx += 1 + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + self.simplerName = self.data[self.dataPointer.fileChosen] + + master.destroy() + ## Now replot with changes..... + self.plotData() + + def changeBinning(self): + #Variable initializations + NEWFRAME = Tk.Toplevel(self.master, bg = 'white') + self.currPlot = 1 + numPlots = len(self.dataChosen[1]) + 1 + root = Tk.Frame(NEWFRAME, bg = 'white') + root.pack(side = Tk.TOP, anchor = Tk.W, pady = 10) + plotListbox = Tk.Listbox(root, width = 100, height = 6) + plotListbox.grid(row = 0, column = 0, rowspan = 2) + bIncreaseBinningX = Tk.Button(root, text = 'Increase Binning X-Axis', command = lambda: self.collectDataIncreaseXBinning(plotListbox.get('active'))) + bIncreaseBinningX.grid(row = 0, column = 1, padx = 10) + bDecreaseBinningX = Tk.Button(root, text = 'Decrease Binning X-Axis', command = lambda: self.collectDataDecreaseXBinning(plotListbox.get('active'))) + bDecreaseBinningX.grid(row = 0, column = 2, padx = 10) + bDecreaseBinningX = Tk.Button(root, text = 'Remove Binning X-Axis', command = lambda: self.collectDataDecreaseXBinning(plotListbox.get('active'), remove = True)) + bDecreaseBinningX.grid(row = 0, column = 3, padx = 10) + bIncreaseBinningY = Tk.Button(root, text = 'Increase Binning Y-Axis', command = lambda: self.collectDataIncreaseYBinning(plotListbox.get('active'))) + bIncreaseBinningY.grid(row = 1, column = 1, padx = 10) + bDecreaseBinningY = Tk.Button(root, text = 'Decrease Binning Y-Axis', command = lambda: self.collectDataDecreaseYBinning(plotListbox.get('active'))) + bDecreaseBinningY.grid(row = 1, column = 2, padx = 10) + bDecreaseBinningY = Tk.Button(root, text = 'Remove Binning Y-Axis', command = lambda: self.collectDataDecreaseYBinning(plotListbox.get('active'), remove = True)) + bDecreaseBinningY.grid(row = 1, column = 3, padx = 10) + + bCancel = Tk.Button(root, text = 'Finished' , command = lambda: NEWFRAME.destroy()) + bCancel.grid(row = 0, column = 4, padx = 10) + + #need to scale all plots to the same length + self.dataPointer = self.dataChosen[0] + self.simplerName = self.data[self.dataPointer.fileChosen] + + for self.currPlot in range(1,numPlots + 1): + self.findKernalLocs() + if 'Parallel Intensity Plot' in self.dataPointer.graphChosen: + plotListbox.insert(Tk.END,str(self.currPlot) + ' ' + self.dataPointer.dataChosenY + ' vs ' + self.dataPointer.dataChosenX) + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + self.simplerName = self.data[self.dataPointer.fileChosen] + + def collectDataIncreaseXBinning(self, currPlot): + plotToIncrease = int(currPlot[0]) + self.xAxisStepsWilStack[plotToIncrease] = self.xAxisStepsWilStack[plotToIncrease] + 20 + self.plotDataForNewBinning(plotToIncrease) + + def collectDataDecreaseXBinning(self, currPlot, remove = False): + plotToDecrease = int(currPlot[0]) + if (remove == True): + self.xAxisStepsWilStack[plotToDecrease] = 1 + else: + self.xAxisStepsWilStack[plotToDecrease] = self.xAxisStepsWilStack[plotToDecrease] - 5 + self.plotDataForNewBinning(plotToDecrease) + + + def collectDataIncreaseYBinning(self, currPlot): + plotToIncrease = int(currPlot[0]) + if (self.yAxisStepsWilStack[plotToIncrease] == 1): + self.yAxisStepsWilStack[plotToIncrease] = 2 + self.yAxisStepsWilStack[plotToIncrease] = int(float(self.yAxisStepsWilStack[plotToIncrease])*1.50) + print self.yAxisStepsWilStack[plotToIncrease] + self.plotDataForNewBinning(plotToIncrease) + + def collectDataDecreaseYBinning(self, currPlot, remove = False): + plotToDecrease = int(currPlot[0]) + print self.yAxisStepsWilStack[plotToDecrease] + if (remove == True): + self.yAxisStepsWilStack[plotToDecrease] = 1 + else: + self.yAxisStepsWilStack[plotToDecrease] = int(float(self.yAxisStepsWilStack[plotToDecrease])/1.50) + self.plotDataForNewBinning(plotToDecrease) + + + def plotDataForNewBinning(self, plotToChange): + self.currPlot = 1 + numPlots = len(self.dataChosen[1]) + 1 + self.dataPointer = self.dataChosen[0] + self.simplerName = self.data[self.dataPointer.fileChosen] + + for self.currPlot in range(1,numPlots + 1): + if self.currPlot == plotToChange: + self.findKernalLocs() + self.plot = self.figure.add_subplot(numPlots,1,self.currPlot) + if self.simplerName[self.dataPointer.dataChosenY].type == 1: + self.type1Variable(self.simplerName[self.dataPointer.dataChosenX].data , self.dataPointer.dataChosenX, self.simplerName[self.dataPointer.dataChosenY].data, self.dataPointer.dataChosenY, self.simplerName[self.dataPointer.dataChosenY].bool, self.currPlot) + elif self.simplerName[self.dataPointer.dataChosenY].type == 2: + self.type2Variable(self.simplerName[self.dataPointer.dataChosenX].data,self.dataPointer.dataChosenX, self.simplerName[self.dataPointer.dataChosenY].data,self.dataPointer.dataChosenY, self.currPlot) + elif self.simplerName[self.dataPointer.dataChosenY].type == 3: + self.type3Variable(self.simplerName[self.dataPointer.dataChosenX].data,self.dataPointer.dataChosenX,self.simplerName[self.dataPointer.dataChosenY].data,self.dataPointer.dataChosenY, self.currPlot) + else: + self.type4Variable(self.simplerName[self.dataPointer.dataChosenX].data,self.dataPointer.dataChosenX,self.simplerName[self.dataPointer.dataChosenY].data,self.dataPointer.dataChosenY, self.currPlot) + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + self.simplerName = self.data[self.dataPointer.fileChosen] + + + def editLabelsButton(self): + #Variable initializations + NEWFRAME = Tk.Toplevel(self.master, bg = 'white') + self.currPlot = 1 + numPlots = len(self.dataChosen[1]) + 1 + + root = Tk.Frame(NEWFRAME, bg = 'white') + root.pack(side = Tk.TOP, anchor = Tk.W, pady = 10) + entries = {} + #need to scale all plots to the same length + self.dataPointer = self.dataChosen[0] + self.simplerName = self.data[self.dataPointer.fileChosen] + numPlots = len(self.dataChosen[1]) + 1 + currentRow = 0 + + for self.currPlot in range(1,numPlots + 1): + self.plot = self.figure.add_subplot(numPlots,1,self.currPlot) + plotFormat = self.plotFormatInfo[self.currPlot] + self.findKernalLocs() + entries[self.currPlot] = [] + + plotLabel = Tk.Label(root, text= self.dataPointer.dataChosenY + ' vs ' + self.dataPointer.dataChosenX, bg= 'white') + plotLabel.grid(row = currentRow, column = 0, pady = 10, padx = 15, sticky=Tk.W) + plotLabel1 = Tk.Label(root, text = 'Y Axis: ', bg = 'white') + plotLabel1.grid(row = currentRow, column = 1) + entries[self.currPlot].append(Tk.Entry(root)) + entries[self.currPlot][-1].grid(row = currentRow, column = 2, padx = 10) + entries[self.currPlot][-1].insert(0, self.plot.get_ylabel()) + plotLabel2 = Tk.Label(root, text = 'X Axis: ', bg = 'white') + plotLabel2.grid(row = currentRow, column = 3) + 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): + plotLabel3 = Tk.Label(root, text = 'Colorbar: ', bg = 'white') + plotLabel3.grid(row = currentRow, column = 5) + entries[self.currPlot].append(Tk.Entry(root, width = 20)) + entries[self.currPlot][-1].grid(row = currentRow, column = 6, padx = 10) + entries[self.currPlot][-1].insert(0, plotFormat.cbarlabel) + else: + plotLabel3 = Tk.Label(root, text = 'Title: ', bg = 'white') + plotLabel3.grid(row = currentRow, column = 5) + entries[self.currPlot].append(Tk.Entry(root, width = 20)) + entries[self.currPlot][-1].grid(row = currentRow, column = 6, padx = 10) + entries[self.currPlot][-1].insert(0, plotFormat.title) + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + self.simplerName = self.data[self.dataPointer.fileChosen] + + plotFontLabel = Tk.Label(root, text = 'Label \nFont Size: ', bg = 'white') + plotFontLabel.grid(row = currentRow, column = 7) + entries[self.currPlot].append(Tk.Entry(root, width = 5)) + entries[self.currPlot][-1].grid(row = currentRow, column = 8, padx = 10) + entries[self.currPlot][-1].insert(0, plotFormat.labelFontSize) + + plotFontLabel = Tk.Label(root, text = 'X Ticks \nFont Size: ', bg = 'white') + plotFontLabel.grid(row = currentRow, column = 9) + entries[self.currPlot].append(Tk.Entry(root, width = 5)) + entries[self.currPlot][-1].grid(row = currentRow, column = 10, padx = 10) + entries[self.currPlot][-1].insert(0, plotFormat.xticksFontSize) + + plotFontLabel = Tk.Label(root, text = 'Y Ticks \nFont Size: ', bg = 'white') + plotFontLabel.grid(row = currentRow, column = 11) + entries[self.currPlot].append(Tk.Entry(root, width = 5)) + entries[self.currPlot][-1].grid(row = currentRow, column = 12, padx = 10) + entries[self.currPlot][-1].insert(0, plotFormat.yticksFontSize) + + currentRow += 1 + + bottomFrame = Tk.Frame(NEWFRAME, bg = 'white') + bottomFrame.pack(side = Tk.BOTTOM, pady = 15) + bDONE = Tk.Button(bottomFrame, text= 'Submit Changes', bg = 'green', command = lambda: self.collectDataEditLabels(entries,NEWFRAME)) + bDONE.pack(side = Tk.BOTTOM) + bCancel = Tk.Button(bottomFrame, text = 'Cancel', command = lambda: NEWFRAME.destroy()) + bCancel.pack(side = Tk.BOTTOM) + + def collectDataEditLabels(self, entries, master): + + self.dataPointer = self.dataChosen[0] + self.simplerName = self.data[self.dataPointer.fileChosen] + numPlots = len(self.dataChosen[1]) + 1 + + for self.currPlot in range(1,numPlots + 1): + self.findKernalLocs() + self.plot = self.figure.add_subplot(numPlots,1,self.currPlot) + plotFormat = self.plotFormatInfo[self.currPlot] + + labelFontOptionIndex = 3 + if entries[self.currPlot][labelFontOptionIndex].get() != '': + plotFormat.labelFontSize = int(entries[self.currPlot][labelFontOptionIndex].get()) + ticksFontOptionIndex = labelFontOptionIndex + 1 + if entries[self.currPlot][ticksFontOptionIndex].get() != '': + plotFormat.xticksFontSize = int(entries[self.currPlot][ticksFontOptionIndex].get()) + ticksFontOptionIndex = ticksFontOptionIndex + 1 + if entries[self.currPlot][ticksFontOptionIndex].get() != '': + plotFormat.yticksFontSize = int(entries[self.currPlot][ticksFontOptionIndex].get()) + plotFormat.cticksFontSize = plotFormat.yticksFontSize + + plotFormat.ylabel = entries[self.currPlot][0].get() + 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): + plotFormat.cbarlabel = entries[self.currPlot][2].get() + self.colorbars[self.currPlot].set_label(plotFormat.cbarlabel, fontsize=plotFormat.labelFontSize) + else: + plotFormat.title = entries[self.currPlot][2].get() + self.plot.set_title(plotFormat.title) + + # change xtick label fontsize + if (plotFormat.xticksFontSize == 0): + self.plot.set_xticklabels([]) + xtickslabels = self.plot.get_xmajorticklabels() + for n in range(0,len(xtickslabels)): + xtickslabels[n].set_fontsize(plotFormat.xticksFontSize) + + # change ytick label fontsize + ytickslabels = self.plot.get_ymajorticklabels() + for n in range(0,len(ytickslabels)): + ytickslabels[n].set_fontsize(plotFormat.yticksFontSize) + + # change colorbar ticks label fontsize + if self.colorbars.has_key(self.currPlot): + for label in self.colorbars[self.currPlot].ax.get_yticklabels(): + label.set_fontsize(plotFormat.cticksFontSize) + + if self.dataChosen[1] != [] and self.currPlot != numPlots: + self.dataPointer = self.dataChosen[1][self.currPlot - 1] + self.simplerName = self.data[self.dataPointer.fileChosen] + + master.destroy() + ## Now replot with changes..... + self.canvas.show() + + def zoomButton(self): + #Variable initializations + NEWFRAME = Tk.Toplevel(self.master, bg = 'white') + numPlots = len(self.dataChosen[1]) + 1 + + root = Tk.Frame(NEWFRAME, bg = 'white') + root.pack(side = Tk.TOP, anchor = Tk.W, pady = 10) + + numPlots = len(self.dataChosen[1]) + 1 + currentRow = 0 + + # create text label for fields + labelYmin = Tk.Label(root, text = 'Y min: ', bg = 'white') + labelYmin.grid(row = currentRow, column = 1) + labelYmax = Tk.Label(root, text = 'Y max: ', bg = 'white') + labelYmax.grid(row = currentRow, column = 2) + labelXmin = Tk.Label(root, text = 'X min: ', bg = 'white') + labelXmin.grid(row = currentRow, column = 3) + labelXmax = Tk.Label(root, text = 'X max: ', bg = 'white') + labelXmax.grid(row = currentRow, column = 4) + currentRow += 1 + + # for x-axis scaling + xData = self.simplerName[self.dataPointer.dataChosenX].data + xtickStep = xData[1] - xData[0] + + # create entry fields for each plot + entries = {} + for plotID in range(1,numPlots + 1): + plot = self.plotRef[plotID] + plotFormat = self.plotFormatInfo[plotID] + ymin, ymax = plot.get_ylim() + xmin, xmax = plot.get_xlim() + if ('Parallel Intensity Plot' in plotFormat.graphType): + ymin = (ymin - 0.5) + ymax = (ymax + 0.5) + xmin = (xmin + 0.5) * xtickStep + xmax = (xmax - 0.5) * xtickStep + elif ('Bar Chart' in plotFormat.graphType): + xmin = (xmin) * xtickStep + xmax = (xmax) * xtickStep + + plotLabel = Tk.Label(root, text= self.dataPointer.dataChosenY + ' vs ' + self.dataPointer.dataChosenX, bg= 'white') + plotLabel.grid(row = currentRow, column = 0, pady = 10, padx = 15, sticky=Tk.W) + + entries[plotID] = [] + # Y min + entries[plotID].append(Tk.Entry(root, width = 12)) + entries[plotID][-1].grid(row = currentRow, column = 1, padx = 10) + entries[plotID][-1].insert(0, ymin) + # Y max + entries[plotID].append(Tk.Entry(root, width = 12)) + entries[plotID][-1].grid(row = currentRow, column = 2, padx = 10) + entries[plotID][-1].insert(0, ymax) + # X min + entries[plotID].append(Tk.Entry(root, width = 12)) + entries[plotID][-1].grid(row = currentRow, column = 3, padx = 10) + entries[plotID][-1].insert(0, xmin) + # X max + entries[plotID].append(Tk.Entry(root, width = 12)) + entries[plotID][-1].grid(row = currentRow, column = 4, padx = 10) + entries[plotID][-1].insert(0, xmax) + + currentRow += 1 + + bottomFrame = Tk.Frame(NEWFRAME, bg = 'white') + bottomFrame.pack(side = Tk.BOTTOM, pady = 15) + bDONE = Tk.Button(bottomFrame, text = 'Apply Changes', bg = 'green', command = lambda: self.zoomCollect(entries,NEWFRAME)) + bDONE.pack(side = Tk.BOTTOM) + bCancel = Tk.Button(bottomFrame, text = 'Cancel', command = lambda: NEWFRAME.destroy()) + bCancel.pack(side = Tk.BOTTOM) + + def zoomCollect(self, entries, master): + + numPlots = len(self.dataChosen[1]) + 1 + zoomLimit = [ [] for plotID in range(numPlots + 1) ] + + # for xtick generation + xData = self.simplerName[self.dataPointer.dataChosenX].data + xtickStep = xData[1] - xData[0] + xLength = len(xData) + + # obtain entered x and y limit + for plotID in range(1,numPlots + 1): + plot = self.plotRef[plotID] + + ylim = plot.get_ylim() + xlim = plot.get_xlim() + zoomLimit[plotID] = [ylim[0], ylim[1], xlim[0], xlim[1]] + for idx in range(len(zoomLimit[plotID])): + limitStr = entries[plotID][idx].get() + if limitStr != '': + zoomLimit[plotID][idx] = float(limitStr) + + # apply change of x and y limit to each plot + for plotID in range(1,numPlots + 1): + plot = self.plotRef[plotID] + plotFormat = self.plotFormatInfo[plotID] + if ('Parallel Intensity Plot' in plotFormat.graphType): + zoomLimit[plotID][2] /= xtickStep + zoomLimit[plotID][3] /= xtickStep + zoomLimit[plotID][0] += 0.5 + zoomLimit[plotID][1] -= 0.5 + zoomLimit[plotID][2] -= 0.5 + zoomLimit[plotID][3] += 0.5 + elif ('Bar Chart' in plotFormat.graphType): + zoomLimit[plotID][2] /= xtickStep + zoomLimit[plotID][3] /= xtickStep + plot.set_ylim( ymin = zoomLimit[plotID][0], ymax = zoomLimit[plotID][1]) + plot.set_xlim( xmin = zoomLimit[plotID][2], xmax = zoomLimit[plotID][3]) + + # regenerate the xtick labels if the new maximum is exceeds the data length + if ('Parallel Intensity Plot' in plotFormat.graphType or 'Bar Chart' in plotFormat.graphType): + xmaxNew = zoomLimit[plotID][3] + if (xmaxNew > xLength): + xlabelValues = [] + xlabelPos = [] + if (self.xAxisStepsWilStack[plotID] != 1): + xNticks = self.xAxisStepsWilStack[plotID] + for count in range(0, int(xmaxNew + 1), int(xmaxNew + 1) / xNticks): + xlabelValues.append(count * xtickStep) + xlabelPos.append(count) + + plot.set_xticklabels(xlabelValues, rotation = plotFormat.rotation, fontsize = plotFormat.xticksFontSize) + plot.set_xticks(xlabelPos) + + master.destroy() + self.canvas.show() + + +class NaviPlotInfo: + + srcViewSection = 'SourceCodeView' + + def __init__(self): + self.titleFontSize = avconfig.get_value(self.__class__.srcViewSection, 'titleFontSize', 12) + self.ylabelFontSize = avconfig.get_value(self.__class__.srcViewSection, 'yLabelFontSize', 12) + self.xlabelFontSize = avconfig.get_value(self.__class__.srcViewSection, 'xLabelFontSize', 12) + self.yticksFontSize = avconfig.get_value(self.__class__.srcViewSection, 'yTicksFontSize', 10) + self.xticksFontSize = avconfig.get_value(self.__class__.srcViewSection, 'xTicksFontSize', 10) + +class newTextTab: + + srcViewSection = 'SourceCodeView' + + def __init__(self, textTabs, numb, res, TEFILES): + + tabnum = "self.page " + numb + self.page = textTabs.add(tabnum) + self.res = res + self.TEFILES = TEFILES + self.fileChosen = '' + self.typeFileChosen = '' + self.chosenStat1 = '' + self.chosenStat2 = '' + self.key2bool = 0 + self.chosenMethod = '' + self.showLineStatName = 0 + self.first_draw = 1 + self.textFont = ('courier', avconfig.get_value(self.__class__.srcViewSection, 'codeFontSize', 8)) + self.naviPlotInfo = NaviPlotInfo() + + + if self.res == "small": + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 700, width = 1200); + #annotationFrame = Tk.Frame(self.background, bg= 'white', height = 550, width = 400) + #textFrame = Tk.Frame(self.background, bg= 'white', height = 550, width = 300) + elif self.res == 'medium': + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 943, width = 1530); + #annotationFrame = Tk.Frame(self.background, bg = 'white', height = 700, width = 500) + #textFrame = Tk.Frame(self.background, bg= 'white', height = 700, width = 800) + else: + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 943, width = 1530); + #annotationFrame = Tk.Frame(self.background, bg= 'green', height = 864, width = 400) + #textFrame = Tk.Frame(self.background, bg= 'brown', height = 864, width = 900) + self.background.pack() + self.background.pack_propagate(0) + #annotationFrame.pack(side = Tk.LEFT) + #annotationFrame.pack_propagate(0) + #textFrame.pack(side = Tk.RIGHT) + #textFrame.pack_propagate(0) + + chooseFileFrame = Tk.Frame(self.background, bg = 'white') + chooseFileFrame.pack(side = Tk.TOP, anchor = Tk.W, pady = 10, padx = 5) + lChooseFile = Tk.Label(chooseFileFrame, text = 'Choose a Text File to Display: ', font = ("Gills Sans MT", 12), bg = 'white' ) + lChooseFile.pack(side= Tk.LEFT) + + fileListboxOuterFrame = Tk.Frame(chooseFileFrame, bg = 'white') + fileListboxOuterFrame.pack(side = Tk.LEFT) + + cAvailableCudaFilesFrame = Tk.Frame(fileListboxOuterFrame, bg = 'white') + cAvailableCudaFilesFrame.pack(side = Tk.TOP) + cAvailableCudaFilesTitle = Tk.Label(cAvailableCudaFilesFrame, text= 'Cuda C', bg= 'white') + cAvailableCudaFilesTitle.pack(side = Tk.TOP) + self.cAvailableCudaFiles = Tk.Listbox(cAvailableCudaFilesFrame, width = 100, height = 4) + self.cAvailableCudaFiles.pack(side = Tk.BOTTOM) + for keys in TEFILES[0]: + self.cAvailableCudaFiles.insert(Tk.END, keys) + + self.cAvailableCudaFiles.bind("<Double-Button-1>", self.chooseFileCuda) + + lOr = Tk.Label(chooseFileFrame, text = 'OR', font = ("Gills Sans MT", 20), bg= 'white') + lOr.pack(side = Tk.LEFT) + + + cAvailablePTXFilesFrame = Tk.Frame(fileListboxOuterFrame, bg = 'white') + cAvailablePTXFilesFrame.pack(side = Tk.BOTTOM) + cAvailablePTXFilesTitle = Tk.Label(cAvailablePTXFilesFrame, text= 'PTX', bg= 'white') + cAvailablePTXFilesTitle.pack(side = Tk.TOP) + self.cAvailablePTXFiles = Tk.Listbox(cAvailablePTXFilesFrame, width = 100, height = 4) + self.cAvailablePTXFiles.pack(side = Tk.BOTTOM) + for keys in TEFILES[1]: + self.cAvailablePTXFiles.insert(Tk.END, keys) + + self.cAvailablePTXFiles.bind("<Double-Button-1>", self.chooseFilePTX) + + chooseStatsFrame = Tk.Frame(self.background, bg = 'white') + chooseStatsFrame.pack(side = Tk.TOP, anchor = Tk.W, pady = 5, padx =5) + lChooseStats = Tk.Label(chooseStatsFrame, text = "Choose Data to be Shown: ", font = ("Gills Sans MT", 12), bg= 'white') + lChooseStats.pack(side = Tk.LEFT) + availMethodsListboxFrame = Tk.Frame(chooseStatsFrame, bg = 'white') + availMethodsListboxFrame.pack(side = Tk.LEFT) + lavailMethodsTitle = Tk.Label(availMethodsListboxFrame, text = 'Available Functions', bg= 'white') + lavailMethodsTitle.pack(side = Tk.TOP) + self.cAvailableMethodsOnStats = Tk.Listbox(availMethodsListboxFrame, width = 25, height = 10) + self.cAvailableMethodsOnStats.pack(side = Tk.BOTTOM, anchor = Tk.W) + self.cAvailableMethodsOnStats.bind("<Double-Button-1>", self.chooseMethod) + + + availStatsListboxFrame1 = Tk.Frame(chooseStatsFrame, bg = 'white') + availStatsListboxFrame1.pack(side = Tk.LEFT) + lavailStatsTitle1 = Tk.Label(availStatsListboxFrame1, text = 'Available Stats', bg= 'white') + lavailStatsTitle1.pack(side = Tk.TOP) + self.cAvailableStats1 = Tk.Listbox(availStatsListboxFrame1, width = 25, height = 10) + self.cAvailableStats1.pack(side = Tk.BOTTOM, anchor = Tk.W, padx = 5) + self.cAvailableStats1.bind("<Double-Button-1>", self.chooseStats1) + + + availStatsListboxFrame2 = Tk.Frame(chooseStatsFrame, bg = 'white') + availStatsListboxFrame2.pack(side = Tk.LEFT) + lavailStatsTitle2 = Tk.Label(availStatsListboxFrame2, text = 'Available Stats', bg= 'white') + lavailStatsTitle2.pack(side = Tk.TOP) + self.cAvailableStats2 = Tk.Listbox(availStatsListboxFrame2, width = 25, height = 10) + self.cAvailableStats2.pack(side = Tk.BOTTOM, anchor = Tk.W, padx = 5) + self.cAvailableStats2.bind("<Double-Button-1>", self.chooseStats2) + + + + + chosenDataFrame = Tk.Frame(chooseStatsFrame, bg = 'white') + chosenDataFrame.pack(side = Tk.LEFT, padx = 5) + lChosenData = Tk.Label(chosenDataFrame, text = 'Chosen Data', bg = 'white') + lChosenData.pack(side = Tk.TOP) + self.cChosenData = Tk.Text(chosenDataFrame, width = 45, height = 10) + self.cChosenData.pack(side = Tk.TOP) + self.cChosenData.tag_config('complete', background = 'green') + self.cChosenData.tag_config('incomplete', background= 'red') + + fShowDataFrame = Tk.Frame(self.background, bg = 'white') + fShowDataFrame.pack(side = Tk.BOTTOM) + self.bShowData = Tk.Button(fShowDataFrame, text = 'Show Data', bg = 'green',font = ("Gills Sans MT", 14), command = lambda: self.showData(),borderwidth = 5) + self.bShowData.pack(side = Tk.RIGHT, pady = 10) + self.updateChosen() + + + + def statString(self, lineNum, statData): + if (self.showLineStatName == 1): + statName = self.chosenStat1 + if (self.chosenStat2 != ''): + statName += '/' + self.chosenStat2 + finalString = 'Line#: ' + str(lineNum) + ' ' + statName + ': ' + str(statData) + '\n' + else: + finalString = 'Line#: ' + str(lineNum) + ' : ' + str(statData) + '\n' + return finalString + + def showData(self): + self.background.destroy() + if self.res == "small": + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 725, width = 1225); + topFrame = Tk.Frame(self.background, bg = 'white', height = 442, width = 1225) + textFrame = Tk.Frame(topFrame, bg = 'green', height = 442, width = 860) + outStatsFrame = Tk.Frame(topFrame, bg= 'white', height = 442, width = 352) + statsFrame = Tk.Frame(outStatsFrame, bg = 'red', height = 413, width = 352) + bottomFrame = Tk.Frame(self.background, bg= 'purple', height = 284, width = 1225) + toolbarFrame = Tk.Frame(outStatsFrame, bg = 'gray', height = 38, width = 352) + elif self.res == 'medium': + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 943, width = 1530); + topFrame = Tk.Frame(self.background, bg = 'white', height = 575, width = 1530) + textFrame = Tk.Frame(topFrame, bg = 'green', height = 575, width = 1075) + outStatsFrame = Tk.Frame(topFrame, bg= 'white', height = 575, width = 440) + statsFrame = Tk.Frame(outStatsFrame, bg = 'red', height = 537, width = 440) + bottomFrame = Tk.Frame(self.background, bg= 'purple', height = 370, width = 1530) + toolbarFrame = Tk.Frame(outStatsFrame, bg = 'black', height = 38, width = 440) + else: + self.background = Tk.Frame(self.page, bg = "white", borderwidth = 5, relief = Tk.GROOVE, height = 943, width = 1530); + topFrame = Tk.Frame(self.background, bg = 'white', height = 575, width = 1530) + textFrame = Tk.Frame(topFrame, bg = 'green', height = 575, width = 1075) + outStatsFrame = Tk.Frame(topFrame, bg= 'white', height = 575, width = 440) + statsFrame = Tk.Frame(outStatsFrame, bg = 'red', height = 537, width = 440) + bottomFrame = Tk.Frame(self.background, bg= 'purple', height = 370, width = 1530) + toolbarFrame = Tk.Frame(outStatsFrame, bg = 'gray', height = 38, width = 440) + + self.background.pack_propagate(0) + self.background.pack() + topFrame.pack_propagate(0) + topFrame.pack(side = Tk.TOP) + outStatsFrame.pack_propagate(0) + outStatsFrame.pack(side = Tk.LEFT) + statsFrame.pack_propagate(0) + statsFrame.pack(side = Tk.TOP) + toolbarFrame.pack_propagate(0) + toolbarFrame.pack(side = Tk.TOP) + textFrame.pack_propagate(0) + textFrame.pack(side = Tk.LEFT) + bottomFrame.pack_propagate(0) + bottomFrame.pack(side = Tk.TOP) + btoolbox = Tk.Button(toolbarFrame, text = 'Toolbox', command = self.toolboxTopLevel) + btoolbox.pack(side = Tk.RIGHT) + + + + scrollbar = Tk.Scrollbar(statsFrame, orient = Tk.VERTICAL ) + scrollbar.pack(side = Tk.RIGHT, fill = 'y') + self.textbox = Tk.Text(textFrame, height = 36, width = 150,yscrollcommand = scrollbar.set, wrap = Tk.NONE) + self.textbox.pack(side = Tk.TOP, anchor = Tk.W, padx =10, pady = 5) + self.statstextbox = Tk.Text(statsFrame, height = 36, width = 55, yscrollcommand = scrollbar.set, wrap = Tk.NONE) + self.statstextbox.pack(padx = 10, pady = 5) + self.statstextbox.tag_config('normal', background = 'white', font = self.textFont) + self.statstextbox.tag_config('highlight',background = 'lightblue', font = self.textFont) + scrollbar.config(command = self.yview) + self.textbox.tag_config('highlight', background = 'lightblue', font = self.textFont) + self.textbox.tag_config('normal', background = 'white', font = self.textFont) + + + + + + self.file = open(self.fileChosen, 'r') + self.Lines = {} + if self.typeFileChosen == 'cuda': + self.statFile = self.TEFILES[2][self.TEFILES[0].index(self.fileChosen)] + else: + self.statFile = self.TEFILES[2][self.TEFILES[1].index(self.fileChosen) ] + + + self.stats = lexyacctexteditor.textEditorParseMe(self.statFile) + + + if self.typeFileChosen == 'cuda': + self.map = lexyacctexteditor.ptxToCudaMapping(self.TEFILES[1][self.TEFILES[2].index(self.statFile) ] ) + for keys in self.map: + tmp = [] + for ptxLines in self.map[keys]: + try: + tmp.append(self.stats[ptxLines]) + except: + noDataArray = [] + for nStats in variableclasses.lineStatName: + noDataArray.append("Null") + tmp.append(noDataArray) + self.Lines[keys] = variableclasses.cudaLineNo(self.map[keys], tmp) + else: + for keys in self.stats: + self.Lines[keys] = variableclasses.ptxLineNo(self.stats[keys]) + + + + + countLines = 1 + for lines in self.file.readlines(): + self.textbox.insert(Tk.END, str(countLines) + '. ' + lines, ('normal')) + countLines += 1 + countLines -= 1 + self.countLines = countLines + + 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.update() + self.histogram = figure.add_subplot(111) + cid = figure.canvas.mpl_connect('button_press_event',self.onclick) + + self.lineCounts = [0.1] + for count in range(1,countLines): + if count in self.Lines: + if self.typeFileChosen == 'cuda': + if self.chosenMethod == 'Ratio': + self.lineCounts.append(float(self.Lines[count].takeRatioSums(self.chosenStat1, self.chosenStat2))) + elif self.chosenMethod == 'Max': + self.lineCounts.append(int(self.Lines[count].takeMax(self.chosenStat1))) + else: + self.lineCounts.append(int(self.Lines[count].sum(self.chosenStat1))) + else: + if self.chosenMethod == 'Ratio': + self.lineCounts.append(float(self.Lines[count].returnRatio(self.chosenStat1, self.chosenStat2))) + else: + self.lineCounts.append(int(self.Lines[count].returnStat(self.chosenStat1))) + else: + if count == countLines - 1: + self.lineCounts.append(0.1) + else: + self.lineCounts.append(0) + + if (self.first_draw == 1): + self.xlabelfreq = countLines/30 + self.first_draw = 0 + self.countLines = countLines + width = 0.4 + + self.generate_xticklabels() + + self.histogram.set_xlim(0, countLines) + + self.data_x_posn = [x for x in range(0, countLines)] + rects1 = self.histogram.bar(self.data_x_posn, self.lineCounts, width, color = 'blue', edgecolor = 'blue' ) + if self.chosenStat2 == '': + self.histogram.set_title(self.chosenStat1) + else: + self.histogram.set_title(self.chosenStat1 + '/' + self.chosenStat2) + self.histArea.show() + + count = 0 + for iter in (self.lineCounts + [0]): + if count == 0: + pass + else: + self.statstextbox.insert(Tk.END, self.statString(count, iter), ('normal')) + count += 1 + + def yview(self, *args): + apply(self.textbox.yview, args) + apply(self.statstextbox.yview, args) + + def onclick(self, event): + if event.button == 3: + + shiftFactor = float(15.25)/float(self.countLines) + args = ('moveto', str(float(event.xdata)/float(self.countLines) - shiftFactor)) + + countLines = 1 + self.textbox.delete(0.0, Tk.END) + self.file = open(self.fileChosen, 'r') + for lines in self.file.readlines(): + if (countLines < event.xdata - 1) or (countLines > event.xdata + 1): + self.textbox.insert(Tk.END, str(countLines) + '. ' + lines, ('normal')) + else: + self.textbox.insert(Tk.END, str(countLines) + '. ' + lines, ('highlight')) + countLines += 1 + + self.statstextbox.delete(0.0, Tk.END) + countLines = 1 + count = 1 + for iter in (self.lineCounts[1:] + [0]): + if (countLines < event.xdata - 1) or (countLines > event.xdata + 1): + self.statstextbox.insert(Tk.END, self.statString(count, iter), ('normal')) + else: + self.statstextbox.insert(Tk.END, self.statString(count, iter), ('highlight')) + countLines += 1 + count += 1 + + + + apply(self.textbox.yview, args) + apply(self.statstextbox.yview, args) + + def chooseFileCuda(self, *event): + self.fileChosen = self.cAvailableCudaFiles.get('active') + self.typeFileChosen = 'cuda' + self.chosenStat1 = '' + self.chosenStat2 = '' + self.key2bool = 0 + + self.cAvailableStats1.delete(0, Tk.END) + self.cAvailableStats2.delete(0, Tk.END) + self.cAvailableMethodsOnStats.delete(0, Tk.END) + + + self.cAvailableMethodsOnStats.insert(Tk.END, 'Sum') + self.cAvailableMethodsOnStats.insert(Tk.END, 'Max') + self.cAvailableMethodsOnStats.insert(Tk.END, 'Ratio') + + + self.updateChosen() + + + + def chooseFilePTX(self, *event): + self.fileChosen = self.cAvailablePTXFiles.get('active') + self.typeFileChosen = 'ptx' + self.chosenMethod = '' + self.chosenStat1 = '' + self.chosenStat2 = '' + self.key2bool = 0 + + self.cAvailableStats1.delete(0, Tk.END) + self.cAvailableStats2.delete(0, Tk.END) + self.cAvailableMethodsOnStats.delete(0, Tk.END) + + self.cAvailableMethodsOnStats.delete(0, Tk.END) + self.cAvailableMethodsOnStats.insert(Tk.END, 'Stat') + self.cAvailableMethodsOnStats.insert(Tk.END, 'Ratio') + + self.updateChosen() + + + + def chooseStats1(self, *event): + self.chosenStat1 = self.cAvailableStats1.get('active') + self.updateChosen() + + def chooseStats2(self, *event): + self.chosenStat2 = self.cAvailableStats2.get('active') + self.updateChosen() + + + def chooseMethod(self, *event): + self.chosenMethod = self.cAvailableMethodsOnStats.get('active') + + self.key2bool = 0 + self.cAvailableStats1.delete(0, Tk.END) + self.cAvailableStats2.delete(0, Tk.END) + + if self.typeFileChosen == 'cuda': + statFile = self.TEFILES[2][self.TEFILES[0].index(self.fileChosen)] + else: + statFile = self.TEFILES[2][self.TEFILES[1].index(self.fileChosen)] + + variableclasses.loadLineStatName(statFile) + + for statName in variableclasses.lineStatName: + self.cAvailableStats1.insert(Tk.END, statName) + + if self.chosenMethod == 'Ratio': + self.key2bool = 1 + try: + self.cAvailableStats2.delete(0, Tk.END) + except: + pass + + for statName in variableclasses.lineStatName: + self.cAvailableStats2.insert(Tk.END, statName) + + self.updateChosen() + + + + + def updateChosen(self): + self.cChosenData.delete(0.0, Tk.END) + if self.fileChosen == '': + self.cChosenData.insert(Tk.END, 'File: \n', ('incomplete')) + self.cChosenData.insert(Tk.END, 'Type File: \n', ('incomplete')) + else: + self.cChosenData.insert(Tk.END, 'File: ' + self.fileChosen + '\n', ('complete')) + self.cChosenData.insert(Tk.END, 'Type File: ' + self.typeFileChosen + '\n', ('complete')) + if self.chosenStat1 == '': + self.cChosenData.insert(Tk.END, 'Stat1: \n', ('incomplete')) + else: + self.cChosenData.insert(Tk.END, 'Stat1: ' + self.chosenStat1 + '\n', ('complete')) + if self.key2bool == 1: + if self.chosenStat2 == '': + self.cChosenData.insert(Tk.END, 'Stat2: \n', ('incomplete')) + else: + self.cChosenData.insert(Tk.END, 'Stat2: ' + self.chosenStat2 + '\n', ('complete')) + + + + if self.chosenMethod == '': + self.cChosenData.insert(Tk.END, 'Method: \n', ('incomplete')) + else: + self.cChosenData.insert(Tk.END, 'Method: ' + self.chosenMethod + '\n', ('complete')) + + def toolboxTopLevel(self): + NEWFRAME = Tk.Toplevel(self.background, bg = 'white') + changefontsize = Tk.Button(NEWFRAME, text = 'Edit Font Size', command = lambda: ( self.editPlotFontSizes(NEWFRAME))) + changefontsize.pack(side = Tk.LEFT, padx = 5, pady = 5) + changeLabels = Tk.Button(NEWFRAME, text = 'Edit Label Names', command = lambda:( self.editPlotLabels(NEWFRAME))) + changeLabels.pack(side = Tk.LEFT, padx = 5, pady = 5) + changeBinning = Tk.Button(NEWFRAME, text = 'Edit X-Axis Binning', command = lambda: (self.changePlotBinning(NEWFRAME))) + changeBinning.pack(side = Tk.LEFT, padx = 5, pady = 5) + + def editPlotLabels(self, oldframe): + oldframe.destroy() + NEWFRAME = Tk.Toplevel(self.background, bg = 'white') + TopFrame = Tk.Frame(NEWFRAME, bg = 'white') + TopFrame.pack(side = Tk.TOP) + lTitle = Tk.Label(TopFrame, text = 'Title: ', bg= 'white') + lTitle.pack(side = Tk.LEFT, padx = 5, pady = 5) + eTitle = Tk.Entry(TopFrame) + eTitle.insert(0, self.histogram.get_title()) + eTitle.pack(side = Tk.LEFT, padx = 5, pady = 5) + lYAxis = Tk.Label(TopFrame, text = 'Y Axis ', bg = 'white') + lYAxis.pack(side = Tk.LEFT, padx = 5, pady = 5) + eYAxis = Tk.Entry(TopFrame) + eYAxis.insert(0, self.histogram.get_ylabel()) + eYAxis.pack(side = Tk.LEFT, padx = 5, pady = 5) + lXaxis = Tk.Label(TopFrame, text = 'X Axis', bg = 'white') + lXaxis.pack(side = Tk.LEFT, padx = 5, pady = 5) + eXaxis = Tk.Entry(TopFrame) + eXaxis.insert(0, self.histogram.get_xlabel()) + eXaxis.pack(side = Tk.LEFT, padx = 5, pady = 5) + bottomFrame = Tk.Frame(NEWFRAME, bg = 'white') + bottomFrame.pack(side = Tk.BOTTOM, pady = 10) + bCancel = Tk.Button(bottomFrame, text = 'Cancel', command = lambda: (NEWFRAME.destroy())) + bCancel.pack(side = Tk.TOP, pady = 5) + bSubmit = Tk.Button(bottomFrame, text = 'Submit', bg = 'green', command = lambda: self.editPlotLabelsSubmit(NEWFRAME, {'title': eTitle.get(), 'xlabel': eXaxis.get(), 'ylabel': eYAxis.get()})) + bSubmit.pack(side = Tk.TOP, pady = 5) + + def editPlotLabelsSubmit(self, oldFrame, entries): + oldFrame.destroy() + self.histogram.set_title(entries['title'], fontsize = self.naviPlotInfo.titleFontSize) + self.histogram.set_xlabel(entries['xlabel'], fontsize = self.naviPlotInfo.xlabelFontSize) + self.histogram.set_ylabel(entries['ylabel'], fontsize = self.naviPlotInfo.ylabelFontSize) + self.histArea.show() + + + def editPlotFontSizes(self, oldFrame): + oldFrame.destroy() + NEWFRAME = Tk.Toplevel(self.background, bg = 'white') + TopFrame = Tk.Frame(NEWFRAME, bg = 'white') + TopFrame.pack(side = Tk.TOP) + lTitle = Tk.Label(TopFrame, text = 'Title Size: ', bg= 'white') + lTitle.pack(side = Tk.LEFT, padx = 5, pady = 5) + eTitle = Tk.Entry(TopFrame) + eTitle.pack(side = Tk.LEFT, padx = 5, pady = 5) + lYAxis = Tk.Label(TopFrame, text = 'Y Axis Size: ', bg = 'white') + lYAxis.pack(side = Tk.LEFT, padx = 5, pady = 5) + eYAxis = Tk.Entry(TopFrame) + eYAxis.pack(side = Tk.LEFT, padx = 5, pady = 5) + lXaxis = Tk.Label(TopFrame, text = 'X Axis Size: ', bg = 'white') + lXaxis.pack(side = Tk.LEFT, padx = 5, pady = 5) + eXaxis = Tk.Entry(TopFrame) + eXaxis.pack(side = Tk.LEFT, padx = 5, pady = 5) + lYBinning = Tk.Label(TopFrame, text = 'Y Axis Binning Size: ', bg = 'white') + lYBinning.pack(side = Tk.LEFT, padx = 5, pady = 5) + eYBinning = Tk.Entry(TopFrame) + eYBinning.pack(side = Tk.LEFT, padx = 5, pady = 5) + lXBinning = Tk.Label(TopFrame, text = 'X Axis Binning Size: ', bg= 'white') + lXBinning.pack(side = Tk.LEFT, padx = 5, pady = 5) + eXBinning = Tk.Entry(TopFrame) + eXBinning.pack(side = Tk.LEFT, padx = 5, pady = 5) + + + + bottomFrame = Tk.Frame(NEWFRAME, bg = 'white') + bottomFrame.pack(side = Tk.BOTTOM, pady = 10) + bCancel = Tk.Button(bottomFrame, text = 'Cancel', command = lambda: (NEWFRAME.destroy())) + bCancel.pack(side = Tk.TOP, pady = 5) + bSubmit = Tk.Button(bottomFrame, text = 'Submit', bg = 'green', command = lambda: self.editPlotFontSizesSubmit(NEWFRAME, {'title': eTitle.get(), 'xlabel': eXaxis.get(), 'ylabel': eYAxis.get(), 'ybinning' : eYBinning.get(), 'xbinning': eXBinning.get()})) + bSubmit.pack(side = Tk.TOP, pady = 5) + + def editPlotFontSizesSubmit(self, oldframe, entries): + oldframe.destroy() + if entries['title'] != '': + self.histogram.set_title(self.histogram.get_title(), fontsize = int(entries['title'])) + self.naviPlotInfo.titleFontSize = int(entries['title']) + if entries['xlabel'] != '': + self.histogram.set_xlabel(self.histogram.get_xlabel(), fontsize = int(entries['xlabel'])) + self.naviPlotInfo.xlabelFontSize = int(entries['xlabel']) + if entries['ylabel'] != '': + self.histogram.set_ylabel(self.histogram.get_ylabel(), fontsize = int(entries['ylabel'])) + self.naviPlotInfo.ylabelFontSize = int(entries['ylabel']) + if entries['ybinning'] != '': + for label in self.histogram.get_yticklabels(): + label.set_fontsize(int(entries['ybinning'])) + self.naviPlotInfo.yticksFontSize = int(entries['ybinning']) + if entries['xbinning'] != '': + for label in self.histogram.get_xticklabels(): + label.set_fontsize(int(entries['xbinning'])) + self.naviPlotInfo.xticksFontSize = int(entries['xbinning']) + + self.histArea.show() + + def changePlotBinning(self,oldframe): + oldframe.destroy() + master = Tk.Toplevel(self.background, bg = 'white') + topFrame = Tk.Frame(master, bg = 'white') + topFrame.pack(side = Tk.TOP) + bIncrease = Tk.Button(topFrame, text = 'Increase Frequency', command = lambda: self.increaseBinning()) + bIncrease.pack(side = Tk.LEFT, padx = 5, pady = 10) + bDecrease = Tk.Button(topFrame, text = 'Decrease Frequency', command = lambda: self.decreaseBinning()) + bDecrease.pack(side = Tk.LEFT, padx = 5) + bottomFrame = Tk.Frame(master, bg = 'white') + bottomFrame.pack(side = Tk.BOTTOM, pady = 10) + bCancel = Tk.Button(bottomFrame, text = 'Cancel', command = lambda: (master.destroy())) + bCancel.pack(side = Tk.TOP, pady = 5) + bSubmit = Tk.Button(bottomFrame, text = 'Submit', bg = 'green', command = lambda: master.destroy()) + bSubmit.pack(side = Tk.TOP, pady = 5) + + def generate_xticklabels(self, fontsize = -1): + ind = [x * self.xlabelfreq for x in range(0, self.countLines / self.xlabelfreq)] + self.histogram.set_xticks(ind) + + labels = [] + for x in range(0, self.countLines / self.xlabelfreq): + labels.append(x * self.xlabelfreq) + if (fontsize >= 0): + self.histogram.set_xticklabels(labels, fontsize = fontsize) + else: + self.histogram.set_xticklabels(labels) + + def increaseBinning(self): + self.xlabelfreq = int(self.xlabelfreq / 1.5) + if self.xlabelfreq < 1: + self.xlabelfreq = 1 + self.generate_xticklabels() + self.histArea.show() + + def decreaseBinning(self): + self.xlabelfreq = int(self.xlabelfreq * 1.5) + self.generate_xticklabels() + self.histArea.show() + + + + + diff --git a/aerialvision/installscript.py b/aerialvision/installscript.py new file mode 100755 index 0000000..129103c --- /dev/null +++ b/aerialvision/installscript.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python + +# Copyright (C) 2009 by Aaron Ariel, Tor M. Aamodt and the University of British +# Columbia, Vancouver, BC V6T 1Z4, All Rights Reserved. +# +# THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE +# TERMS AND CONDITIONS. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h +# are derived from the CUDA Toolset available from http://www.nvidia.com/cuda +# (property of NVIDIA). The files benchmarks/BlackScholes/ and +# benchmarks/template/ are derived from the CUDA SDK available from +# http://www.nvidia.com/cuda (also property of NVIDIA). The files from +# src/intersim/ are derived from Booksim (a simulator provided with the +# textbook "Principles and Practices of Interconnection Networks" available +# from http://cva.stanford.edu/books/ppin/). As such, those files are bound by +# the corresponding legal terms and conditions set forth separately (original +# copyright notices are left in files from these sources and where we have +# modified a file our copyright notice appears before the original copyright +# notice). +# +# Using this version of GPGPU-Sim requires a complete installation of CUDA +# which is distributed seperately by NVIDIA under separate terms and +# conditions. To use this version of GPGPU-Sim with OpenCL requires a +# recent version of NVIDIA's drivers which support OpenCL. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the University of British Columbia nor the names of +# its contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# 4. This version of GPGPU-SIM is distributed freely for non-commercial use only. +# +# 5. No nonprofit user may place any restrictions on the use of this software, +# including as modified by the user, by any other authorized user. +# +# 6. GPGPU-SIM was developed primarily by Tor M. Aamodt, Wilson W. L. Fung, +# Ali Bakhoda, George L. Yuan, at the University of British Columbia, +# Vancouver, BC V6T 1Z4 + + +import os +# +# make sure you have the following installed before running this script +# (a) python-dev|python-devel +# (b) Tkinter +# (c) tcl-devel +# (d) tk-devel + +os.system('mkdir $HOME/local') +os.system('mkdir $HOME/local/test') +os.system('mkdir $HOME/.gpgpu_sim') +os.system('mkdir $HOME/.gpgpu_sim/aerialvision') + +###Installing Pmw +os.system('echo "XYZ 2"; curl -L -o "$HOME/local/test/Pmw.1.3.2.tar.gz" "http://sourceforge.net/projects/pmw/files/Pmw/Pmw.1.3.2/Pmw.1.3.2.tar.gz/download"') +os.system('echo "XYZ 3"; tar xvfz $HOME/local/test/Pmw.1.3.2.tar.gz -C $HOME/local/test') +os.system('echo "XYZ 4"; cd $HOME/local/test/Pmw.1.3.2/src/; ./setup.py build') +os.system('echo "XYZ 5"; cd $HOME/local/test/Pmw.1.3.2/src/; ./setup.py install --prefix=$HOME/local/test') +os.system('echo "XYZ 6"; rm $HOME/local/test/Pmw.1.3.2.tar.gz') + + +####Installing PLY +os.system('echo "XYZ 7"; curl -L -o "$HOME/local/test/ply-3.2.tar.gz" "http://www.dabeaz.com/ply/ply-3.2.tar.gz"') +os.system('echo "XYZ 8"; tar xvfz $HOME/local/test/ply-3.2.tar.gz -C $HOME/local/test') +os.system('echo "XYZ 9"; cd $HOME/local/test/ply-3.2/; python setup.py build') +os.system('echo "XYZ 10"; export PYTHONPATH=$PYTHONPATH:$HOME/local/test/lib/python2.6/site-packages:$HOME/local/test/lib64/python2.6/site-packages; cd $HOME/local/test/ply-3.2/; python setup.py install --prefix=$HOME/local/test') +os.system('echo "XYZ 11"; rm $HOME/local/test/ply-3.2.tar.gz') + +#####Installing Numpy +os.system('echo "XYZ 12"; curl -L -o "$HOME/local/test/numpy-1.3.0.tar.gz" "http://sourceforge.net/projects/numpy/files/NumPy/1.3.0/numpy-1.3.0.tar.gz/download"') +os.system('echo "XYZ 13"; tar xvfz $HOME/local/test/numpy-1.3.0.tar.gz -C $HOME/local/test') +os.system('echo "XYZ 14"; rm $HOME/local/test/numpy-1.3.0.tar.gz') +os.system('echo "XYZ 15"; python $HOME/local/test/numpy-1.3.0/setup.py build') +os.system('echo "XYZ 16"; python $HOME/local/test/numpy-1.3.0/setup.py install --prefix=$HOME/local/test') + +#####Installing LibPng +os.system('echo "XYZ 17"; curl -L -o "$HOME/local/test/libpng-1.2.37.tar.gz" "http://sourceforge.net/projects/libpng/files/libpng-stable/1.2.37/libpng-1.2.37.tar.gz/download"') +os.system('echo "XYZ 18"; tar xvfz $HOME/local/test/libpng-1.2.37.tar.gz -C $HOME/local/test') +os.system('echo "XYZ 19"; rm $HOME/local/test/libpng-1.2.37.tar.gz') +os.system('echo "XYZ 20"; cd $HOME/local/test/libpng-1.2.37') +os.system('echo "XYZ 21"; cd $HOME/local/test/libpng-1.2.37; ./configure --prefix=$HOME/local/test') +os.system('echo "XYZ 22"; cd $HOME/local/test/libpng-1.2.37; make') +os.system('echo "XYZ 23"; cd $HOME/local/test/libpng-1.2.37; make install') + +####Installing matplotlib +os.system('echo "XYZ 24"; curl -L -o "$HOME/local/test/matplotlib-0.98.5.3.tar.gz" "http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.98.5/matplotlib-0.98.5.3.tar.gz/download"') +os.system('echo "XYZ 25"; tar xvfz $HOME/local/test/matplotlib-0.98.5.3.tar.gz -C $HOME/local/test') +os.system('echo "XYZ 26"; rm $HOME/local/test/matplotlib-0.98.5.3.tar.gz') +os.system('echo "XYZ 27"; export PYTHONPATH=$PYTHONPATH:$HOME/local/test/lib/python2.6/site-packages:$HOME/local/test/lib64/python2.6/site-packages; export CPLUS_INCLUDE_PATH=$HOME/local/test/include; export PKG_CONFIG_PATH=$HOME/local/test/lib/pkgconfig; cd $HOME/local/test/matplotlib-0.98.5.3;python setup.py build') +os.system('echo "XYZ 28"; export PYTHONPATH=$PYTHONPATH:$HOME/local/test/lib/python2.6/site-packages:$HOME/local/test/lib64/python2.6/site-packages; export CPLUS_INCLUDE_PATH=$HOME/local/test/include; export PKG_CONFIG_PATH=$HOME/local/test/lib/pkgconfig; cd $HOME/local/test/matplotlib-0.98.5.3/; python setup.py install --prefix=$HOME/local/test') +os.system('echo "XYZ 29"; echo "Please add the following to your environment (e.g., via your .bashrc file)\n export PYTHONPATH=\$PYTHONPATH:$HOME/local/test/lib/python2.6/site-packages:$HOME/local/test/lib64/python2.6/site-packages\n export CPLUS_INCLUDE_PATH=$HOME/local/test/include\n export PKG_CONFIG_PATH=$HOME/local/test/lib/pkgconfig\n"') diff --git a/aerialvision/lexyacc.py b/aerialvision/lexyacc.py new file mode 100644 index 0000000..3208737 --- /dev/null +++ b/aerialvision/lexyacc.py @@ -0,0 +1,307 @@ +#!/usr/bin/env python + +# Copyright (C) 2009 by Aaron Ariel, Tor M. Aamodt, Andrew Turner, Wilson W. L. +# Fung, Ali Bakhoda and the University of British Columbia, Vancouver, +# BC V6T 1Z4, All Rights Reserved. +# +# THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE +# TERMS AND CONDITIONS. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h +# are derived from the CUDA Toolset available from http://www.nvidia.com/cuda +# (property of NVIDIA). The files benchmarks/BlackScholes/ and +# benchmarks/template/ are derived from the CUDA SDK available from +# http://www.nvidia.com/cuda (also property of NVIDIA). The files from +# src/intersim/ are derived from Booksim (a simulator provided with the +# textbook "Principles and Practices of Interconnection Networks" available +# from http://cva.stanford.edu/books/ppin/). As such, those files are bound by +# the corresponding legal terms and conditions set forth separately (original +# copyright notices are left in files from these sources and where we have +# modified a file our copyright notice appears before the original copyright +# notice). +# +# Using this version of GPGPU-Sim requires a complete installation of CUDA +# which is distributed seperately by NVIDIA under separate terms and +# conditions. To use this version of GPGPU-Sim with OpenCL requires a +# recent version of NVIDIA's drivers which support OpenCL. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the University of British Columbia nor the names of +# its contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. + +import os +import os.path +import sys +sys.path.insert(0,"Lib/site-packages/ply-3.2/ply-3.2") +import ply.lex as lex +import ply.yacc as yacc +import gzip +import variableclasses as vc + +global skipCFLOGParsing +skipCFLOGParsing = 0 + +userSettingPath = os.path.join(os.environ['HOME'], '.gpgpu_sim', 'aerialvision') + + +# Import user-defined statistic variables on top of the default ones built into AerialVision +# Here is the format to specify a new variable: +# <name>, <plot type>, <reset at kernel launch>, <organization>, <data type> +# <plot type> can be one of: scalar, vector, stackedbar, vector2d +# <organization> can be: +# scalar (for scalar plot), +# implicit or index (for vector plot or stackedbar), +# index2d (for vector2d plot) +# <data type> can be: int or float +def import_user_defined_variables(variables): + # attempt to open the user defined variables definition file + try: + file = open(os.path.join(userSettingPath, 'variables.txt'),'r') + except: + print "No variables.txt file found." + return + + #this can be replaced with a proper lex-yacc parser later + for line in file: + try: + # strip out trailing whitespaces and skip comment lines + line = line.strip() + if len(line) == 0: # skip empty line + continue + if line[0] == '#': # skip comment + continue + + # parse the line containing definition of a stat variable + s = line.split(",") + statName = s[0] + statVar = vc.variable('', 1, 0) + statVar.importFromString(line) + + # add parsed stat variable to the searchable map + variables[statName] = statVar + + except Exception, (e): + print "error:",e,", in variables.txt line:",line + +# Parses through a given log file for data +def parseMe(filename): + + #The lexer + + # List of token names. This is always required + tokens = ['WORD', + 'NUMBERSEQUENCE', + ] + + # Regular expression rules for tokens + + + def t_WORD(t): + r'[a-zA-Z_][a-zA-Z0-9_]*' + return t + + def t_NUMBERSEQUENCE(t): + r'([-]{0,1}[0-9]+([\.][0-9]+){0,1}[ ]*)+' + return t + + + t_ignore = '[\t: ]+' + + def t_newline(t): + r'\n+' + t.lexer.lineno += t.value.count("\n") + + def t_error(t): + print "Illegal character '%s'" % t.value[0] + t.lexer.skip(1) + + lex.lex() + + # Creating holder for CFLOG + CFLOG = {} + + # Declaring the properties of supported stats in a single dictionary + # FORMAT: <stat name in GUI>:vc.variable(<Stat Name in Log>, <type>, <reset@kernelstart>, [datatype]) + variables = { + 'shaderInsn':vc.variable('shaderinsncount', 2, 0, 'impVec'), + 'globalInsn':vc.variable('globalinsncount', 1, 1, 'scalar'), + 'globalCycle':vc.variable('globalcyclecount', 1, 1, 'scalar'), + 'shaderWarpDiv':vc.variable('shaderwarpdiv', 2, 0, 'impVec'), + 'L1TextMiss' :vc.variable('lonetexturemiss', 1, 0, 'scalar'), + 'L1ConstMiss':vc.variable('loneconstmiss', 1, 0, 'scalar'), + 'L1ReadMiss' :vc.variable('lonereadmiss', 1, 0, 'scalar'), + 'L1WriteMiss':vc.variable('lonewritemiss', 1, 0, 'scalar'), + 'L2ReadMiss' :vc.variable('ltworeadmiss', 1, 0, 'scalar'), + 'L2WriteMiss':vc.variable('ltwowritemiss', 1, 0, 'scalar'), + 'L2WriteHit' :vc.variable('ltwowritehit', 1, 0, 'scalar'), + 'L2ReadHit' :vc.variable('ltworeadhit', 1, 0, 'scalar'), + 'globalTotInsn':vc.variable('globaltotinsncount', 1,0, 'scalar'), + 'dramCMD' :vc.variable('', 2, 0, 'idxVec'), + 'dramNOP' :vc.variable('', 2, 0, 'idxVec'), + 'dramNACT':vc.variable('', 2, 0, 'idxVec'), + 'dramNPRE':vc.variable('', 2, 0, 'idxVec'), + 'dramNREQ':vc.variable('', 2, 0, 'idxVec'), + 'dramMaxMRQS':vc.variable('', 2, 0, 'idxVec'), + 'dramAveMRQS':vc.variable('', 2, 0, 'idxVec'), + 'dramUtil':vc.variable('', 2, 0, 'idxVec'), + 'dramEff' :vc.variable('', 2, 0, 'idxVec'), + 'globalCompletedThreads':vc.variable('gpucompletedthreads', 1, 1, 'scalar'), + 'globalSentWrites':vc.variable('gpgpunsentwrites', 1, 0, 'scalar'), + 'globalProcessedWrites':vc.variable('gpgpunprocessedwrites', 1, 0, 'scalar'), + 'averagemflatency' :vc.variable('', 1, 0, 'custom'), + 'LDmemlatdist':vc.variable('', 3, 0, 'impVec'), + 'STmemlatdist':vc.variable('', 3, 0, 'impVec'), + 'WarpDivergenceBreakdown':vc.variable('', 3, 0, 'impVec'), + 'dram_writes_per_cycle':vc.variable('', 1, 0, 'scalar', float), + 'dram_reads_per_cycle' :vc.variable('', 1, 0, 'scalar', float), + 'gpu_stall_by_MSHRwb':vc.variable('', 1, 0, 'scalar'), + 'dramglobal_acc_r' :vc.variable('', 4, 0, 'idx2DVec'), + 'dramglobal_acc_w' :vc.variable('', 4, 0, 'idx2DVec'), + 'dramlocal_acc_r' :vc.variable('', 4, 0, 'idx2DVec'), + 'dramlocal_acc_w' :vc.variable('', 4, 0, 'idx2DVec'), + 'dramconst_acc_r' :vc.variable('', 4, 0, 'idx2DVec'), + 'dramtexture_acc_r':vc.variable('', 4, 0, 'idx2DVec'), + 'cacheMissRate_globalL1_all' :vc.variable('cachemissrate_globallocall1_all', 2, 0, 'impVec', float), + 'cacheMissRate_textureL1_all' :vc.variable('cachemissrate_texturel1_all', 2, 0, 'impVec', float), + 'cacheMissRate_constL1_all' :vc.variable('cachemissrate_constl1_all', 2, 0, 'impVec', float), + 'cacheMissRate_globalL1_noMgHt' :vc.variable('cachemissrate_globallocall1_nomght', 2, 0, 'impVec', float), + 'cacheMissRate_textureL1_noMgHt':vc.variable('cachemissrate_texturel1_nomght', 2, 0, 'impVec', float), + 'cacheMissRate_constL1_noMgHt' :vc.variable('cachemissrate_constl1_nomght', 2, 0, 'impVec', float), + 'shdrctacount': vc.variable('shdrctacount', 2, 0, 'impVec'), + 'CFLOG' : CFLOG + } + + # import user defined stat variables from variables.txt - adds on top of the defaults + import_user_defined_variables(variables) + + # generate a lookup table based on the specified name in log file for each stat + stat_lookuptable = {} + for name, var in variables.iteritems(): + if (name == 'CFLOG'): + continue; + if (var.lookup_tag != ''): + stat_lookuptable[var.lookup_tag] = var + else: + stat_lookuptable[name.lower()] = var + + inputData = 'NULL' + + + def p_sentence(p): + '''sentence : WORD NUMBERSEQUENCE''' + #print p[0], p[1],p[2] + num = p[2].split(" ") + for x in list(num): + try: + float(x) + except: + num.remove(x) + + 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] + + stat = stat_lookuptable[lookup_input] + if (stat.type == 1): + for x in num: + stat.data.append(stat.datatype(x)) + + elif (stat.type == 2): + for x in num: + stat.data.append(stat.datatype(x)) + stat.data.append("NULL") + + elif (stat.type == 3): + for x in num: + stat.data.append(stat.datatype(x)) + stat.data.append("NULL") + + elif (stat.type == 4): + for x in num: + stat.data.append(stat.datatype(x)) + stat.data.append("NULL") + + elif (p[1].lower()[0:5] == 'cflog'): + if (skipCFLOGParsing == 1): + return + count = 0 + pc = [] + threadcount = [] + for x in num: + if (count % 2) == 0: + pc.append(int(x)) + else: + threadcount.append(int(x)) + count += 1 + + if (p[1] not in CFLOG): + CFLOG[p[1]] = vc.variable('',2,0) + CFLOG[p[1]].data.append([]) # pc[] + CFLOG[p[1]].data.append([]) # threadcount[] + CFLOG[p[1]].maxPC = 0 + + CFLOG[p[1]].data[0].append(pc) + CFLOG[p[1]].data[1].append(threadcount) + MaxPC = max(pc) + CFLOG[p[1]].maxPC = max(MaxPC, CFLOG[p[1]].maxPC) + + else: + pass + + + + def p_error(p): + if p: + print("Syntax error at '%s'" % p.value) + else: + print("Syntax error at EOF") + + yacc.yacc() + + # detect for gzip'ed log file and gunzip on the fly + if (filename.endswith('.gz')): + file = gzip.open(filename, 'r') + else: + file = open(filename, 'r') + while file: + line = file.readline() + if not line : break + parts = line.split(":") + if (len(parts) != 2): + print("Syntax error at '%s'" % line) + parts[0] = parts[0].strip() + parts[1] = parts[1].strip() + parts = [' '] + parts + p_sentence(parts) + # yacc.parse(line[0:-1]) + file.close() + + + return variables + + + + diff --git a/aerialvision/lexyaccbookmark.py b/aerialvision/lexyaccbookmark.py new file mode 100644 index 0000000..42c6b40 --- /dev/null +++ b/aerialvision/lexyaccbookmark.py @@ -0,0 +1,180 @@ +#!/usr/bin/env python + +# Copyright (C) 2009 by Aaron Ariel, Tor M. Aamodt and the University of British +# Columbia, Vancouver, +# BC V6T 1Z4, All Rights Reserved. +# +# THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE +# TERMS AND CONDITIONS. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h +# are derived from the CUDA Toolset available from http://www.nvidia.com/cuda +# (property of NVIDIA). The files benchmarks/BlackScholes/ and +# benchmarks/template/ are derived from the CUDA SDK available from +# http://www.nvidia.com/cuda (also property of NVIDIA). The files from +# src/intersim/ are derived from Booksim (a simulator provided with the +# textbook "Principles and Practices of Interconnection Networks" available +# from http://cva.stanford.edu/books/ppin/). As such, those files are bound by +# the corresponding legal terms and conditions set forth separately (original +# copyright notices are left in files from these sources and where we have +# modified a file our copyright notice appears before the original copyright +# notice). +# +# Using this version of GPGPU-Sim requires a complete installation of CUDA +# which is distributed seperately by NVIDIA under separate terms and +# conditions. To use this version of GPGPU-Sim with OpenCL requires a +# recent version of NVIDIA's drivers which support OpenCL. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the University of British Columbia nor the names of +# its contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# 4. This version of GPGPU-SIM is distributed freely for non-commercial use only. +# +# 5. No nonprofit user may place any restrictions on the use of this software, +# including as modified by the user, by any other authorized user. +# +# 6. GPGPU-SIM was developed primarily by Tor M. Aamodt, Wilson W. L. Fung, +# Ali Bakhoda, George L. Yuan, at the University of British Columbia, +# Vancouver, BC V6T 1Z4 + + +import os +import sys +import ply.lex as lex +import ply.yacc as yacc +import variableclasses as vc + +def parseMe(): + + + + #The lexer + + # List of token names. This is always required + tokens = ['WORD', + 'EQUALS', + 'VALUE', + 'NUMBER', + 'NOTHING' + ] + + # Regular expression rules for tokens + + def t_VALUE(t): + r'["][a-zA-Z()0-9\._ ]+["]' + return t + + def t_EQUALS(t): + r'[=][ ]' + return t + + def t_WORD(t): + r'[a-zA-Z_]+[ ]' + return t + + def t_NUMBER(t): + r'["][\d]+["]' + return t + + def t_NOTHING(t): + r'["]["]' + return t + + t_ignore = '[\n]+' + + + + def t_error(t): + print "Illegal character '%s'" % t.value[0] + t.lexer.skip(1) + + lex.lex() + + listBookmarks = [] + + + def p_sentence(p): + + '''sentence : WORD EQUALS VALUE + | WORD EQUALS NUMBER + | WORD EQUALS NOTHING''' + p[1] = p[1][0:-1] + p[3] = p[3][1:-1] + + if p[1] == 'title': + listBookmarks[-1].title = p[3] + + elif p[1] == 'description': + listBookmarks[-1].description = p[3] + + elif p[1] == 'dataChosenX': + listBookmarks[-1].dataChosenX.append(p[3]) + + elif p[1] == 'dataChosenY': + listBookmarks[-1].dataChosenY.append(p[3]) + + elif p[1] == 'graphChosen': + listBookmarks[-1].graphChosen.append(p[3]) + + + elif p[1] == 'dydx': + listBookmarks[-1].dydx.append(p[3]) + + elif p[1] == 'START': + listBookmarks.append(vc.bookmark()) + + elif p[1] == 'ReasonForFile': + pass + + else: + print 'An Parsing Error has occurred' + + + + + + + def p_error(p): + if p: + print("Syntax error at '%s'" % p.value) + else: + print("Syntax error at EOF") + + yacc.yacc() + + try: + file = open(os.environ['HOME'] + '/.gpgpu_sim/aerialvision/bookmarks.txt', 'r') + inputData = file.readlines() + except IOError,e: + if e.errno == 2: + inputData = '' + else: + raise e + + for x in inputData: + yacc.parse(x[0:-1]) # ,debug=True) + + return listBookmarks diff --git a/aerialvision/lexyacctexteditor.py b/aerialvision/lexyacctexteditor.py new file mode 100644 index 0000000..757a090 --- /dev/null +++ b/aerialvision/lexyacctexteditor.py @@ -0,0 +1,171 @@ +#!/usr/bin/env python + +# Copyright (C) 2009 by Aaron Ariel, Wilson W. L. Fung +# and the University of British Columbia, Vancouver, +# BC V6T 1Z4, All Rights Reserved. +# +# THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE +# TERMS AND CONDITIONS. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h +# are derived from the CUDA Toolset available from http://www.nvidia.com/cuda +# (property of NVIDIA). The files benchmarks/BlackScholes/ and +# benchmarks/template/ are derived from the CUDA SDK available from +# http://www.nvidia.com/cuda (also property of NVIDIA). The files from +# src/intersim/ are derived from Booksim (a simulator provided with the +# textbook "Principles and Practices of Interconnection Networks" available +# from http://cva.stanford.edu/books/ppin/). As such, those files are bound by +# the corresponding legal terms and conditions set forth separately (original +# copyright notices are left in files from these sources and where we have +# modified a file our copyright notice appears before the original copyright +# notice). +# +# Using this version of GPGPU-Sim requires a complete installation of CUDA +# which is distributed seperately by NVIDIA under separate terms and +# conditions. To use this version of GPGPU-Sim with OpenCL requires a +# recent version of NVIDIA's drivers which support OpenCL. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the University of British Columbia nor the names of +# its contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# 4. This version of GPGPU-SIM is distributed freely for non-commercial use only. +# +# 5. No nonprofit user may place any restrictions on the use of this software, +# including as modified by the user, by any other authorized user. +# +# 6. GPGPU-SIM was developed primarily by Tor M. Aamodt, Wilson W. L. Fung, +# Ali Bakhoda, George L. Yuan, at the University of British Columbia, +# Vancouver, BC V6T 1Z4 + + + +import sys +sys.path.insert(0,"Lib/site-packages/ply-3.2/ply-3.2") +import ply.lex as lex +import ply.yacc as yacc +import variableclasses as vc + +def textEditorParseMe(filename): + + tokens = ['FILENAME', 'NUMBERSEQUENCE'] + + def t_FILENAME(t): + r'[a-zA-Z_/.][a-zA-Z0-9_/.]*\.ptx' + return t + + def t_NUMBERSEQUENCE(t): + r'[0-9 :]+' + return t + + t_ignore = '\t: ' + + def t_newline(t): + r'\n+' + t.lexer.lineno += t.value.count("\n") + + def t_error(t): + print "Illegal character '%s'" % t.value[0] + t.lexer.skip(1) + + lex.lex() + + count = [] + latency = [] + organized = {} + + def p_sentence(p): + '''sentence : FILENAME NUMBERSEQUENCE''' + tmp1 = [] + tmp = p[2].split(':') + for x in tmp: + x = x.strip() + tmp1.append(x) + organized[int(tmp1[0])] = tmp1[1].split(' ') + + + def p_error(p): + if p: + print("Syntax error at '%s'" % p.value) + print p + else: + print("Syntax error at EOF") + + + yacc.yacc() + + file = open(filename, 'r') + while file: + line = file.readline() + if not line : break + if (line.startswith('kernel line :')) : + line = line.strip() + ptxLineStatName = line.split(' ') + ptxLineStatName = ptxLineStatName[3:] + else: + yacc.parse(line[0:-1]) + + + return organized + + +def ptxToCudaMapping(filename): + map = {} + file = open(filename, 'r') + bool = 0 + count = 0 + loc = 0 + while file: + line = file.readline() + if not line: break + try: + map[loc].append(count) + except: + map[loc] = [] + map[loc].append(count) + try: + line.index('.loc') + try: + line.index('.local') + except: + lineList = line.split('\t') + loc = int(lineList[3]) + except: + pass + count += 1 + x = map.keys() + return map + + +#Unit test / playground +def main(): + data = textEditorParseMe(sys.argv[1]) + print data[100] + +if __name__ == "__main__": + main() + + + diff --git a/aerialvision/organizedata.py b/aerialvision/organizedata.py new file mode 100644 index 0000000..87cb9ce --- /dev/null +++ b/aerialvision/organizedata.py @@ -0,0 +1,331 @@ +#!/usr/bin/env python + +# Copyright (C) 2009 by Aaron Ariel, Tor M. Aamodt, Wilson W. L. Fung +# and the University of British Columbia, Vancouver, +# BC V6T 1Z4, All Rights Reserved. +# +# THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE +# TERMS AND CONDITIONS. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h +# are derived from the CUDA Toolset available from http://www.nvidia.com/cuda +# (property of NVIDIA). The files benchmarks/BlackScholes/ and +# benchmarks/template/ are derived from the CUDA SDK available from +# http://www.nvidia.com/cuda (also property of NVIDIA). The files from +# src/intersim/ are derived from Booksim (a simulator provided with the +# textbook "Principles and Practices of Interconnection Networks" available +# from http://cva.stanford.edu/books/ppin/). As such, those files are bound by +# the corresponding legal terms and conditions set forth separately (original +# copyright notices are left in files from these sources and where we have +# modified a file our copyright notice appears before the original copyright +# notice). +# +# Using this version of GPGPU-Sim requires a complete installation of CUDA +# which is distributed seperately by NVIDIA under separate terms and +# conditions. To use this version of GPGPU-Sim with OpenCL requires a +# recent version of NVIDIA's drivers which support OpenCL. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the University of British Columbia nor the names of +# its contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# 4. This version of GPGPU-SIM is distributed freely for non-commercial use only. +# +# 5. No nonprofit user may place any restrictions on the use of this software, +# including as modified by the user, by any other authorized user. +# +# 6. GPGPU-SIM was developed primarily by Tor M. Aamodt, Wilson W. L. Fung, +# Ali Bakhoda, George L. Yuan, at the University of British Columbia, +# Vancouver, BC V6T 1Z4 + +import os +import lexyacctexteditor +import variableclasses as vc + +global convertCFLog2CUDAsrc +global skipCFLog + +convertCFLog2CUDAsrc = 0 +skipCFLog = 1 + +CFLOGInsnInfoFile = '' +CFLOGptxFile = '' +# Obtain the files required to parse CFLOG files from the source code view tab input +def setCFLOGInfoFiles(sourceViewFileList): + + global CFLOGInsnInfoFile + global CFLOGptxFile + + if CFLOGInsnInfoFile == '' and len(sourceViewFileList[2]) > 0: + CFLOGInsnInfoFile = sourceViewFileList[2][0] + if CFLOGptxFile == '' and len(sourceViewFileList[1]) > 0: + CFLOGptxFile = sourceViewFileList[1][0] + + +def organizedata(fileVars): + + organizeFunction = { + 'scalar':OrganizeScalar, # Scalar data + 'impVec':nullOrganizedShader, # Implicit vector data for multiple units (used by Shader Core stats) + 'idxVec':nullOrganizedDram, # Vector data with index (used by DRAM stats) + 'idx2DVec':nullOrganizedDramV2, # Vector data with 2D index (used by DRAM access stats) + 'custom':0 + } + + print "Organizing data into internal format..." + + # Organize globalCycle in advance because it is used as a reference + if ('globalCycle' in fileVars): + statData = fileVars['globalCycle'] + fileVars['globalCycle'].data = organizeFunction[statData.organize](statData.data) + + # Organize other stat data into internal format + for statName, statData in fileVars.iteritems(): + if (statName != 'CFLOG' and statName != 'globalCycle' and statData.organize != 'custom'): + fileVars[statName].data = organizeFunction[statData.organize](statData.data) + + # Custom routines to organize stat data into internal format + if fileVars.has_key('averagemflatency'): + 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'): + ptxFile = CFLOGptxFile + statFile = CFLOGInsnInfoFile + + print "PC Histogram to CUDA Src = %d" % convertCFLog2CUDAsrc + parseCFLOGCUDA = convertCFLog2CUDAsrc + + if parseCFLOGCUDA == 1: + print "Obtaining PTX-to-CUDA Mapping from %s..." % ptxFile + map = lexyacctexteditor.ptxToCudaMapping(ptxFile.rstrip()) + print "Obtaining Program Range from %s..." % statFile + maxStats = max(lexyacctexteditor.textEditorParseMe(statFile.rstrip()).keys()) + + if parseCFLOGCUDA == 1: + newMap = {} + for lines in map: + for ptxLines in map[lines]: + newMap[ptxLines] = lines + + markForDel = [] + for ptxLines in newMap: + if ptxLines > maxStats: + markForDel.append(ptxLines) + for lines in markForDel: + del newMap[lines] + + + + fileVars['CFLOGglobalPTX'] = vc.variable('',2,0) + fileVars['CFLOGglobalCUDA'] = vc.variable('',2,0) + + count = 0 + for iter in fileVars['CFLOG']: + + 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) + if parseCFLOGCUDA == 1: + fileVars[iter + 'CUDA'] = vc.variable('',2,0) + fileVars[iter + 'CUDA'].data = CFLOGOrganizeCuda(fileVars[iter + 'PTX'].data, newMap) + + try: + if count == 0: + fileVars['globalPTX'] = fileVars[iter + 'PTX'] + if parseCFLOGCUDA == 1: + fileVars['globalCUDA'] = fileVars[iter + 'CUDA'] + else: + for rows in range(0, len(fileVars[iter + 'PTX'].data)): + for columns in range(0, len(fileVars[iter + 'PTX'].data[rows])): + fileVars['globalPTX'].data[rows][columns] += fileVars[iter + 'PTX'].data[rows][columns] + if parseCFLOGCUDA == 1: + for rows in range(0, len(fileVars[iter + 'CUDA'].data)): + for columns in range(0, len(fileVars[iter + 'CUDA'].data[rows])): + fileVars['globalCUDA'].data[rows][columns] += fileVars[iter + 'CUDA'].data[rows][columns] + except: + print "Error in generating globalCFLog data" + + count += 1 + del fileVars['CFLOG'] + + + return fileVars + +def OrganizeScalar(data): + organized = [0] + data; + return organized; + +def nullOrganizedShader(nullVar): + #need to organize this array into usable information + count = 0 + organized = [] + + #determining how many shader cores are present + for x in nullVar: + if x != 'NULL': + count += 1 + else: + numPlots = count + break + count = 0 + + #initializing 2D list + for x in range(0, numPlots): + organized.append([]) + + #filling up list appropriately + for x in range(0,(len(nullVar))): + if nullVar[x] == 'NULL': + count=0 + else: + organized[count].append(nullVar[x]) + count += 1 + + for x in range(0,len(organized)): + organized[x] = [0] + organized[x] + + return organized + +def nullOrganizedDram(nullVar): + organized = [[0]] + mem = 1 + for iter in nullVar: + if iter == 'NULL': + mem = 1 + continue + elif mem == 1: + memNum = iter + mem = 0 + continue + else: + try: + organized[memNum].append(iter) + except: + organized.append([0]) + organized[memNum].append(iter) + return organized + +def nullOrganizedDramV2(nullVar): + organized = {} + mem = 1 + for iter in nullVar: + if iter == 'NULL': + mem = 1 + continue + elif mem == 1: + ChipNum = iter + mem += 1 + continue + elif mem == 2: + BankNum = iter + mem = 0 + continue + else: + try: + key = str(ChipNum) + '.' + str(BankNum) + organized[key].append(iter) + except: + organized[key] = [0] + organized[key].append(iter) + + return organized + +def CFLOGOrganizePTX(list, maxPC): + count = 0 + + organizedThreadCount = list[1] + organizedPC = list[0] + + nCycles = len(organizedPC) + final = [[0 for cycle in range(nCycles)] for pc in range(maxPC + 1)] # fill the 2D array with zeros + + for cycle in range(0, nCycles): + pcList = organizedPC[cycle] + threadCountList = organizedThreadCount[cycle] + for n in range(0, len(pcList)): + final[pcList[n]][cycle] = threadCountList[n] + + return final + +def CFLOGOrganizeCuda(list, ptx2cudamap): + #We need to aggregate lines of PTX together + cudaMaxLineNo = max(ptx2cudamap.keys()) + tmp = {} + #need to fill up the final matrix appropriately + + 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): + pass + else: + tmp[cudaline] = [0 for lengthData in range(nSamples)] + + + for cudaline in tmp: + for ptxLines, mapped_cudaline in ptx2cudamap.iteritems(): + if mapped_cudaline == cudaline: + for lengthData in range(nSamples): + tmp[cudaline][lengthData] += list[ptxLines][lengthData] + + + final = [] + for iter in range(min(tmp.keys()),max(tmp.keys())): + if tmp.has_key(iter): + final.append(tmp[iter]) + else: + final.append([0 for lengthData in range(nSamples)]) + + return final + + + #final[lines][lengthData] += 0 + #list[ptxLines][lengthData] += 0 + + #print final + + + + + + + +#def stackedBar(nullVar): +# #Need to initialize organize ar +# organized = [[]] +# for iter in nullVar: +# if iter != 'NULL': +# organized[-1].append(iter) +# else: +# organized.append([]) +# organized.remove([]) +# return organized + + diff --git a/aerialvision/startup.py b/aerialvision/startup.py new file mode 100644 index 0000000..fb3f79b --- /dev/null +++ b/aerialvision/startup.py @@ -0,0 +1,875 @@ +#!/usr/bin/env python + +# Copyright (C) 2009 by Aaron Ariel, Tor M. Aamodt, Andrew Turner, Wilson W. L. +# Fung, Zev Weiss and the University of British Columbia, Vancouver, +# BC V6T 1Z4, All Rights Reserved. +# +# THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE +# TERMS AND CONDITIONS. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h +# are derived from the CUDA Toolset available from http://www.nvidia.com/cuda +# (property of NVIDIA). The files benchmarks/BlackScholes/ and +# benchmarks/template/ are derived from the CUDA SDK available from +# http://www.nvidia.com/cuda (also property of NVIDIA). The files from +# src/intersim/ are derived from Booksim (a simulator provided with the +# textbook "Principles and Practices of Interconnection Networks" available +# from http://cva.stanford.edu/books/ppin/). As such, those files are bound by +# the corresponding legal terms and conditions set forth separately (original +# copyright notices are left in files from these sources and where we have +# modified a file our copyright notice appears before the original copyright +# notice). +# +# Using this version of GPGPU-Sim requires a complete installation of CUDA +# which is distributed seperately by NVIDIA under separate terms and +# conditions. To use this version of GPGPU-Sim with OpenCL requires a +# recent version of NVIDIA's drivers which support OpenCL. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the University of British Columbia nor the names of +# its contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# 4. This version of GPGPU-SIM is distributed freely for non-commercial use only. +# +# 5. No nonprofit user may place any restrictions on the use of this software, +# including as modified by the user, by any other authorized user. +# +# 6. GPGPU-SIM was developed primarily by Tor M. Aamodt, Wilson W. L. Fung, +# Ali Bakhoda, George L. Yuan, at the University of British Columbia, +# Vancouver, BC V6T 1Z4 + + +import sys +import Tkinter as Tk +import Pmw +import lexyacc +import guiclasses +import tkFileDialog as Fd +import organizedata +import os +import os.path + + +global TabsForGraphs +global Filenames +global TabsForText +global SourceCode + +Filenames = [] +TabsForGraphs = [] +vars = {} +TabsForText = [] + +userSettingPath = os.path.join(os.environ['HOME'], '.gpgpu_sim', 'aerialvision') + +def checkEmpty(list): + bool = 0 + try: + if type(list[0]).__name__ == 'list': + for iter in list: + for x in iter: + if ((int(x) != 0) and (x != 'NULL')): + bool = 1 + return bool + else: + for x in list: + if ((x != 'NULL') and (int(x) != 0)): + bool = 1 + return bool + except: + for x in list: + if ((int(x) != 0) and (x != 'NULL')): + bool = 1 + return bool + +def fileInput(cl_files=None): + # The Main Window Stuff + + # Instantiate the window + instance = Tk.Tk(); + instance.title("File Input") + #set the window size + root = Tk.Frame(instance, width = 1100, height = 550, bg = 'white'); + root.pack_propagate(0); + root.pack(); + + #Title at top of Page + rootTitle = Tk.Label(root, text='AerialVision 1.0', font = ("Gill Sans MT", 20, "bold"), bg = 'white'); + rootTitle.pack(side = Tk.TOP); + fileInputTitle = Tk.Label(root, text='Please Fill Out Specifications \n to Get Started', font = ("Gill Sans MT", 15, "bold", "underline"), bg = 'white', width = 400) + fileInputTitle.pack(side = Tk.TOP) + + inputTabs = Pmw.NoteBook(root) + inputTabs.pack(fill = 'both', expand = 'True') + + fileInputOuter = inputTabs.add('File Inputs for Visualizer') + fileInputTextEditor = inputTabs.add('File Inputs for Source Code Viewer') + + + + #################### The visualizer side #############################3 + + + fileInput = Tk.Frame(fileInputOuter, bg = 'white', borderwidth = 5, relief = Tk.GROOVE) + fileInput.pack() + + specChoices = Tk.Frame(fileInput, bg= 'white') + specChoices.pack(side = Tk.TOP, anchor = Tk.W, pady = 30) + addFile = Tk.Frame(specChoices, bg = 'white') + addFile.pack(side = Tk.TOP, anchor = Tk.W) + lAddFile = Tk.Label(addFile, text= "Add Input File: ", bg= 'white') + lAddFile.pack(side = Tk.LEFT) + eAddFile = Tk.Entry(addFile, width= 30, bg = 'white') + eAddFile.pack(side = Tk.LEFT) + bClearEntry = Tk.Button(addFile, text = "Clear", command = (lambda: clearField(eAddFile))) + bClearEntry.pack(side = Tk.LEFT) + + bAddFileSubmit = Tk.Button(addFile, text = "Add File", command = (lambda: addToListbox(cFilesAdded, eAddFile.get(),eAddFile))) + bAddFileSubmit.pack(side = Tk.LEFT) + + + + #Loading the most recent directory visited as the first directory + try: + loadfile = open(os.path.join(userSettingPath, 'recentfiles.txt'), 'r') + tmprecentfile = loadfile.readlines() + recentfile = '' + tmprecentfile = tmprecentfile[len(tmprecentfile) -1] + tmprecentfile = tmprecentfile.split('/') + for iter in range(1,len(tmprecentfile) - 1): + recentfile = recentfile + '/' + tmprecentfile[iter] + except IOError,e: + if e.errno == 2: + # recentfiles.txt does not exist, ignore and use CWD + recentfile = '.' + else: + raise e + + bAddFileBrowse = Tk.Button(addFile, text = "Browse", command = (lambda: eAddFile.insert(0,Fd.askopenfilename(initialdir=recentfile )))) + bAddFileBrowse.pack(side = Tk.LEFT) + bAddFileRecentFiles = Tk.Button(addFile, text = "Recent Files", command = (lambda: loadRecentFile(eAddFile))) + bAddFileRecentFiles.pack(side = Tk.LEFT) + filesAdded = Tk.Frame(specChoices, bg = 'white') + filesAdded.pack(side = Tk.TOP, anchor = Tk.W) + lFilesAdded = Tk.Label(filesAdded, text = "Files Added: ", bg = 'white') + lFilesAdded.pack(side = Tk.LEFT) + cFilesAdded = Tk.Listbox(filesAdded, width = 100, height = 5, bg = 'white') + cFilesAdded.pack(side = Tk.LEFT) + bFilesAddedRem = Tk.Button(filesAdded, text = "Remove", command = (lambda: delFileFromListbox(cFilesAdded))) + bFilesAddedRem.pack(side = Tk.LEFT) + screenRes = Tk.Frame(specChoices, bg = 'white') + screenRes.pack(side = Tk.TOP, anchor= Tk.W) + lScreenResolution = Tk.Label(screenRes, text = "Choose Closest Screen Resolution: ", bg = 'white') + lScreenResolution.pack(side = Tk.LEFT) + Modes = [("1024 x 768", "1"), ("1600 x 1200", "3") ] + num = Tk.StringVar() + num.set("3") + for text, mode in Modes: + bRes = Tk.Radiobutton(specChoices, text = text, variable = num, value = mode, bg = 'white') + bRes.pack(anchor = Tk.W) + + # add files specified on command line to listbox + if cl_files: + #print "adding", cl_files + addListToListbox(cFilesAdded,cl_files) + recentfile = cl_files[len(cl_files) -1] + + # check box to skip parsing of CFLog + skipCFLogVar = Tk.IntVar() + skipCFLogVar.set(1) + cbSkipCFLog = Tk.Checkbutton(specChoices, text = "Skip CFLog parsing", bg = 'white', variable = skipCFLogVar) + cbSkipCFLog.pack(side = Tk.LEFT) + # check box to activate converting CFLog to CUDA source line + cflog2cuda = Tk.IntVar() + cflog2cuda.set(0) + cbCFLog2CUDAsrc = Tk.Checkbutton(specChoices, text = "Convert CFLog to CUDA source line", bg = 'white', variable = cflog2cuda) + cbCFLog2CUDAsrc.pack(side = Tk.LEFT) + + ############### The text editor side ################################## + + fileInputTE = Tk.Frame(fileInputTextEditor, bg = 'white', borderwidth = 5, relief = Tk.GROOVE) + fileInputTE.pack() + + ###### INPUT a Text File ############### + specChoicesTE = Tk.Frame(fileInputTE, bg= 'white') + specChoicesTE.pack(side = Tk.TOP, anchor = Tk.W, pady = 30) + addFileTE = Tk.Frame(specChoicesTE, bg = 'white') + addFileTE.pack(side = Tk.TOP, anchor = Tk.W) + lAddFileTE = Tk.Label(addFileTE, text= "Add CUDA Source Code File: ", bg= 'white') + lAddFileTE.pack(side = Tk.LEFT) + eAddFileTE = Tk.Entry(addFileTE, width= 30, bg = 'white') + eAddFileTE.pack(side = Tk.LEFT) + bClearEntryTE = Tk.Button(addFileTE, text = "Clear", command = (lambda: clearField(eAddFileTE))) + bClearEntryTE.pack(side = Tk.LEFT) + + bAddFileBrowseTE = Tk.Button(addFileTE, text = "Browse", command = (lambda: eAddFileTE.insert(0,Fd.askopenfilename(initialdir=recentfile )))) + bAddFileBrowseTE.pack(side = Tk.LEFT) + bAddFileRecentFilesTE = Tk.Button(addFileTE, text = "Recent Files", command = (lambda: loadRecentFile(eAddFileTE))) + bAddFileRecentFilesTE.pack(side = Tk.LEFT) + + + ### Input Corresponding PTX file ########### + addFileTEPTX = Tk.Frame(specChoicesTE, bg = 'white') + addFileTEPTX.pack(side = Tk.TOP, anchor = Tk.W) + lAddFileTEPTX = Tk.Label(addFileTEPTX, text= "Add Corresponding PTX File: ", bg= 'white') + lAddFileTEPTX.pack(side = Tk.LEFT) + eAddFileTEPTX = Tk.Entry(addFileTEPTX, width= 30, bg = 'white') + eAddFileTEPTX.pack(side = Tk.LEFT) + bClearEntryTEPTX = Tk.Button(addFileTEPTX, text = "Clear", command = (lambda: clearField(eAddFileTEPTX))) + bClearEntryTEPTX.pack(side = Tk.LEFT) + + bAddFileBrowseTEPTX = Tk.Button(addFileTEPTX, text = "Browse", command = (lambda: eAddFileTEPTX.insert(0,Fd.askopenfilename(initialdir=recentfile )))) #"/home/taamodt/fpga_simulation/run/" + bAddFileBrowseTEPTX.pack(side = Tk.LEFT) + bAddFileRecentFilesTEPTX = Tk.Button(addFileTEPTX, text = "Recent Files", command = (lambda: loadRecentFile(eAddFileTEPTX))) + bAddFileRecentFilesTEPTX.pack(side = Tk.LEFT) + + lNote = Tk.Label(addFileTEPTX, text = '*Must include at least PTX and Stat files before pressing the submit button', bg = 'white') + lNote.pack(side = Tk.LEFT) + + + + #### Input the corresponding stat file ################## + addFileTEStat = Tk.Frame(specChoicesTE, bg = 'white') + addFileTEStat.pack(side = Tk.TOP, anchor = Tk.W) + lAddFileTEStat = Tk.Label(addFileTEStat, text= "Add Corresponding Stat File: ", bg= 'white') + lAddFileTEStat.pack(side = Tk.LEFT) + eAddFileTEStat = Tk.Entry(addFileTEStat, width= 30, bg = 'white') + eAddFileTEStat.pack(side = Tk.LEFT) + bClearEntryTEStat = Tk.Button(addFileTEStat, text = "Clear", command = (lambda: clearField(eAddFileTEStat))) + bClearEntryTEStat.pack(side = Tk.LEFT) + + bAddFileBrowseTEStat = Tk.Button(addFileTEStat, text = "Browse", command = (lambda: eAddFileTEStat.insert(0,Fd.askopenfilename(initialdir=recentfile )))) #"/home/taamodt/fpga_simulation/run/" + bAddFileBrowseTEStat.pack(side = Tk.LEFT) + bAddFileRecentFilesTEStat = Tk.Button(addFileTEStat, text = "Recent Files", command = (lambda: loadRecentFile(eAddFileTEStat))) + bAddFileRecentFilesTEStat.pack(side = Tk.LEFT) + + bAddFileSubmitTEStat = Tk.Button(addFileTEStat, text = "Add Files", command = lambda: addToListboxTE([cFilesAddedTE,cFilesAddedTEPTX, cFilesAddedTEStat], + [eAddFileTE,eAddFileTEPTX, eAddFileTEStat]), bg = 'green') + bAddFileSubmitTEStat.pack(side = Tk.LEFT) + + #### Display text file Chosen and stat file Chosen ########### + + #TEXT FILES CHOSEN + filesAddedTE = Tk.Frame(specChoicesTE, bg = 'white') + filesAddedTE.pack(side = Tk.TOP, anchor = Tk.W) + lFilesAddedTE = Tk.Label(filesAddedTE, text = "CUDA Source Code File Added: ", bg = 'white') + lFilesAddedTE.pack(side = Tk.LEFT) + cFilesAddedTE = Tk.Listbox(filesAddedTE, width = 100, height = 3, bg = 'white') + cFilesAddedTE.pack(side = Tk.LEFT) + + #Corresponding PTX File Chosen + filesAddedTEPTX = Tk.Frame(specChoicesTE, bg = 'white') + filesAddedTEPTX.pack(side = Tk.TOP, anchor = Tk.W) + lFilesAddedTEPTX = Tk.Label(filesAddedTEPTX, text = "Corresponding PTX Files Added: ", bg = 'white') + lFilesAddedTEPTX.pack(side = Tk.LEFT) + cFilesAddedTEPTX = Tk.Listbox(filesAddedTEPTX, width = 100, height = 3, bg = 'white') + cFilesAddedTEPTX.pack(side = Tk.LEFT, padx = 15) + bFilesAddedRemTE = Tk.Button(filesAddedTE, text = "Remove", command = (lambda: delFileFromListbox(cFilesAdded))) + bFilesAddedRemTE.pack(side = Tk.LEFT) + + + #CORRESPONDING STAT FILES CHOSEN + filesAddedTEStat = Tk.Frame(specChoicesTE, bg = 'white') + filesAddedTEStat.pack(side = Tk.TOP, anchor = Tk.W) + lFilesAddedTEStat = Tk.Label(filesAddedTEStat, text = "Corresponding Stat Files Added: ", bg = 'white') + lFilesAddedTEStat.pack(side = Tk.LEFT) + cFilesAddedTEStat = Tk.Listbox(filesAddedTEStat, width = 100, height = 3, bg = 'white') + cFilesAddedTEStat.pack(side = Tk.LEFT, padx = 15) + + + bSUBMIT = Tk.Button(root, text = "Submit", font = ("Gill Sans MT", 12, "bold"), width = 10, command = lambda: submitClicked(instance, num.get(), skipCFLogVar.get(), cflog2cuda.get(), [cFilesAddedTE, cFilesAddedTEPTX, cFilesAddedTEStat])) + bSUBMIT.pack(pady = 5) + + + instance.mainloop() + + +def loadRecentFile(entry): + instance = Tk.Toplevel(bg = 'white') + instance.title("Recent Files") + + try: + loadfile = open(os.path.join(userSettingPath, 'recentfiles.txt'), 'r') + recentfiles = loadfile.readlines() + except IOError,e: + if e.errno == 2: + recentfiles = '' + else: + raise e + + recentFileWindow = Tk.Frame(instance, bg = 'white') + 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("<Double-Button-1>", 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) + + tmp = [] + for x in range(len(recentfiles) - 1, 0, -1): + try: + tmp.index(recentfiles[x][0:-1]) + pass + except: + tmp.append(recentfiles[x][0:-1]) + + for x in range(0,len(tmp)): + cRecentFile.insert(Tk.END, tmp[x]) + + belowRecentFileWindow = Tk.Frame(instance, bg = 'white') + belowRecentFileWindow.pack(side = Tk.BOTTOM) + bRecentFile = Tk.Button(belowRecentFileWindow , text = "Submit", command = lambda: recentFileInsert(entry, cRecentFile.get('active'), instance)) + bRecentFile.pack() + bRecentFileCancel = Tk.Button(belowRecentFileWindow , text = 'Cancel', command = (lambda: instance.destroy())) + bRecentFileCancel.pack() + +def recentFileInsert(entry, string, window): + window.destroy() + entry.insert(0, string) + +def clearField(entry): + entry.delete(0,Tk.END) + + +def delFileFromListbox(filesListbox): + for files in Filenames: + if files[-80:] == filesListbox.get('active')[-80:]: + Filenames.remove(files) + filesListbox.delete(Tk.ANCHOR) + + +def addToListboxTE(listbox, entry): + for iter in range(1,len(listbox)): + try: + test = open(entry[iter].get(), 'r') + except: + errorMsg('Could not open file ' + entry[iter].get()) + return + + for iter in range(0,len(listbox)): + listbox[iter].insert(Tk.END, entry[iter].get()) + entry[iter].delete(0,Tk.END) + +def addToListbox(listbox, string, entry): + try: + test = open(string, 'r') + Filenames.append(string) + listbox.insert(Tk.END, string) + entry.delete(0,Tk.END) + except: + errorMsg('Could not open file') + return 0 + +def addListToListbox(listbox,list): + for file in list: + try: + string = os.path.abspath(file) + if os.path.isfile(string): + Filenames.append(string) + listbox.insert(Tk.END, string) + else: + print 'Could not open file: ' + string + except: + print 'Could not open file: ' + file + + +def errorMsg(string): + error = Tk.Toplevel(bg = 'white') + error.title("Error Message") + tError = Tk.Label(error, text = "Error", font = ("Gills Sans MT", 20, "underline", "bold"), bg = "red") + tError.pack(side = Tk.TOP, pady = 20) + lError = Tk.Label(error, text = string, font = ("Gills Sans MT", 15, "bold"), bg = 'white') + lError.pack(pady = 10, padx = 10) + bError = Tk.Button(error, text = "OK", font = ("Times New Roman", 14), command = (lambda: error.destroy())) + bError.pack(pady = 10) + +def submitClicked(instance, num, skipcflog, cflog2cuda, listboxes): + + for iter in range(0, len(listboxes)): + if iter == 0: + TEFiles = listboxes[iter].get(0, Tk.END) + if iter == 1: + TEPTXFiles = listboxes[iter].get(0, Tk.END) + else: + TEStatFiles = listboxes[iter].get(0, Tk.END) + + organizedata.skipCFLog = skipcflog + lexyacc.skipCFLOGParsing = skipcflog + organizedata.convertCFLog2CUDAsrc = cflog2cuda + + start = 0 + if (not os.path.exists(userSettingPath)): + os.makedirs(userSettingPath) + f_recentFiles = open(os.path.join(userSettingPath, 'recentfiles.txt'), 'a') + for files in Filenames: + f_recentFiles.write(files + '\n') + + for files in TEFiles: + f_recentFiles.write(files + '\n') + + for files in TEPTXFiles: + f_recentFiles.write(files + '\n') + + for files in TEStatFiles: + f_recentFiles.write(files + '\n') + + f_recentFiles.close() + if num == '1': + res = 'small' + elif num == '2': + res = 'medium' + else: + res = 'big' + instance.destroy() + 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) + entry.insert(0, 'TabTitle?') + +def remTab(graphTabs): + + graphTabs.delete(Pmw.SELECT) + +def destroy(instance, quit): + quit.destroy() + instance.destroy() + + +def tmpquit(instance): + + quit = Tk.Toplevel(bg = 'white') + quit.title("...") + tQuit = Tk.Label(quit, text = "Quit?", font = ("Gills Sans MT", 20, "underline", "bold"), bg = "white") + tQuit.pack(side = Tk.TOP, pady = 20) + lQuit = Tk.Label(quit, text = "Are you sure you want to quit?", font = ("Gills Sans MT", 15, "bold"), bg = 'white') + lQuit.pack(side = Tk.TOP, pady = 20, padx = 10) + bQuit = Tk.Button(quit, text = "Yes", font = ("Time New Roman", 13), command = (lambda: destroy(instance, quit))) + bQuit.pack(side = Tk.LEFT, anchor = Tk.W, pady = 5, padx = 5) + bNo = Tk.Button(quit, text = "No", font= ("Time New Roman", 13), command = (lambda: quit.destroy())) + bNo.pack(side = Tk.RIGHT, pady = 5, padx = 5) + + +def startup(res, TEFILES): + global vars + # The Main Window Stuff + + # Instantiate the window + instance = Tk.Tk(); + instance.title("AerialVision GPU Graphing Tool") + + + #set the window size + if res == 'small': + root = Tk.Frame(instance, width = 1325, height = 850, bg = 'white'); + elif res == 'medium': + root = Tk.Frame(instance, width = 1700, height = 1100, bg = 'white'); + else: + root = Tk.Frame(instance, width = 1700, height = 1100, bg = 'white'); + root.pack_propagate(0); + root.pack(); + + # User can choose between a text editor or a visualizer + chooseTextVisualizer = Pmw.NoteBook(root) + chooseTextVisualizer.pack(fill= 'both', expand = 'true') + + visualizer = chooseTextVisualizer.add('Visualizer') + textEditor = chooseTextVisualizer.add('Source Code View') + + + #INITIALIZING THE VISUALIZER + + #The top frame for the control panel + # Frame for Control Panel + if res == 'small': + controlPanel = Tk.Frame(visualizer, width=1250, height= 50, bg ="beige", borderwidth = 5, relief = Tk.GROOVE); + elif res == 'medium': + controlPanel = Tk.Frame(visualizer, width=1530, height= 50, bg ="beige", borderwidth = 5, relief = Tk.GROOVE); + else: + controlPanel = Tk.Frame(visualizer, width=1530, height= 50, bg ="beige", borderwidth = 5, relief = Tk.GROOVE); + controlPanel.pack(anchor = Tk.N, pady = 5); + controlPanel.pack_propagate(0) + + # Control Panel Title + controlTitle = Tk.Frame(controlPanel, bg = 'beige') + controlTitle.pack(side = Tk.LEFT) + lControlTitle = Tk.Label(controlTitle, text='Control Panel: ', font = ("Gills Sans MT", 15, "bold"), bg = "beige"); + lControlTitle.pack(side = Tk.LEFT) + + #Number of Tabs Frame) + numbTabs = Tk.Frame(controlPanel, bg = 'beige') + numbTabs.pack(side = Tk.LEFT) + eAddTab = Tk.Entry(numbTabs) + bRemTab = Tk.Button(numbTabs, text = "Rem Tab", command = (lambda: remTab(graphTabs)), bg = 'red') + bRemTab.pack(side=Tk.LEFT) + bAddTab = Tk.Button(numbTabs, text = "Add Tab", command = (lambda: graphAddTab(vars, graphTabs, res, eAddTab))) + bAddTab.pack(side=Tk.LEFT) + eAddTab.pack(side = Tk.LEFT) + eAddTab.insert(0, 'TabTitle?') + bManageFiles = Tk.Button(numbTabs, text = "Manage Files", command = lambda: manageFiles()) + bManageFiles.pack(side = Tk.LEFT) + + #Quit or Open up new Window Frame + quitNew = Tk.Frame(controlPanel, bg = 'beige') + quitNew.pack(side = Tk.RIGHT, padx = 10) + bQuit = Tk.Button(quitNew, text = "Quit", bg = 'red', command = (lambda: tmpquit(instance))) + bQuit.pack(side = Tk.LEFT) + + + #The bottom Frame that contains tabs,graphs,etc... + + + #Instantiating the Main frame + #Frame for Graphing Area + if res == 'small': + graphMainFrame = Tk.Frame(visualizer, width = 1250, height = 750, borderwidth = 5, relief = Tk.GROOVE); + elif res == 'medium': + graphMainFrame = Tk.Frame(visualizer, width = 1615, height = 969, borderwidth = 5, relief = Tk.GROOVE); + else: + graphMainFrame = Tk.Frame(visualizer, width = 1615, height = 969, borderwidth = 5, relief = Tk.GROOVE); + graphMainFrame.pack(pady = 5); + graphMainFrame.pack_propagate(0); + + #Setting up the Tabs + graphTabs = Pmw.NoteBook(graphMainFrame) + graphTabs.pack(fill = 'both', expand = 'true') + #Class newTab will take "graphTabs" which is the widget on top of graphMainFrame and create a new tab + #for every instance of the class + + # Here we extract the available data that can be graphed by the user + + for files in Filenames: + vars[files] = lexyacc.parseMe(files) + + markForDel = {} + + + for files in vars: + markForDel[files] = [] + for variables in vars[files]: + if variables == 'CFLOG': + continue + if variables == 'EXTVARS': + continue + if checkEmpty(vars[files][variables].data) == 0: + markForDel[files].append(variables) + + for files in markForDel: + for variables in markForDel[files]: + del vars[files][variables] + + organizedata.setCFLOGInfoFiles(TEFILES) + for files in Filenames: + vars[files] = organizedata.organizedata(vars[files]) + + graphAddTab(vars, graphTabs, res, eAddTab) + + + # INITIALIZING THE TEXT EDITOR + + if res == 'small': + textControlPanel = Tk.Frame(textEditor, width = 1250, height = 50, bg = 'beige', borderwidth = 5, relief = Tk.GROOVE) + elif res == 'medium': + textControlPanel = Tk.Frame(textEditor, width = 1530, height = 50, bg = 'beige', borderwidth = 5, relief = Tk.GROOVE) + else: + textControlPanel = Tk.Frame(textEditor, width = 1530, height = 50, bg = 'beige', borderwidth = 5, relief = Tk.GROOVE) + + + textControlPanel.pack(anchor = Tk.N, pady = 5) + textControlPanel.pack_propagate(0) + + lTextControlPanel = Tk.Label(textControlPanel, text = 'Control Panel: ', font = ("Gills Sans MT", 15, "bold"), bg = "beige") + lTextControlPanel.pack(side = Tk.LEFT) + bTextRemTab = Tk.Button(textControlPanel, text = 'Rem Tab', command = (lambda: textRemTab(textTabs)), bg = 'red') + bTextRemTab.pack(side = Tk.LEFT) + bTextAddTab = Tk.Button(textControlPanel, text = 'AddTab', command = (lambda: textAddTab(textTabs,res, TEFILES))) + bTextAddTab.pack(side= Tk.LEFT) + bTextManageFiles = Tk.Button(textControlPanel, text = 'Manage Files', command = (lambda: textManageFiles())) + bTextManageFiles.pack(side = Tk.LEFT) + + + + #Quit or Open up new Window Frame + textquitNew = Tk.Frame(textControlPanel, bg = 'beige') + textquitNew.pack(side = Tk.RIGHT, padx = 10) + bTextQuit = Tk.Button(textquitNew, text = "Quit", bg = 'red', command = (lambda: tmpquit(instance))) + bTextQuit.pack(side = Tk.LEFT) + + if res == 'small': + textMainFrame = Tk.Frame(textEditor, width = 1250, height = 750, borderwidth = 5, relief = Tk.GROOVE) + elif res == 'medium': + textMainFrame = Tk.Frame(textEditor, width = 1615, height = 969, borderwidth = 5, relief = Tk.GROOVE) + else: + textMainFrame = Tk.Frame(textEditor, width = 1615, height = 969, borderwidth = 5, relief = Tk.GROOVE) + + textMainFrame.pack(pady = 5) + textMainFrame.pack_propagate(0) + + textTabs = Pmw.NoteBook(textMainFrame) + textTabs.pack(fill = 'both', expand = 'true') + + textAddTab(textTabs, res, TEFILES) + + instance.mainloop() + +def textManageFiles(): + textManageFiles = Tk.Toplevel(bg = 'white') + title = Tk.Label(textManageFiles, text = 'Manage Files', font = ("Gill Sans MT", 15, "bold", "underline"), bg= 'white' ) + title.pack(side = Tk.TOP) + + bottomFrameMaster = Tk.Frame(textManageFiles, bg= 'white') + bottomFrameMaster.pack(side = Tk.TOP, padx = 20, pady = 20) + bottomFrame1 = Tk.Frame(bottomFrameMaster, bg= 'white') + bottomFrame1.pack(side = Tk.LEFT, padx = 20, pady = 20) + bottomFrameOption = Tk.Frame(bottomFrameMaster, bg = 'white') + bottomFrameOption.pack(side = Tk.LEFT) + ltextCurrentFiles = Tk.Label(bottomFrame1, text= 'Current Files: ', bg = 'white') + ltextCurrentFiles.pack(side = Tk.LEFT) + + bottomFrame2 = Tk.Frame(textManageFiles, bg= 'white') + bottomFrame2.pack(side = Tk.TOP, anchor= Tk.W) + ctextCurrentFiles = Tk.Listbox(bottomFrame1, width = 100) + ctextCurrentFiles.pack(side = Tk.LEFT) + lSubmittedChanges= Tk.Label(bottomFrame2, text='Changes: ', bg = 'white') + lSubmittedChanges.pack(side = Tk.LEFT, padx=35, pady =15) + cSubmittedChanges = Tk.Listbox(bottomFrame2, width = 100) + cSubmittedChanges.pack(side = Tk.LEFT,pady = 15) + for files in Filenames: + ctextCurrentFiles.insert(Tk.END, files) + + btextAddFile = Tk.Button(bottomFrameOption, text = 'Add File', command = lambda: textAddFile(bottomFrameMaster,cSubmittedChanges, textManageFiles)) + btextAddFile.pack() + btextRemFile = Tk.Button(bottomFrameOption, text= 'Remove File') + btextRemFile.pack(side = Tk.LEFT) + + + + +def textAddFile(frame, listbox, master): + addFileFrame = Tk.Frame(frame, bg = 'white') + addFileFrame.pack(side = Tk.RIGHT,padx = 15) + + topFrame = Tk.Frame(addFileFrame, bg= 'white') + topFrame.pack(side = Tk.TOP) + bottomFrame = Tk.Frame(addFileFrame, bg = 'white') + bottomFrame.pack(side = Tk.TOP) + + lSourceCode = Tk.Label(topFrame, text = 'Source Code File', bg = 'white') + lSourceCode.pack(side = Tk.LEFT) + + eSourceCode = Tk.Entry(topFrame) + eSourceCode.pack(side = Tk.LEFT) + + bSourceCodeClearEntry = Tk.Button(topFrame, text = "Clear", command = lambda: (eSourceCode.delete(0, Tk.END))) + bSourceCodeClearEntry.pack(side = Tk.LEFT) + + bSourceCodeAddFileBrowse = Tk.Button(topFrame, text = "Browse", command = (lambda: eSourceCode.insert(0,Fd.askopenfilename()))) + bSourceCodeAddFileBrowse.pack(side = Tk.LEFT) + + bSourceCodeAddFileRecentFiles = Tk.Button(topFrame, text = "Recent Files", command = (lambda: loadRecentFile(eAddFile))) + bSourceCodeAddFileRecentFiles.pack(side = Tk.LEFT) + + + + + lStatFile = Tk.Label(bottomFrame, text= 'Corresponding Stat File', bg = 'white') + lStatFile.pack(side = Tk.LEFT) + + eStatFile = Tk.Entry(bottomFrame) + eStatFile.pack(side = Tk.LEFT) + + bSourceCodeClearEntry = Tk.Button(bottomFrame, text = "Clear", command = lambda: (eStatFile.delete(0, Tk.END))) + bSourceCodeClearEntry.pack(side = Tk.LEFT) + + bSourceCodeAddFileBrowse = Tk.Button(bottomFrame, text = "Browse", command = (lambda: eStatFile.insert(0,Fd.askopenfilename()))) + bSourceCodeAddFileBrowse.pack(side = Tk.LEFT) + + bSourceCodeAddFileRecentFiles = Tk.Button(bottomFrame, text = "Recent Files", command = (lambda: loadRecentFile(eAddFile))) + bSourceCodeAddFileRecentFiles.pack(side = Tk.LEFT) + + bSubmit = Tk.Button(addFileFrame, text = "Submit", command = lambda: sourceCodeAddFileSubmit(eSourceCode, eStatFile, listbox, master)) + bSubmit.pack(side = Tk.BOTTOM) + +def sourceCodeAddFileSubmit(eSourceCode, eStatFile, listbox, frame): + source = open(eSourceCode.get(), 'r') + stat = open(eStatFile.get(), 'r') + SourceCode[eSourceCode.get()] = [source, stat] + frame.destroy() + + + + +def textAddTab(textTabs,res, TEFILES): + TabsForText.append(guiclasses.newTextTab(textTabs, str(len(TabsForText) + 1), res, TEFILES)) + +def textRemTab(textTabs): + textTabs.delete(Pmw.SELECT) + + +def manageFiles(): + manageFilesWindow = Tk.Toplevel(bg = 'white') + manageFilesWindow.title("Manage Files") + titleFrame = Tk.Frame(manageFilesWindow, bg = 'white') + titleFrame.pack(side = Tk.TOP) + lTitle = Tk.Label(titleFrame, bg = 'white', text = "Manage Files" ,font = ("Gill Sans MT", 15, "bold", "underline")) + lTitle.pack(side = Tk.LEFT) + bHelp = Tk.Button(titleFrame, text = " ? ") + bHelp.pack(side = Tk.LEFT, padx = 10) + optionsFrame = Tk.Frame(manageFilesWindow, bg = 'white') + optionsFrame.pack(side = Tk.TOP, padx = 20, pady = 20) + lCurrentFiles = Tk.Label(optionsFrame, text = "Current Files: ", bg= 'white') + lCurrentFiles.pack(side = Tk.LEFT) + cCurrentFiles = Tk.Listbox(optionsFrame, width = 100) + cCurrentFiles.pack(side = Tk.LEFT) + for files in Filenames: + cCurrentFiles.insert(Tk.END, files) + buttonsFrame = Tk.Frame(optionsFrame, bg = 'white') + buttonsFrame.pack(side = Tk.LEFT, padx = 20) + bAdd = Tk.Button(buttonsFrame, text = "Add", width = 10, command = lambda: manageFilesAddFile(optionsFrame, cSubmittedChanges)) + bAdd.pack(side = Tk.TOP) + bRemove = Tk.Button(buttonsFrame, text = "Remove", width = 10, command = (lambda: manageFilesDelFile(cCurrentFiles, cSubmittedChanges))) + bRemove.pack(side = Tk.TOP) + bRefresh = Tk.Button(buttonsFrame, text = "Refresh", width = 10, command = (lambda: manageFilesRefreshFile(cCurrentFiles, cSubmittedChanges))) + bRefresh.pack(side = Tk.TOP) + bSubmit = Tk.Button(buttonsFrame, text = "Submit Changes", width = 10, command = lambda: manageFilesSubmit(manageFilesWindow, cSubmittedChanges)) + bSubmit.pack(side = Tk.TOP) + bCancel = Tk.Button(buttonsFrame, text = "Omit Changes", width = 10, command = lambda: manageFilesOmitChanges(manageFilesWindow)) + bCancel.pack(side = Tk.LEFT) + submittedChangesFrame = Tk.Frame(manageFilesWindow, bg= 'white') + submittedChangesFrame.pack(side = Tk.TOP, anchor = Tk.W, pady = 10, padx = 20) + lSubmittedChanges = Tk.Label(submittedChangesFrame, text = "Changes: ", bg= 'white') + lSubmittedChanges.pack(side = Tk.LEFT) + cSubmittedChanges = Tk.Listbox(submittedChangesFrame, width = 100) + cSubmittedChanges.pack(side = Tk.LEFT) + + +def manageFilesOmitChanges(window): + window.destroy() + + +def manageFilesAddFile(frame, listbox): + addFrame = Tk.Frame(frame, bg = 'white') + addFrame.pack(side = Tk.LEFT, anchor = Tk.N) + lTitle = Tk.Label(addFrame, text = "Add a New File", bg = 'white') + lTitle.pack(side = Tk.TOP) + widgetsForAddFrame = Tk.Frame(addFrame, bg = 'white') + widgetsForAddFrame.pack(side = Tk.TOP) + eAddFile = Tk.Entry(widgetsForAddFrame, width= 30, bg = 'white') + eAddFile.pack(side = Tk.LEFT) + bClearEntry = Tk.Button(widgetsForAddFrame, text = "Clear", command = lambda: (clearField(eAddFile))) + bClearEntry.pack(side = Tk.LEFT) + bAddFileSubmit = Tk.Button(widgetsForAddFrame, text = "Submit", command = lambda: manageFilesAddFileSubmit(eAddFile, listbox)) + bAddFileSubmit.pack(side = Tk.LEFT) + bAddFileBrowse = Tk.Button(widgetsForAddFrame, text = "Browse", command = (lambda: eAddFile.insert(0,Fd.askopenfilename()))) + bAddFileBrowse.pack(side = Tk.LEFT) + bAddFileRecentFiles = Tk.Button(widgetsForAddFrame, text = "Recent Files", command = (lambda: loadRecentFile(eAddFile))) + bAddFileRecentFiles.pack(side = Tk.LEFT) + bCancel = Tk.Button(addFrame, text = "<--", command = lambda: addFrame.destroy()) + bCancel.pack(side = Tk.TOP, anchor = Tk.W, pady = 20) + + +def manageFilesAddFileSubmit(entry, listbox): + try: + tmpList = listbox.get(0,Tk.END) + index = tmpList.index('Add File: ' + entry.get()) + errorMsg("This request is already in the queue") + except: + listbox.insert(Tk.END, 'Add File: ' + entry.get()) + + entry.delete(0,Tk.END) + +def manageFilesRefreshFile(filesListbox, listbox): + try: + tmpList = listbox.get(0,Tk.END) + index = tmpList.index("Refresh File: " + filesListbox.get('active')) + errorMsg("This request is already in the queue") + except: + listbox.insert(Tk.END, "Refresh File: " + filesListbox.get('active')) + +def manageFilesDelFile(filesListbox, listbox): + try: + tmpList = listbox.get(0,Tk.END) + index = tmpList.index("Delete File: " + filesListbox.get('active')) + errorMsg("This request is already in the queue") + except: + listbox.insert(Tk.END, "Delete File: " + filesListbox.get('active')) + +def manageFilesSubmit(window, listbox): + global vars + submittedEntries = listbox.get(0, Tk.END) + count = 0 + for entries in submittedEntries: + if entries[0:3] == 'Add': + #try: + test = open(entries[10:], 'r') + Filenames.append(entries[10:]) + vars[entries[10:]] = lexyacc.parseMe(entries[10:]) + + markForDel = [] + for variables in vars[entries[10:]]: + if (variables != 'CFLOG' and checkEmpty(vars[entries[10:]][variables].data) == 0): + markForDel.append(variables) + + for variables in markForDel: + del vars[entries[10:]][variables] + + vars[entries[10:]] = organizedata.organizedata(vars[entries[10:]]) + + + + #except: + # errorMsg('Could not open file' + str(count)) + + elif entries[0:7] == 'Refresh': + del vars[entries[14:]] + vars[entries[14:]] = lexyacc.parseMe(entries[14:]) + + markForDel = [] + for variables in vars[entries[14:]]: + if checkEmpty(vars[entries[14:]][variables].data) == 0: + markForDel.append(variables) + + for variables in markForDel: + del vars[entries[14:]][variables] + + vars[entries[14:]] = organizedata.organizedata(vars[entries[14:]]) + + + elif entries[0:6] == 'Delete': + del vars[entries[13:]] + Filenames.remove(entries[13:]) + + else: + errorMsg('This is a bug... please submit bug report') + + window.destroy() + + + + + diff --git a/aerialvision/variableclasses.py b/aerialvision/variableclasses.py new file mode 100644 index 0000000..cf24c29 --- /dev/null +++ b/aerialvision/variableclasses.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python + +# Copyright (C) 2009 by Aaron Ariel +# and the University of British Columbia, Vancouver, +# BC V6T 1Z4, All Rights Reserved. +# +# THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE +# TERMS AND CONDITIONS. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h +# are derived from the CUDA Toolset available from http://www.nvidia.com/cuda +# (property of NVIDIA). The files benchmarks/BlackScholes/ and +# benchmarks/template/ are derived from the CUDA SDK available from +# http://www.nvidia.com/cuda (also property of NVIDIA). The files from +# src/intersim/ are derived from Booksim (a simulator provided with the +# textbook "Principles and Practices of Interconnection Networks" available +# from http://cva.stanford.edu/books/ppin/). As such, those files are bound by +# the corresponding legal terms and conditions set forth separately (original +# copyright notices are left in files from these sources and where we have +# modified a file our copyright notice appears before the original copyright +# notice). +# +# Using this version of GPGPU-Sim requires a complete installation of CUDA +# which is distributed seperately by NVIDIA under separate terms and +# conditions. To use this version of GPGPU-Sim with OpenCL requires a +# recent version of NVIDIA's drivers which support OpenCL. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the University of British Columbia nor the names of +# its contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# 4. This version of GPGPU-SIM is distributed freely for non-commercial use only. +# +# 5. No nonprofit user may place any restrictions on the use of this software, +# including as modified by the user, by any other authorized user. +# +# 6. GPGPU-SIM was developed primarily by Tor M. Aamodt, Wilson W. L. Fung, +# Ali Bakhoda, George L. Yuan, at the University of British Columbia, +# Vancouver, BC V6T 1Z4 + + +class variable: + + # normal constructor used by internal types + def __init__(self, lookup_tag, type, bool, organize = 'custom', datatype = int): + self.data = [] + self.lookup_tag = lookup_tag # the stat name in the log file (can be different from the GUI) + self.type = type # plot type + self.bool = bool # wheither to expect reset at the end of a kernel + self.organize = organize # how is the data organize in the log, see organizedata.py for options + self.datatype = datatype # int or float or other custom type? + + # import the stat variable setting from a string in variables.txt or a custom header + def importFromString(self, string_spec): + data_type_str = {'int':int, 'float':float} + plot_type_str = {'scalar': 1, 'vector': 2, 'stackedbar': 3, 'vector2d': 4} + organize_str = {'scalar': 'scalar', 'implicit': 'impVec', 'index': 'idxVec', 'index2d': 'idx2DVec'} #skip custom + + try: + # initialize new stat variable with info from input string + self.data = [] + self.lookup_tag = '' + spec = [token.strip().lower() for token in string_spec.split(",")] + self.lookup_tag = spec[0] + self.type = plot_type_str[spec[1]] + self.bool = int(spec[2]) + self.organize = organize_str[spec[3]] + self.datatype = data_type_str[spec[4]] + + # guard against bogus entries + if (self.type == 1): + assert(self.organize == 'scalar') + elif (self.type == 2): + assert(self.organize in ['impVec', 'idxVec']) + elif (self.type == 3): + assert(self.organize in ['impVec', 'idxVec']) + elif (self.type == 4): + assert(self.organize == 'idx2DVec') + except Exception, (e): + print "Error in creating new stat variable from string: %s" % string_spec + raise e + + +class bookmark: + + def __init__(self): + self.title = "" + self.fileChosen = [] + self.dataChosenX = [] + self.dataChosenY = [] + self.graphChosen = [] + self.dydx = [] + self.description = "" + +global lineStatName +lineStatName = ['count', 'latency', 'dram_traffic', 'smem_bk_conflicts', 'smem_warp', + 'gmem_access_generated', 'gmem_warp', 'exposed_latency', 'warp_divergence', + 'warp_issued'] + +def loadLineStatName(filename): + global lineStatName + file = open(filename, 'r') + while file: + line = file.readline() + if not line : break + if (line.startswith('kernel line :')) : + line = line.strip() + ptxLineStatName = line.split(' ') + ptxLineStatName = ptxLineStatName[3:] + lineStatName = ptxLineStatName + break + + +class cudaLineNo: + + debug = 0 + + def __init__(self, ptxLines, ptxStats): + self.stats = {} + self.ptxLines = ptxLines + for statName in lineStatName: + self.stats[statName] = [] + + #Filling up count appropriately + for iter in ptxStats: + for statID in range(0, len(iter)): + if (iter[statID] != "Null"): + self.stats[lineStatName[statID]].append(int(iter[statID])) + + def sum(self,key): + sum = 0 + for iter in self.stats[key]: + sum += int(iter) + return sum + + def takeMax(self,key): + try: + tmp = max(self.stats[key]) + except: + tmp = 0 + if cudaLineNo.debug: + print 'Exception in cudaLineNo.takeMax()', self.stats[key] + return tmp + + def takeRatioSums(self, key1,key2): + tmp1 = float(self.sum(key1)) + tmp2 = float(self.sum(key2)) + + try: + return tmp1/tmp2 + except: + if cudaLineNo.debug: + print tmp1, tmp2 + if tmp2 == 0 and cudaLineNo.debug: + print 'infinite' + return 0 + + + +class ptxLineNo: + + debug = 0 + + def __init__(self, ptxStats): + self.stats = {} + + for statID in range(0, len(ptxStats)): + self.stats[lineStatName[statID]] = int(ptxStats[statID]) + + def returnStat(self, key): + return self.stats[key] + + def returnRatio(self, key1, key2): + tmp1 = float(self.stats[key1]) + tmp2 = float(self.stats[key2]) + try: + return tmp1/tmp2 + except: + if tmp2 == 0 and ptxLineNo.debug: + print 'infinite' + return 0 + + + + + + + + + + |
