[clfft] 01/01: Clean up python code

Jérôme Kieffer kieffer-guest at moszumanska.debian.org
Wed May 20 07:30:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

kieffer-guest pushed a commit to branch master
in repository clfft.

commit abd7828e4a290896aa3c1239f6b547080041b283
Author: Jerome Kieffer <jerome.kieffer at esrf.fr>
Date:   Fri Apr 24 14:18:49 2015 +0200

    Clean up python code
---
 src/scripts/perf/errorHandler.py          |  37 +--
 src/scripts/perf/fftPerformanceTesting.py |  63 ++--
 src/scripts/perf/measurePerformance.py    | 241 +++++++--------
 src/scripts/perf/performanceUtility.py    |  44 +--
 src/scripts/perf/plotPerformance.py       | 467 +++++++++++++++---------------
 5 files changed, 439 insertions(+), 413 deletions(-)

diff --git a/src/scripts/perf/errorHandler.py b/src/scripts/perf/errorHandler.py
index 8471f9d..dd39486 100644
--- a/src/scripts/perf/errorHandler.py
+++ b/src/scripts/perf/errorHandler.py
@@ -1,12 +1,13 @@
+#!/usr/bin/env python2
 # ########################################################################
 # Copyright 2013 Advanced Micro Devices, Inc.
-# 
+#
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# 
+#
 # http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,8 +16,8 @@
 # ########################################################################
 
 #---------------------------------File Note------------------------------------
-#Date: 27 January 2012
-#This file defines all the error code and error handler mechanism
+# Date: 27 January 2012
+# This file defines all the error code and error handler mechanism
 #--------------------------------Global Variables------------------------------
 
 UINS_CAT = 100
@@ -24,12 +25,12 @@ WIN_REG_SEARCH_FAIL = 101
 UNIMPL_APP = 200
 SYS_ERR = 300
 TIME_OUT = 400
-DIM_INCO_FILE_FMT = 500 #incorrect file format for dimension
-DIM_FILE_VAL_INCO = 501 #Value coming from dimension file is incorrect
+DIM_INCO_FILE_FMT = 500  # incorrect file format for dimension
+DIM_FILE_VAL_INCO = 501  # Value coming from dimension file is incorrect
 
-#__errorTable : Defines all the errors in the system. Add a new error code and
-#               error message here 
-"""Error table is defined as private to this module""" 
+# __errorTable : Defines all the errors in the system. Add a new error code and
+#               error message here
+"""Error table is defined as private to this module"""
 errorTable = {
               UINS_CAT: 'Application is not able to find the installed catalyst',
               WIN_REG_SEARCH_FAIL: 'Windows Registry search for catalysts version is unsuccessful',
@@ -41,25 +42,25 @@ errorTable = {
               }
 
 #--------------------------------Class Definitions-----------------------------
-class TimeoutException(Exception): 
+class TimeoutException(Exception):
     pass
 
 """Base class for handling all the application generated exception"""
 class ApplicationException(Exception):
-    
-    def __init__(self, fileName, errno, msg = ""):
+
+    def __init__(self, fileName, errno, msg=""):
         self.fileName = fileName
         self.errno = errno
         self.mess = errorTable[errno] + msg
-        self.message = 'Application ERROR:'+repr(self.fileName+'-'+str(self.errno)+'-'+self.mess)
-        
+        self.message = 'Application ERROR:' + repr(self.fileName + '-' + str(self.errno) + '-' + self.mess)
+
     def __str__(self):
-        return repr(self.fileName+'-'+str(self.errno)+'-'+self.mess)
-    
+        return repr(self.fileName + '-' + str(self.errno) + '-' + self.mess)
+
 
 #--------------------------------Global Function-------------------------------
 if __name__ == '__main__':
-    #print errorTable
+    # print errorTable
     try:
         raise ApplicationException('errorHandler', SYS_ERR)
 
diff --git a/src/scripts/perf/fftPerformanceTesting.py b/src/scripts/perf/fftPerformanceTesting.py
index 2d1df69..b638d5b 100644
--- a/src/scripts/perf/fftPerformanceTesting.py
+++ b/src/scripts/perf/fftPerformanceTesting.py
@@ -1,12 +1,13 @@
+#!/usr/bin/env python2
 # ########################################################################
 # Copyright 2013 Advanced Micro Devices, Inc.
-# 
+#
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# 
+#
 # http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,7 +16,7 @@
 # ########################################################################
 
 import itertools
-import re#gex
+import re  # gex
 import subprocess
 import os
 import sys
@@ -25,10 +26,11 @@ from datetime import datetime
 
 tableHeader = 'lengthx,lengthy,lengthz,batch,device,inlay,outlay,place,precision,label,GFLOPS'
 
+
 class TestCombination:
     def __init__(self,
                  lengthx, lengthy, lengthz, batchsize,
-                 device, inlayout, outlayout, placeness, precision,                 
+                 device, inlayout, outlayout, placeness, precision,
                  label):
         self.x = lengthx
         self.y = lengthy
@@ -44,6 +46,7 @@ class TestCombination:
     def __str__(self):
         return self.x + 'x' + self.y + 'x' + self.z + ':' + self.batchsize + ', ' + self.device + ', ' + self.inlayout + '/' + self.outlayout + ', ' + self.placeness + ', ' + self.precision + ' -- ' + self.label
 
+
 class GraphPoint:
     def __init__(self,
                  lengthx, lengthy, lengthz, batchsize,
@@ -63,6 +66,7 @@ class GraphPoint:
         # ALL members must be represented here (x, y, z, batch, device, label, etc)
         return self.x + 'x' + self.y + 'x' + self.z + ':' + self.batchsize + ', ' + self.precision + ' precision, ' + self.device + ', -- ' + self.label + '; ' + self.gflops
 
+
 class TableRow:
     # parameters = class TestCombination instantiation
     def __init__(self, parameters, gflops):
@@ -72,7 +76,8 @@ class TableRow:
     def __str__(self):
         return self.parameters.__str__() + '; ' + self.gflops
 
-def transformDimension(x,y,z):
+
+def transformDimension(x, y, z):
     if int(z) != 1:
         return 3
     elif int(y) != 1:
@@ -80,6 +85,7 @@ def transformDimension(x,y,z):
     elif int(x) != 1:
         return 1
 
+
 def executable(library):
     if type(library) != str:
         print 'ERROR: expected library name to be a string'
@@ -93,7 +99,8 @@ def executable(library):
         if sys.platform == 'win32':
             exe = 'Client.exe'
         elif sys.platform == 'linux2':
-            exe = 'Client'
+            exe = "/usr/bin/clFFT-client"
+            # 'Client'
     else:
         print 'ERROR: unknown library -- cannot determine executable name'
         quit()
@@ -105,15 +112,17 @@ def executable(library):
 
     return exe
 
+
 def max_mem_available_in_bytes(exe, device):
     arguments = [exe, '-i', device]
-    
+
     deviceInfo = subprocess.check_output(arguments, stderr=subprocess.STDOUT).split(os.linesep)
-    deviceInfo = itertools.ifilter( lambda x: x.count('MAX_MEM_ALLOC_SIZE'), deviceInfo)
+    deviceInfo = itertools.ifilter(lambda x: x.count('MAX_MEM_ALLOC_SIZE'), deviceInfo)
     deviceInfo = list(itertools.islice(deviceInfo, None))
     maxMemoryAvailable = re.search('\d+', deviceInfo[0])
     return int(maxMemoryAvailable.group(0))
 
+
 def max_problem_size(exe, layout, precision, device):
     if layout == 'ci' or layout == 'cp':
         numbers_in_one_datapoint = 2
@@ -133,23 +142,26 @@ def max_problem_size(exe, layout, precision, device):
     max_problem_size = max_problem_size / 16
     return max_problem_size
 
+
 def maxBatchSize(lengthx, lengthy, lengthz, layout, precision, exe, device):
     problemSize = int(lengthx) * int(lengthy) * int(lengthz)
     maxBatchSize = max_problem_size(exe, layout, precision, device) / problemSize
-    if int(lengthx) == pow(2,16) or int(lengthx) == pow(2,17):
+    if int(lengthx) == pow(2, 16) or int(lengthx) == pow(2, 17):
         # special cases in the kernel. extra padding is added in, so we need to shrink the batch size to accommodate
-        return str(maxBatchSize/2)
+        return str(maxBatchSize / 2)
     else:
         return str(maxBatchSize)
 
+
 def create_ini_file_if_requested(args):
     if args.createIniFilename:
         for x in vars(args):
-            if (type(getattr(args,x)) != file) and x.count('File') == 0:
+            if (type(getattr(args, x)) != file) and x.count('File') == 0:
                 args.createIniFilename.write('--' + x + os.linesep)
-                args.createIniFilename.write(str(getattr(args,x)) + os.linesep)
+                args.createIniFilename.write(str(getattr(args, x)) + os.linesep)
         quit()
-    
+
+
 def load_ini_file_if_requested(args, parser):
     if args.useIniFilename:
         argument_list = args.useIniFilename.readlines()
@@ -157,9 +169,11 @@ def load_ini_file_if_requested(args, parser):
         args = parser.parse_args(argument_list)
     return args
 
+
 def is_numeric_type(x):
     return type(x) == int or type(x) == long or type(x) == float
 
+
 def split_up_comma_delimited_lists(args):
     for x in vars(args):
         attr = getattr(args, x)
@@ -171,6 +185,7 @@ def split_up_comma_delimited_lists(args):
             setattr(args, x, attr.split(','))
     return args
 
+
 class Range:
     def __init__(self, ranges, defaultStep='+1'):
         # we might be passed in a single value or a list of strings
@@ -188,7 +203,7 @@ class Range:
                 elif thisRange == 'max':
                     self.expanded = self.expanded + ['max']
                 else:
-                #elif thisRange != 'max':
+                # elif thisRange != 'max':
                     if thisRange.count(':'):
                         self._stepAmount = thisRange.split(':')[1]
                     else:
@@ -231,9 +246,11 @@ class Range:
     def _add(self):
         self.current = self.current + self._stepAmount
 
+
 def expand_range(a_range):
     return Range(a_range).expanded
 
+
 def decode_parameter_problemsize(problemsize):
     if not problemsize.count(None):
         i = 0
@@ -242,14 +259,16 @@ def decode_parameter_problemsize(problemsize):
             j = 0
             while j < len(problemsize[i]):
                 problemsize[i][j] = problemsize[i][j].split('x')
-                j = j+1
-            i = i+1
+                j = j + 1
+            i = i + 1
 
     return problemsize
 
+
 def gemm_table_header():
     return 'm,n,k,lda,ldb,ldc,alpha,beta,order,transa,transb,function,device,library,label,GFLOPS'
 
+
 class GemmTestCombination:
     def __init__(self,
                  sizem, sizen, sizek, lda, ldb, ldc,
@@ -274,6 +293,7 @@ class GemmTestCombination:
     def __str__(self):
         return self.sizem + 'x' + self.sizen + 'x' + self.sizek + ':' + self.lda + 'x' + self.ldb + 'x' + self.ldc + ', ' + self.device + ', ' + self.function + ', ' + self.library + ', alpha(' + self.alpha + '), beta(' + self.beta + '), order(' + self.order + '), transa(' + self.transa + '), transb(' + self.transb + ') -- ' + self.label
 
+
 class GemmGraphPoint:
     def __init__(self,
                  sizem, sizen, sizek,
@@ -300,16 +320,17 @@ class GemmGraphPoint:
         # ALL members must be represented here (x, y, z, batch, device, label, etc)
         return self.sizem + 'x' + self.sizen + 'x' + self.sizek + ':' + self.device + ', ' + self.function + ', ' + self.library + ', order(' + self.order + '), transa(' + self.transa + '), transb(' + self.transb + ') -- ' + self.label + '; ' + self.gflops + ' gflops'
 
-def open_file( filename ):
+
+def open_file(filename):
     if type(filename) == list:
         filename = filename[0]
     if filename == None:
-        filename = 'results' + datetime.now().isoformat().replace(':','.') + '.txt'
+        filename = 'results' + datetime.now().isoformat().replace(':', '.') + '.txt'
     else:
         if os.path.isfile(filename):
             oldname = filename
-            filename = filename + datetime.now().isoformat().replace(':','.')
+            filename = filename + datetime.now().isoformat().replace(':', '.')
             message = 'A file with the name ' + oldname + ' already exists. Changing filename to ' + filename
             print message
-    
+
     return open(filename, 'w')
diff --git a/src/scripts/perf/measurePerformance.py b/src/scripts/perf/measurePerformance.py
index c0cbc6a..d754a68 100644
--- a/src/scripts/perf/measurePerformance.py
+++ b/src/scripts/perf/measurePerformance.py
@@ -1,12 +1,13 @@
+#!/usr/bin/env python2
 # ########################################################################
 # Copyright 2013 Advanced Micro Devices, Inc.
-# 
+#
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# 
+#
 # http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +19,7 @@ import sys
 import argparse
 import subprocess
 import itertools
-import re#gex
+import re  # gex
 import os
 from threading import Timer, Thread
 import thread, time
@@ -31,8 +32,8 @@ from fftPerformanceTesting import *
 from performanceUtility import timeout, log, generate235Radices
 
 IAM = 'FFT'
-TIMOUT_VAL = 900  #In seconds
-   
+TIMOUT_VAL = 900  # In seconds
+
 devicevalues = ['gpu', 'cpu']
 layoutvalues = ['cp', 'ci']
 placevalues = ['in', 'out']
@@ -94,39 +95,39 @@ args = parser.parse_args()
 
 label = str(args.label)
 
-subprocess.call('mkdir perfLog', shell = True)
-logfile = os.path.join('perfLog', (label+'-'+'fftMeasurePerfLog.txt'))
+subprocess.call('mkdir perfLog', shell=True)
+logfile = os.path.join('perfLog', (label + '-' + 'fftMeasurePerfLog.txt'))
 
 def printLog(txt):
     print txt
     log(logfile, txt)
 
 printLog("=========================MEASURE PERFORMANCE START===========================")
-printLog("Process id of Measure Performance:"+str(os.getpid()))
+printLog("Process id of Measure Performance:" + str(os.getpid()))
 
 currCommandProcess = None
 
 
-printLog('Executing measure performance for label: '+str(label))
+printLog('Executing measure performance for label: ' + str(label))
 
 
-#This function is defunct now
- at timeout(1, "fileName") # timeout is 5 minutes, 5*60 = 300 secs
+# This function is defunct now
+ at timeout(1, "fileName")  # timeout is 5 minutes, 5*60 = 300 secs
 def checkTimeOutPut2(args):
     global currCommandProcess
-    #ret = subprocess.check_output(args, stderr=subprocess.STDOUT)
-    #return ret
+    # ret = subprocess.check_output(args, stderr=subprocess.STDOUT)
+    # return ret
     currCommandProcess = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    printLog("Curr Command Process id = "+str(currCommandProcess.pid))
-    ret = currCommandProcess.communicate()    
+    printLog("Curr Command Process id = " + str(currCommandProcess.pid))
+    ret = currCommandProcess.communicate()
     if(ret[0] == None or ret[0] == ''):
         errCode = currCommandProcess.poll()
         raise subprocess.CalledProcessError(errCode, args, output=ret[1])
     return ret[0]
 
 
-#Spawns a separate thread to execute the library command and wait for that thread to complete
-#This wait is of 900 seconds (15 minutes). If still the thread is alive then we kill the thread
+# Spawns a separate thread to execute the library command and wait for that thread to complete
+# This wait is of 900 seconds (15 minutes). If still the thread is alive then we kill the thread
 def checkTimeOutPut(args):
     t = None
     global currCommandProcess
@@ -140,51 +141,48 @@ def checkTimeOutPut(args):
         global stde
         try:
             stdo, stde = currCommandProcess.communicate()
-            printLog('stdout:\n'+str(stdo))
-            printLog('stderr:\n'+str(stde))
+            printLog('stdout:\n' + str(stdo))
+            printLog('stderr:\n' + str(stde))
         except:
             printLog("ERROR: UNKNOWN Exception - +checkWinTimeOutPut()::executeCommand()")
 
     currCommandProcess = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     thread = Thread(target=executeCommand)
     thread.start()
-    thread.join(TIMOUT_VAL) #wait for the thread to complete 
+    thread.join(TIMOUT_VAL)  # wait for the thread to complete
     if thread.is_alive():
         printLog('ERROR: Killing the process - terminating thread because it is taking too much of time to execute')
         currCommandProcess.kill()
         printLog('ERROR: Timed out exception')
         raise errorHandler.ApplicationException(__file__, errorHandler.TIME_OUT)
-    if stdo == "" or stdo==None:
+    if stdo == "" or stdo == None:
         errCode = currCommandProcess.poll()
         printLog('ERROR: @@@@@Raising Called processor exception')
         raise subprocess.CalledProcessError(errCode, args, output=stde)
     return stdo
 
 
-
-
-
 # don't try to create and use an .ini file at the same time (it will open a portal through which demons will emerge)
 if args.iniFilename and args.createIniFilename:
     printLog('ERROR: --ini and --createini are mutually exclusive. Please choose only one.')
     quit()
 
-#read in .ini parameters if --ini is used
+# read in .ini parameters if --ini is used
 if args.iniFilename != None:
     if not os.path.isfile(args.iniFilename):
         printLog("No file with the name \'{}\' exists. Please indicate another filename.".format(args.iniFilename))
         quit()
-    
+
     ini = open(args.iniFilename, 'r')
     iniContents = ini.read()
     iniContents = iniContents.split(';')
-    for i in range(0,len(iniContents)):
+    for i in range(0, len(iniContents)):
         line = iniContents.pop()
         line = line.partition(' ')
         parameter = line[0]
         value = line[2]
-        value = value.replace('\'','').replace('[','').replace(']','').replace(' ','')
-        
+        value = value.replace('\'', '').replace('[', '').replace(']', '').replace(' ', '')
+
         if parameter == 'batchSize':
             args.batchSize = value
         elif parameter == 'constProbSize':
@@ -211,13 +209,13 @@ if args.iniFilename != None:
             printLog('{} corrupted. Please re-create a .ini file with the --createini flag.'.format(args.iniFilename))
             quit()
 
-#create ini file if requested
+# create ini file if requested
 if args.createIniFilename != None:
     printLog('Creating Ini files')
     if os.path.isfile(args.createIniFilename):
         printLog('A file with the name \'{}\' already exists. Please delete the file or choose another name.'.format(args.createIniFilename))
         quit()
-    printLog('Creating Ini file:'+args.createIniFilename+'\n')
+    printLog('Creating Ini file:' + args.createIniFilename + '\n')
     ini = open(args.createIniFilename, 'w')
     ini.write('batchSize {} ;'.format(args.batchSize))
     ini.write('constProbSize {} ;'.format(args.constProbSize))
@@ -230,16 +228,16 @@ if args.createIniFilename != None:
     ini.write('outputlayout {} ;'.format(args.outputlayout))
     ini.write('placeness {} ;'.format(args.placeness))
     ini.write('precision {} ;'.format(args.precision))
-    printLog('Created Ini file:'+args.createIniFilename+'\n')
+    printLog('Created Ini file:' + args.createIniFilename + '\n')
     printLog("=========================MEASURE PERFORMANCE START===========================\n")
     quit()
 
 
-#turn pow10 into its range list
+# turn pow10 into its range list
 if args.batchSize.count('pow10'):
     args.batchSize = pow10
 
-#split up comma-delimited lists
+# split up comma-delimited lists
 args.batchSize = args.batchSize.split(',')
 args.constProbSize = int(args.constProbSize.split(',')[0])
 args.device = args.device.split(',')
@@ -254,13 +252,12 @@ args.placeness = args.placeness.split(',')
 args.precision = args.precision.split(',')
 
 
-
-printLog('Executing for label: '+str(args.label))
-#check parameters for sanity
+printLog('Executing for label: ' + str(args.label))
+# check parameters for sanity
 
 # batchSize of 'max' must not be in a list (does not get on well with others)
-#if args.batchSize.count('max') and len(args.batchSize) > 1:
-if ( args.batchSize.count('max') or args.batchSize.count('adapt') )and len(args.batchSize) > 1:
+# if args.batchSize.count('max') and len(args.batchSize) > 1:
+if (args.batchSize.count('max') or args.batchSize.count('adapt'))and len(args.batchSize) > 1:
     printLog('ERROR: --batchsize max must not be in a comma delimited list')
     quit()
 
@@ -283,44 +280,48 @@ def isPrime(n):
     n = abs(n)
     i = 2
     while i <= math.sqrt(n):
-        if n%i == 0:
+        if n % i == 0:
             return False
         i += 1
     return True
 
+
 def findFactors(number):
-    iter_space = range(1, number+1)
+    iter_space = range(1, number + 1)
     prime_factor_list = []
     for curr_iter in iter_space:
         if isPrime(curr_iter) == True:
-            #print 'curr_iter_prime: ', curr_iter
-            if number%curr_iter == 0:
+            # print 'curr_iter_prime: ', curr_iter
+            if number % curr_iter == 0:
                 prime_factor_list.append(curr_iter)
     return prime_factor_list
 
 
-#Type : Function
-#Input: num, a number which we need to factorize
-#Return Type: list
-#Details: This function returns only the prime factors on an input number
-#         e.g: input: 20, returns: [2,2,5]
-#              input: 32, returns: [2,2,2,2,2]
 def factor(num):
+    """
+    This function returns only the prime factors on an input number
+        e.g: input: 20, returns: [2,2,5]
+            input: 32, returns: [2,2,2,2,2]
+
+    Type : Function
+    Input: num, a number which we need to factorize
+    Return Type: list
+    """
     if num == 1:
         return [1]
     i = 2
-    limit = num**0.5
+    limit = num ** 0.5
     while i <= limit:
         if num % i == 0:
-            ret = factor(num/i)
+            ret = factor(num / i)
             ret.append(i)
             return ret
         i += 1
     return [num]
 
 def validateFactors(flist):
-    ref_list = [1,2,3,5]
-    if flist==ref_list:
+    ref_list = [1, 2, 3, 5]
+    if flist == ref_list:
         return True
     if len(flist) > len(ref_list):
         return False
@@ -329,23 +330,24 @@ def validateFactors(flist):
             return False
     return True
 
-#Type : Function
-#Input: num, a number which we need to validate for 1,2,3 or 5 factors
-#Return Type: boolean
-#Details: This function validates an input number for its prime factors
-#         If factors has number other than 1,2,3 or 5 then return false else return true
-#         e.g: input: 20, returns: True
-#              input: 28, returns: False
 def validate_number_for_1235(num):
+    """This function validates an input number for its prime factors
+    If factors has number other than 1,2,3 or 5 then return false else return true
+    e.g: input: 20, returns: True
+         input: 28, returns: False
+
+    Input: num, a number which we need to validate for 1,2,3 or 5 factors
+    Return Type: boolean
+    """
     if num == 0:
         return True
-    set1235 = set([1,2,3,5])
+    set1235 = set([1, 2, 3, 5])
     setPrimeFactors = set(factor(num))
-    setPrimeFactors = setPrimeFactors | set1235 #performed union of two sets
+    setPrimeFactors = setPrimeFactors | set1235  # performed union of two sets
     #if still the sets are same then we are done!!!
-    #else we got few factors other than 1,2,3 or 5 and we should invalidate
-    #the input number
-    if setPrimeFactors ==  set1235:
+    # else we got few factors other than 1,2,3 or 5 and we should invalidate
+    # the input number
+    if setPrimeFactors == set1235:
         return True
     return False
 
@@ -358,33 +360,33 @@ def getValidNumbersInRange(rlist):
             valid_number_list.append(relement)
     return valid_number_list
 
+
 def get_next_num_with_1235_factors(start):
-    start+=1
+    start += 1
     while not validateFactors(findFactors(start)):
-        start+=1
+        start += 1
     return start
 
 
 def check_number_for_1235_factors(number):
-    #printLog('number:'+ number)
+    # printLog('number:'+ number)
     factors = findFactors(number)
-    #printLog('factors:'+ factors)
+    # printLog('factors:'+ factors)
     if not validateFactors(factors):
         printLog("ERROR: --{0} must have only 1,2,3,5 as factors")
         return False
     return True
 
 
-
 def check_for_1235_factors(values, option):
-    #print 'values: ', values
+    # print 'values: ', values
     for n in values:
-        for m in n.replace('-',',').split(','):
+        for m in n.replace('-', ',').split(','):
             if not validate_number_for_1235(int(m)):
                 print 'ERROR: --{0} must specify number with only 1,2,3,5 as factors'.format(option)
                 quit()
-            #print 'Valid number for :',option,':', m
-       
+            # print 'Valid number for :',option,':', m
+
 
 if args.library == 'clFFT':
     check_for_1235_factors(args.lengthx, 'lengthx')
@@ -392,7 +394,6 @@ if args.library == 'clFFT':
     check_for_1235_factors(args.lengthz, 'lengthz')
 
 
-
 if not os.path.isfile(executable(args.library)):
     printLog("ERROR: Could not find client named {0}".format(executable(args.library)))
     quit()
@@ -404,9 +405,10 @@ def get235RadicesNumberInRange(minimum, maximum):
     numbers = generate235Radices(maximum)
     minIndex = numbers.index(minimum)
     maxIndex = numbers.index(maximum)
-    return numbers[minIndex:maxIndex+1]
-   
-#expand ranges
+    return numbers[minIndex:maxIndex + 1]
+
+
+# expand ranges
 class Range:
     def __init__(self, ranges, defaultStep='+1'):
         self.expanded = []
@@ -477,25 +479,24 @@ args.lengthy = Range(args.lengthy, 'l').expanded
 args.lengthz = Range(args.lengthz, 'l').expanded
 
 
-
-#expand problemsizes ('XxYxZ:batch')
-#print "args.problemsize--1-->", args.problemsize
+# expand problemsizes ('XxYxZ:batch')
+# print "args.problemsize--1-->", args.problemsize
 if args.problemsize and args.problemsize[0] != 'None':
     i = 0
     while i < len(args.problemsize):
         args.problemsize[i] = args.problemsize[i].split(':')
         args.problemsize[i][0] = args.problemsize[i][0].split('x')
-        i = i+1
+        i = i + 1
 
 
-#create the problem size combinations for each run of the client
+# create the problem size combinations for each run of the client
 problem_size_combinations = itertools.product(args.lengthx, args.lengthy, args.lengthz, args.batchSize)
 
 problem_size_combinations = list(itertools.islice(problem_size_combinations, None))
 
-#print "args.problemsize--2-->", args.problemsize
+# print "args.problemsize--2-->", args.problemsize
 
-#add manually entered problem sizes to the list of FFTs to crank out
+# add manually entered problem sizes to the list of FFTs to crank out
 manual_test_combinations = []
 
 if args.problemsize and args.problemsize[0] != 'None':
@@ -504,24 +505,24 @@ if args.problemsize and args.problemsize[0] != 'None':
         y = []
         z = []
         batch = []
-    
+
         x.append(int(n[0][0]))
-    
+
         if len(n[0]) >= 2:
             y.append(int(n[0][1]))
         else:
             y.append(1)
-    
+
         if len(n[0]) >= 3:
             z.append(int(n[0][2]))
         else:
             z.append(1)
-    
+
         if len(n) > 1:
             batch.append(int(n[1]))
         else:
             batch.append(1)
-    
+
         combos = itertools.product(x, y, z, batch)
         combos = list(itertools.islice(combos, None))
         for n in combos:
@@ -531,29 +532,29 @@ if args.problemsize and args.problemsize[0] != 'None':
 
 problem_size_combinations = problem_size_combinations + manual_test_combinations
 
-#create final list of all transformations (with problem sizes and transform properties)
+# create final list of all transformations (with problem sizes and transform properties)
 test_combinations = itertools.product(problem_size_combinations, args.device, args.inputlayout, args.outputlayout, args.placeness, args.precision)
 test_combinations = list(itertools.islice(test_combinations, None))
 test_combinations = [TestCombination(params[0][0], params[0][1], params[0][2], params[0][3], params[1], params[2], params[3], params[4], params[5], args.label) for params in test_combinations]
 
 
-#turn each test combination into a command, run the command, and then stash the gflops
-result = [] # this is where we'll store the results for the table
+# turn each test combination into a command, run the command, and then stash the gflops
+result = []  # this is where we'll store the results for the table
 
 
-#open output file and write the header
+# open output file and write the header
 
 if args.tableOutputFilename == None:
-   args.tableOutputFilename = 'results' + datetime.now().isoformat().replace(':','.') + '.txt'
+   args.tableOutputFilename = 'results' + datetime.now().isoformat().replace(':', '.') + '.txt'
 else:
    if os.path.isfile(args.tableOutputFilename):
        oldname = args.tableOutputFilename
-       args.tableOutputFilename = args.tableOutputFilename + datetime.now().isoformat().replace(':','.')
+       args.tableOutputFilename = args.tableOutputFilename + datetime.now().isoformat().replace(':', '.')
        message = 'A file with the name ' + oldname + ' already exists. Changing filename to ' + args.tableOutputFilename
        printLog(message)
 
 
-printLog('table header---->'+ str(tableHeader))
+printLog('table header---->' + str(tableHeader))
 
 table = open(args.tableOutputFilename, 'w')
 table.write(tableHeader + '\n')
@@ -564,23 +565,23 @@ if args.constProbSize == -1:
 args.constProbSize = int(args.constProbSize)
 
 
-printLog('Total combinations =  '+str(len(test_combinations)))
+printLog('Total combinations =  ' + str(len(test_combinations)))
 
 vi = 0
-#test_combinations = test_combinations[825:830]
+# test_combinations = test_combinations[825:830]
 for params in test_combinations:
-    vi = vi+1
+    vi = vi + 1
     printLog("")
-    printLog('preparing command: '+ str(vi))    
+    printLog('preparing command: ' + str(vi))
     device = params.device
     lengthx = str(params.x)
     lengthy = str(params.y)
     lengthz = str(params.z)
-    
+
     if params.batchsize == 'max':
         batchSize = maxBatchSize(lengthx, lengthy, lengthz, params.inlayout, params.precision, executable(args.library), '--' + device)
     elif params.batchsize == 'adapt':
-        batchSize = str(args.constProbSize/(int(lengthx)*int(lengthy)*int(lengthz)))
+        batchSize = str(args.constProbSize / (int(lengthx) * int(lengthy) * int(lengthz)))
     else:
         batchSize = str(params.batchsize)
 
@@ -613,7 +614,7 @@ for params in test_combinations:
         printLog('ERROR: invalid value for precision when assembling client command')
 
 
-    #set up arguments here
+    # set up arguments here
     if args.library == 'clFFT':
         arguments = [executable(args.library),
                      '--' + device,
@@ -626,17 +627,17 @@ for params in test_combinations:
                      placeness,
                      precision,
                      '-p', '10']
-   
+
     writeline = True
     try:
-        printLog('Executing Command: '+str(arguments))
+        printLog('Executing Command: ' + str(arguments))
         output = checkTimeOutPut(arguments)
         output = output.split(os.linesep);
         printLog('Execution Successfull---------------\n')
 
     except errorHandler.ApplicationException as ae:
         writeline = False
-        printLog('ERROR: Command is taking too much of time '+ae.message+'\n'+'Command: \n'+str(arguments))
+        printLog('ERROR: Command is taking too much of time ' + ae.message + '\n' + 'Command: \n' + str(arguments))
         continue
     except subprocess.CalledProcessError as clientCrash:
         print 'Command execution failure--->'
@@ -645,7 +646,7 @@ for params in test_combinations:
             printLog('Omitting line from table - problem is too large')
         else:
             writeline = False
-            printLog('ERROR: client crash. Please report the following error message (with \'CLFFT_*\' error code, if given, and the parameters used to invoke measurePerformance.py) \n'+clientCrash.output+'\n')
+            printLog('ERROR: client crash. Please report the following error message (with \'CLFFT_*\' error code, if given, and the parameters used to invoke measurePerformance.py) \n' + clientCrash.output + '\n')
             printLog('IN ORIGINAL WE CALL QUIT HERE - 1\n')
             continue
 
@@ -656,7 +657,7 @@ for params in test_combinations:
 
     if writeline:
         try:
-            output = itertools.ifilter( lambda x: x.count('Gflops'), output)
+            output = itertools.ifilter(lambda x: x.count('Gflops'), output)
             output = list(itertools.islice(output, None))
             thisResult = re.search('\d+\.*\d*e*-*\d*$', output[-1])
             thisResult = float(thisResult.group(0))
@@ -673,31 +674,31 @@ for params in test_combinations:
     else:
         if(len(output) > 0):
             if output[0].find('nan') or output[0].find('inf'):
-                printLog( 'WARNING: output from client was funky for this run. skipping table row')
+                printLog('WARNING: output from client was funky for this run. skipping table row')
             else:
                 prinLog('ERROR: output from client makes no sense')
                 printLog(str(output[0]))
                 printLog('IN ORIGINAL WE CALL QUIT HERE - 2\n')
         else:
             prinLog('ERROR: output from client makes no sense')
-            #quit()
+            # quit()
 printLog("=========================MEASURE PERFORMANCE ENDS===========================\n")
 #
-#"""
-#print a pretty table
-#"""
-#if args.tableOutputFilename == None:
+# """
+# print a pretty table
+# """
+# if args.tableOutputFilename == None:
 #   args.tableOutputFilename = 'results' + datetime.now().isoformat().replace(':','.') + '.txt'
-#else:
+# else:
 #   if os.path.isfile(args.tableOutputFilename):
 #       oldname = args.tableOutputFilename
 #       args.tableOutputFilename = args.tableOutputFilename + datetime.now().isoformat().replace(':','.')
 #       message = 'A file with the name ' + oldname + ' already exists. Changing filename to ' + args.tableOutputFilename
 #       print message
 #
-#table = open(args.tableOutputFilename, 'w')
-#table.write(tableHeader + '\n')
-#for x in result:
+# table = open(args.tableOutputFilename, 'w')
+# table.write(tableHeader + '\n')
+# for x in result:
 #   row = ''
 #   for y in x:
 #       row = row + str(y) + ','
diff --git a/src/scripts/perf/performanceUtility.py b/src/scripts/perf/performanceUtility.py
index e3c7626..379cbcf 100644
--- a/src/scripts/perf/performanceUtility.py
+++ b/src/scripts/perf/performanceUtility.py
@@ -1,12 +1,13 @@
+#!/usr/bin/env python2
 # ########################################################################
 # Copyright 2013 Advanced Micro Devices, Inc.
-# 
+#
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# 
+#
 # http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -14,8 +15,8 @@
 # limitations under the License.
 # ########################################################################
 
-#This file contains a number of utilities function which could be independent of
-#any specific domain concept
+# This file contains a number of utilities function which could be independent of
+# any specific domain concept
 
 import signal
 from subprocess import check_output
@@ -24,12 +25,12 @@ from datetime import datetime
 
 def currentUser():
     try:
-        return check_output("who", shell = True).split()[0];
+        return check_output("who", shell=True).split()[0];
     except:
         print 'Unhandled Exception at performanceUtility::currentUser()'
         raise
-    
-#Details: Generate sorted numbers in radices of 2,3 and 5 upto a given upper limit number
+
+# Details: Generate sorted numbers in radices of 2,3 and 5 upto a given upper limit number
 def generate235Radices(maxSize):
     sizeList = list()
     i = 0
@@ -46,15 +47,15 @@ def generate235Radices(maxSize):
             sumk = 1
             k = 0
             while(True):
-                SUM = sumi*sumj*sumk
-                if ( SUM > maxSize ): break
+                SUM = sumi * sumj * sumk
+                if (SUM > maxSize): break
                 sizeList.append(SUM)
                 k += 1
                 sumk *= 2
             if (k == 0): break
             j += 1
             sumj *= 3
-        if ( j == 0 and k == 0): break
+        if (j == 0 and k == 0): break
         i += 1
         sumi *= 5
     sizeList.sort()
@@ -66,11 +67,11 @@ def timeout(timeout_time, default):
         def f2(args):
             def timeout_handler(signum, frame):
                 raise errorHandler.TimeoutException()
- 
-            old_handler = signal.signal(signal.SIGALRM, timeout_handler) 
-            signal.alarm(timeout_time) # triger alarm in timeout_time seconds
+
+            old_handler = signal.signal(signal.SIGALRM, timeout_handler)
+            signal.alarm(timeout_time)  # triger alarm in timeout_time seconds
             retval = ""
-            try: 
+            try:
                 retval = f(args)
             except errorHandler.TimeoutException:
                 raise errorHandler.ApplicationException(__file__, errorHandler.TIME_OUT)
@@ -78,8 +79,8 @@ def timeout(timeout_time, default):
                 signal.alarm(0)
                 raise
             finally:
-                #print 'executing finally'
-                signal.signal(signal.SIGALRM, old_handler) 
+                # print 'executing finally'
+                signal.signal(signal.SIGALRM, old_handler)
             signal.alarm(0)
             return retval
         return f2
@@ -87,11 +88,10 @@ def timeout(timeout_time, default):
 
 
 def logTxtOutput(fileName, mode, txt):
-    todayFile =  fileName+'-'+datetime.now().strftime('%Y-%b-%d')+'.txt'
+    todayFile = fileName + '-' + datetime.now().strftime('%Y-%b-%d') + '.txt'
     with open(todayFile, mode) as f:
-        f.write('------\n'+txt+'\n')
-        
+        f.write('------\n' + txt + '\n')
+
 def log(filename, txt):
     with open(filename, 'a') as f:
-        f.write(datetime.now().ctime()+'# '+txt+'\n')
-        
\ No newline at end of file
+        f.write(datetime.now().ctime() + '# ' + txt + '\n')
diff --git a/src/scripts/perf/plotPerformance.py b/src/scripts/perf/plotPerformance.py
index 3976512..dd2a516 100644
--- a/src/scripts/perf/plotPerformance.py
+++ b/src/scripts/perf/plotPerformance.py
@@ -1,12 +1,13 @@
+#!/usr/bin/env python2
 # ########################################################################
 # Copyright 2013 Advanced Micro Devices, Inc.
-# 
+#
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# 
+#
 # http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,207 +38,207 @@ from matplotlib.backends.backend_pdf import PdfPages
 from fftPerformanceTesting import *
 
 def plotGraph(dataForAllPlots, title, plottype, plotkwargs, xaxislabel, yaxislabel):
-  """
-  display a pretty graph
-  """
-  dh.write('Making graph\n')
-  colors = ['k','y','m','c','r','b','g']
-  #plottype = 'plot'
-  for thisPlot in dataForAllPlots:
-    getattr(pylab, plottype)(thisPlot.xdata, thisPlot.ydata,
-                             '{}.-'.format(colors.pop()), 
-                             label=thisPlot.label, **plotkwargs)
-  if len(dataForAllPlots) > 1:
-    pylab.legend(loc='best')
-  
-  pylab.title(title)
-  pylab.xlabel(xaxislabel)
-  pylab.ylabel(yaxislabel)
-  pylab.grid(True)
-  
-  if args.outputFilename == None:
-    # if no pdf output is requested, spit the graph to the screen . . .
-    pylab.show()
-  else:
-    pylab.savefig(args.outputFilename,dpi=(1024/8))
-    # . . . otherwise, gimme gimme pdf
-    #pdf = PdfPages(args.outputFilename)
-    #pdf.savefig()
-    #pdf.close()
+    """
+      display a pretty graph
+      """
+    dh.write('Making graph\n')
+    colors = ['k', 'y', 'm', 'c', 'r', 'b', 'g']
+    # plottype = 'plot'
+    for thisPlot in dataForAllPlots:
+      getattr(pylab, plottype)(thisPlot.xdata, thisPlot.ydata,
+                               '{}.-'.format(colors.pop()),
+                               label=thisPlot.label, **plotkwargs)
+    if len(dataForAllPlots) > 1:
+      pylab.legend(loc='best')
+
+    pylab.title(title)
+    pylab.xlabel(xaxislabel)
+    pylab.ylabel(yaxislabel)
+    pylab.grid(True)
+
+    if args.outputFilename == None:
+      # if no pdf output is requested, spit the graph to the screen . . .
+      pylab.show()
+    else:
+      pylab.savefig(args.outputFilename, dpi=(1024 / 8))
+      # . . . otherwise, gimme gimme pdf
+      # pdf = PdfPages(args.outputFilename)
+      # pdf.savefig()
+      # pdf.close()
 
 ######## plotFromDataFile() Function to plot from data file begins ########
 def plotFromDataFile():
-  data = []
-  """
-  read in table(s) from file(s)
-  """
-  for thisFile in args.datafile:
-    if not os.path.isfile(thisFile):
-      print 'No file with the name \'{}\' exists. Please indicate another filename.'.format(thisFile)
-      quit()
-  
-    results = open(thisFile, 'r')
-    resultsContents = results.read()
-    resultsContents = resultsContents.rstrip().split('\n')
-  
-    firstRow = resultsContents.pop(0)
-    if firstRow != tableHeader:
-      print 'ERROR: input file \'{}\' does not match expected format.'.format(thisFile)
-      quit()
-  
-    for row in resultsContents:
-      row = row.split(',')
-      row = TableRow(TestCombination(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9]), row[10])
-      data.append(GraphPoint(row.parameters.x, row.parameters.y, row.parameters.z, row.parameters.batchsize, row.parameters.precision, row.parameters.device, row.parameters.label, row.gflops))
-  
-  """
-  data sanity check
-  """
-  # if multiple plotvalues have > 1 value among the data rows, the user must specify which to plot
-  multiplePlotValues = []
-  for option in plotvalues:
-    values = []
-    for point in data:
-      values.append(getattr(point, option)) 
-    multiplePlotValues.append(len(set(values)) > 1)
-  if multiplePlotValues.count(True) > 1 and args.plot == None:
-    print 'ERROR: more than one parameter of {} has multiple values. Please specify which parameter to plot with --plot'.format(plotvalues)
-    quit()
-  
-  # if args.graphxaxis is not 'problemsize', the user should know that the results might be strange
-  if args.graphxaxis != 'problemsize':
-    xaxisvalueSet = []
-    for option in xaxisvalues:
-      if option != 'problemsize':
+    data = []
+    """
+    read in table(s) from file(s)
+    """
+    for thisFile in args.datafile:
+        if not os.path.isfile(thisFile):
+            print 'No file with the name \'{}\' exists. Please indicate another filename.'.format(thisFile)
+            quit()
+
+        results = open(thisFile, 'r')
+        resultsContents = results.read()
+        resultsContents = resultsContents.rstrip().split('\n')
+
+        firstRow = resultsContents.pop(0)
+        if firstRow != tableHeader:
+            print 'ERROR: input file \'{}\' does not match expected format.'.format(thisFile)
+            quit()
+
+        for row in resultsContents:
+            row = row.split(',')
+            row = TableRow(TestCombination(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9]), row[10])
+            data.append(GraphPoint(row.parameters.x, row.parameters.y, row.parameters.z, row.parameters.batchsize, row.parameters.precision, row.parameters.device, row.parameters.label, row.gflops))
+
+    """
+    data sanity check
+    """
+    # if multiple plotvalues have > 1 value among the data rows, the user must specify which to plot
+    multiplePlotValues = []
+    for option in plotvalues:
         values = []
         for point in data:
-          values.append(getattr(point, option)) 
-        xaxisvalueSet.append(len(set(values)) > 1)
-    if xaxisvalueSet.count(True) > 1:
-      print 'WARNING: more than one parameter of {} is varied. unexpected results may occur. please double check your graphs for accuracy.'.format(xaxisvalues)
-  
-  # multiple rows should not have the same input values
-  pointInputs = []
-  for point in data:
-    pointInputs.append(point.__str__().split(';')[0])
-  if len(set(pointInputs)) != len(data):
-    print 'ERROR: imported table has duplicate rows with identical input parameters'
-    quit()
-  
-  """
-  figure out if we have multiple plots on this graph (and what they should be)
-  """
-  if args.plot != None:
-    multiplePlots = args.plot
-  elif multiplePlotValues.count(True) == 1:
-    multiplePlots = plotvalues[multiplePlotValues.index(True)]
-  else:
-    # default to device if none of the options to plot have multiple values
-    multiplePlots = 'device'
-  
-  """
-  assemble data for the graphs
-  """
-  data.sort(key=lambda row: int(getattr(row, args.graphxaxis)))
-  
-  # choose scale for x axis
-  if args.xaxisscale == None:
-    # user didn't specify. autodetect
-    if int(getattr(data[len(data)-1], args.graphxaxis)) > 2000: # big numbers on x-axis
-      args.xaxisscale = 'log2'
-    elif int(getattr(data[len(data)-1], args.graphxaxis)) > 10000: # bigger numbers on x-axis
-      args.xaxisscale = 'log10'
-    else: # small numbers on x-axis
-      args.xaxisscale = 'linear'
-  
-  if args.xaxisscale == 'linear':
-    plotkwargs = {}
-    plottype = 'plot'
-  elif args.xaxisscale == 'log2':
-    plottype = 'semilogx'
-    plotkwargs = {'basex':2}
-  elif args.xaxisscale == 'log10':
-    plottype = 'semilogx'
-    plotkwargs = {'basex':10}
-  else:
-    print 'ERROR: invalid value for x-axis scale'
-    quit()
-  
-  plots = set(getattr(row, multiplePlots) for row in data)
-  
-  class DataForOnePlot:
-    def __init__(self, inlabel, inxdata, inydata):
-      self.label = inlabel
-      self.xdata = inxdata
-      self.ydata = inydata
-  
-  dataForAllPlots = []
-  for plot in plots:
-    dataForThisPlot = itertools.ifilter( lambda x: getattr(x, multiplePlots) == plot, data)
-    dataForThisPlot = list(itertools.islice(dataForThisPlot, None))
-    if args.graphxaxis == 'problemsize':
-      xdata = [int(row.x) * int(row.y) * int(row.z) * int(row.batchsize) for row in dataForThisPlot]
+            values.append(getattr(point, option))
+        multiplePlotValues.append(len(set(values)) > 1)
+    if multiplePlotValues.count(True) > 1 and args.plot == None:
+        print 'ERROR: more than one parameter of {} has multiple values. Please specify which parameter to plot with --plot'.format(plotvalues)
+        quit()
+
+    # if args.graphxaxis is not 'problemsize', the user should know that the results might be strange
+    if args.graphxaxis != 'problemsize':
+        xaxisvalueSet = []
+        for option in xaxisvalues:
+            if option != 'problemsize':
+                values = []
+                for point in data:
+                    values.append(getattr(point, option))
+                xaxisvalueSet.append(len(set(values)) > 1)
+        if xaxisvalueSet.count(True) > 1:
+          print 'WARNING: more than one parameter of {} is varied. unexpected results may occur. please double check your graphs for accuracy.'.format(xaxisvalues)
+
+    # multiple rows should not have the same input values
+    pointInputs = []
+    for point in data:
+        pointInputs.append(point.__str__().split(';')[0])
+    if len(set(pointInputs)) != len(data):
+        print 'ERROR: imported table has duplicate rows with identical input parameters'
+        quit()
+
+    """
+    figure out if we have multiple plots on this graph (and what they should be)
+    """
+    if args.plot != None:
+        multiplePlots = args.plot
+    elif multiplePlotValues.count(True) == 1:
+        multiplePlots = plotvalues[multiplePlotValues.index(True)]
     else:
-      xdata = [getattr(row, args.graphxaxis) for row in dataForThisPlot]
-    ydata = [getattr(row, args.graphyaxis) for row in dataForThisPlot]
-    dataForAllPlots.append(DataForOnePlot(plot,xdata,ydata))
-  
-  """
-  assemble labels for the graph or use the user-specified ones
-  """
-  if args.graphtitle:
-    # use the user selection
-    title = args.graphtitle
-  else:
-    # autogen a lovely title
-    title = 'Performance vs. ' + args.graphxaxis.capitalize()
-  
-  if args.xaxislabel:
-    # use the user selection
-    xaxislabel = args.xaxislabel
-  else:
-    # autogen a lovely x-axis label
-    if args.graphxaxis == 'cachesize':
-      units = '(bytes)'
+        # default to device if none of the options to plot have multiple values
+        multiplePlots = 'device'
+
+    """
+    assemble data for the graphs
+    """
+    data.sort(key=lambda row: int(getattr(row, args.graphxaxis)))
+
+    # choose scale for x axis
+    if args.xaxisscale == None:
+        # user didn't specify. autodetect
+        if int(getattr(data[len(data) - 1], args.graphxaxis)) > 2000:  # big numbers on x-axis
+            args.xaxisscale = 'log2'
+        elif int(getattr(data[len(data) - 1], args.graphxaxis)) > 10000:  # bigger numbers on x-axis
+            args.xaxisscale = 'log10'
+        else:  # small numbers on x-axis
+            args.xaxisscale = 'linear'
+
+    if args.xaxisscale == 'linear':
+        plotkwargs = {}
+        plottype = 'plot'
+    elif args.xaxisscale == 'log2':
+        plottype = 'semilogx'
+        plotkwargs = {'basex':2}
+    elif args.xaxisscale == 'log10':
+        plottype = 'semilogx'
+        plotkwargs = {'basex':10}
+    else:
+      print 'ERROR: invalid value for x-axis scale'
+      quit()
+
+    plots = set(getattr(row, multiplePlots) for row in data)
+
+    class DataForOnePlot:
+        def __init__(self, inlabel, inxdata, inydata):
+            self.label = inlabel
+            self.xdata = inxdata
+            self.ydata = inydata
+
+    dataForAllPlots = []
+    for plot in plots:
+        dataForThisPlot = itertools.ifilter(lambda x: getattr(x, multiplePlots) == plot, data)
+        dataForThisPlot = list(itertools.islice(dataForThisPlot, None))
+        if args.graphxaxis == 'problemsize':
+            xdata = [int(row.x) * int(row.y) * int(row.z) * int(row.batchsize) for row in dataForThisPlot]
+        else:
+            xdata = [getattr(row, args.graphxaxis) for row in dataForThisPlot]
+        ydata = [getattr(row, args.graphyaxis) for row in dataForThisPlot]
+        dataForAllPlots.append(DataForOnePlot(plot, xdata, ydata))
+
+    """
+    assemble labels for the graph or use the user-specified ones
+    """
+    if args.graphtitle:
+      # use the user selection
+      title = args.graphtitle
+    else:
+      # autogen a lovely title
+      title = 'Performance vs. ' + args.graphxaxis.capitalize()
+
+    if args.xaxislabel:
+      # use the user selection
+      xaxislabel = args.xaxislabel
     else:
-      units = '(datapoints)'
-  
-    xaxislabel = args.graphxaxis + ' ' + units
-  
-  if args.yaxislabel:
-    # use the user selection
-    yaxislabel = args.yaxislabel
-  else:
-    # autogen a lovely y-axis label
-    if args.graphyaxis == 'gflops':
-      units = 'GFLOPS'
-    yaxislabel = 'Performance (' + units + ')'
-  
-  """
-  display a pretty graph
-  """
-  colors = ['k','y','m','c','r','b','g']
-  
-  for thisPlot in dataForAllPlots:
-    getattr(pylab, plottype)(thisPlot.xdata, thisPlot.ydata, '{}.-'.format(colors.pop()), label=thisPlot.label, **plotkwargs)
-  
-  if len(dataForAllPlots) > 1:
-    pylab.legend(loc='best')
-  
-  pylab.title(title)
-  pylab.xlabel(xaxislabel)
-  pylab.ylabel(yaxislabel)
-  pylab.grid(True)
-  
-  if args.outputFilename == None:
-    # if no pdf output is requested, spit the graph to the screen . . .
-    pylab.show()
-  else:
-    # . . . otherwise, gimme gimme pdf
-    #pdf = PdfPages(args.outputFilename)
-    #pdf.savefig()
-    #pdf.close()
-    pylab.savefig(args.outputFilename,dpi=(1024/8))
+      # autogen a lovely x-axis label
+      if args.graphxaxis == 'cachesize':
+        units = '(bytes)'
+      else:
+        units = '(datapoints)'
+
+      xaxislabel = args.graphxaxis + ' ' + units
+
+    if args.yaxislabel:
+      # use the user selection
+      yaxislabel = args.yaxislabel
+    else:
+      # autogen a lovely y-axis label
+      if args.graphyaxis == 'gflops':
+        units = 'GFLOPS'
+      yaxislabel = 'Performance (' + units + ')'
+
+    """
+    display a pretty graph
+    """
+    colors = ['k', 'y', 'm', 'c', 'r', 'b', 'g']
+
+    for thisPlot in dataForAllPlots:
+      getattr(pylab, plottype)(thisPlot.xdata, thisPlot.ydata, '{}.-'.format(colors.pop()), label=thisPlot.label, **plotkwargs)
+
+    if len(dataForAllPlots) > 1:
+      pylab.legend(loc='best')
+
+    pylab.title(title)
+    pylab.xlabel(xaxislabel)
+    pylab.ylabel(yaxislabel)
+    pylab.grid(True)
+
+    if args.outputFilename == None:
+      # if no pdf output is requested, spit the graph to the screen . . .
+      pylab.show()
+    else:
+      # . . . otherwise, gimme gimme pdf
+      # pdf = PdfPages(args.outputFilename)
+      # pdf.savefig()
+      # pdf.close()
+      pylab.savefig(args.outputFilename, dpi=(1024 / 8))
 ######### plotFromDataFile() Function to plot from data file ends #########
 
 
@@ -247,60 +248,62 @@ def plotFromDataFile():
 define and parse parameters
 """
 
-xaxisvalues = ['x','y','z','batchsize','problemsize']
+xaxisvalues = ['x', 'y', 'z', 'batchsize', 'problemsize']
 yaxisvalues = ['gflops']
 plotvalues = ['device', 'precision', 'label']
 
 
 
 parser = argparse.ArgumentParser(description='Plot performance of the clfft\
-    library. clfft.plotPerformance.py reads in data tables from clfft.\
-    measurePerformance.py and plots their values')
+ library. clfft.plotPerformance.py reads in data tables from clfft.\
+ measurePerformance.py and plots their values')
 fileOrDb = parser.add_mutually_exclusive_group(required=True)
 fileOrDb.add_argument('-d', '--datafile',
-  dest='datafile', action='append', default=None, required=False,
-  help='indicate a file to use as input. must be in the format output by\
-  clfft.measurePerformance.py. may be used multiple times to indicate\
-  multiple input files. e.g., -d cypressOutput.txt -d caymanOutput.txt')
+                      dest='datafile', action='append', default=None, required=False,
+                      help='indicate a file to use as input. must be in the format output by\
+ clfft.measurePerformance.py. may be used multiple times to indicate\
+ multiple input files. e.g., -d cypressOutput.txt -d caymanOutput.txt')
 parser.add_argument('-x', '--x_axis',
-  dest='graphxaxis', default=None, choices=xaxisvalues, required=True,
-  help='indicate which value will be represented on the x axis. problemsize\
-      is defined as x*y*z*batchsize')
+                    dest='graphxaxis', default=None, choices=xaxisvalues, required=True,
+                    help='indicate which value will be represented on the x axis. problemsize\
+ is defined as x*y*z*batchsize')
 parser.add_argument('-y', '--y_axis',
-  dest='graphyaxis', default='gflops', choices=yaxisvalues,
-  help='indicate which value will be represented on the y axis')
+                    dest='graphyaxis', default='gflops', choices=yaxisvalues,
+                    help='indicate which value will be represented on the y axis')
 parser.add_argument('--plot',
-  dest='plot', default=None, choices=plotvalues,
-  help='indicate which of {} should be used to differentiate multiple plots.\
-      this will be chosen automatically if not specified'.format(plotvalues))
+                    dest='plot', default=None, choices=plotvalues,
+                    help='indicate which of {} should be used to differentiate multiple plots.\
+ this will be chosen automatically if not specified'.format(plotvalues))
 parser.add_argument('--title',
-  dest='graphtitle', default=None,
-  help='the desired title for the graph generated by this execution. if\
-      GRAPHTITLE contains any spaces, it must be entered in \"double quotes\".\
-      if this option is not specified, the title will be autogenerated')
+                    dest='graphtitle', default=None,
+                    help='the desired title for the graph generated by this execution. if\
+ GRAPHTITLE contains any spaces, it must be entered in \"double quotes\".\
+ if this option is not specified, the title will be autogenerated')
 parser.add_argument('--x_axis_label',
-  dest='xaxislabel', default=None,
-  help='the desired label for the graph\'s x-axis. if XAXISLABEL contains\
-      any spaces, it must be entered in \"double quotes\". if this option\
-      is not specified, the x-axis label will be autogenerated')
+                    dest='xaxislabel', default=None,
+                    help='the desired label for the graph\'s x-axis. if XAXISLABEL contains\
+ any spaces, it must be entered in \"double quotes\". if this option\
+ is not specified, the x-axis label will be autogenerated')
 parser.add_argument('--x_axis_scale',
-  dest='xaxisscale', default=None, choices=['linear','log2','log10'],
-  help='the desired scale for the graph\'s x-axis. if nothing is specified,\
-      it will be selected automatically')
+                    dest='xaxisscale', default=None, choices=['linear', 'log2', 'log10'],
+                    help='the desired scale for the graph\'s x-axis. if nothing is specified,\
+ it will be selected automatically')
 parser.add_argument('--y_axis_label',
-  dest='yaxislabel', default=None,
-  help='the desired label for the graph\'s y-axis. if YAXISLABEL contains any\
-      spaces, it must be entered in \"double quotes\". if this option is not\
-      specified, the y-axis label will be autogenerated')
+                    dest='yaxislabel', default=None,
+                    help='the desired label for the graph\'s y-axis. if YAXISLABEL contains any\
+ spaces, it must be entered in \"double quotes\". if this option is not\
+ specified, the y-axis label will be autogenerated')
 parser.add_argument('--outputfile',
-  dest='outputFilename', default=None,
-  help='name of the file to output graphs. Supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz.')
+                    dest='outputFilename', default=None,
+                    help='name of the file to output graphs. Supported formats: emf, eps, \
+pdf, png, ps, raw, rgba, svg, svgz.')
 
 args = parser.parse_args()
 
 if args.datafile != None:
-  plotFromDataFile()
+    plotFromDataFile()
 else:
-  print "Atleast specify if you want to use text files or database for plotting graphs. Use -h or --help option for more details"
-  quit()
+    print "Atleast specify if you want to use text files or database for plotting graphs.\
+ Use -h or --help option for more details"
+    quit()
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/clfft.git



More information about the debian-science-commits mailing list