def organizedata(fileVars):

    organizeFunction = {
        'scalar':OrganizeScalar,        # Scalar data
        'impVec':nullOrganizedShader,   # Implicit vector data for multiple units (used by Shader Core stats)
        'stackbar':nullOrganizedStackedBar, # Stacked bars 
        'idxVec':nullOrganizedDram,     # Vector data with index  (used by DRAM stats)
        'idx2DVec':nullOrganizedDramV2, # Vector data with 2D index  (used by DRAM access stats)
        'sparse':OrganizeSparse,        # Vector data with 2D index  (used by DRAM access stats)
        'custom':0
    }
    data_type_char = {int:'I', float:'f'}

    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, data_type_char[statData.datatype])

    # 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, data_type_char[statData.datatype])
  
    # 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
            print "    Total number of CUDA src lines = %s..." % len(newMap)
            
            markForDel = []
            for ptxLines in newMap:
                if ptxLines > maxStats:
                    markForDel.append(ptxLines)
            for lines in markForDel:
                del newMap[lines]
            print "    Number of touched CUDA src lines = %s..." % len(newMap)
    
        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['CFLOGglobalPTX'] = fileVars[iter + 'PTX']
                    if parseCFLOGCUDA == 1:
                        fileVars['CFLOGglobalCUDA'] = 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['CFLOGglobalPTX'].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['CFLOGglobalCUDA'].data[rows][columns] += fileVars[iter + 'CUDA'].data[rows][columns]
            except:
                print "Error in generating globalCFLog data"

            count += 1
        del fileVars['CFLOG']


    return fileVars
Exemple #2
0
def organizedata(fileVars):

    print "Organizing data into internal format...";
    
    #Section 2.1 for adding a variable
    if fileVars.has_key('shaderInsn'):
        fileVars['shaderInsn'].data = nullOrganizedShader(fileVars['shaderInsn'].data)
    
    if fileVars.has_key('shdrctacount'):
        fileVars['shdrctacount'].data = nullOrganizedShader(fileVars['shdrctacount'].data)
    
    if fileVars.has_key('cacheMissRate_globalL1_all'):
        fileVars['cacheMissRate_globalL1_all'].data = nullOrganizedShaderv2(fileVars['cacheMissRate_globalL1_all'].data)
    
    if fileVars.has_key('cacheMissRate_textureL1_all'):
        fileVars['cacheMissRate_textureL1_all'].data = nullOrganizedShaderv2(fileVars['cacheMissRate_textureL1_all'].data)
    
    if fileVars.has_key('cacheMissRate_constL1_all'):
        fileVars['cacheMissRate_constL1_all'].data = nullOrganizedShaderv2(fileVars['cacheMissRate_constL1_all'].data)
    
    if fileVars.has_key('cacheMissRate_globalL1_noMgHt'):
        fileVars['cacheMissRate_globalL1_noMgHt'].data = nullOrganizedShaderv2(fileVars['cacheMissRate_globalL1_noMgHt'].data)
    
    if fileVars.has_key('cacheMissRate_textureL1_noMgHt'):
        fileVars['cacheMissRate_textureL1_noMgHt'].data = nullOrganizedShaderv2(fileVars['cacheMissRate_textureL1_noMgHt'].data)
    
    if fileVars.has_key('cacheMissRate_constL1_noMgHt'):
        fileVars['cacheMissRate_constL1_noMgHt'].data = nullOrganizedShaderv2(fileVars['cacheMissRate_constL1_noMgHt'].data)

    if fileVars.has_key('dram_writes_per_cycle'):
        fileVars['dram_writes_per_cycle'].data = [0] + [float(x) for x in fileVars['dram_writes_per_cycle'].data]

    if fileVars.has_key('dram_reads_per_cycle'):
        fileVars['dram_reads_per_cycle'].data = [0] + [float(x) for x in fileVars['dram_reads_per_cycle'].data]

    if fileVars.has_key('globalInsn'):
        fileVars['globalInsn'].data = [0] + [int(x) for x in fileVars['globalInsn'].data]
    
    if fileVars.has_key('globalCycle'):            
        fileVars['globalCycle'].data = [0] + [int(x) for x in fileVars['globalCycle'].data]
  
    if fileVars.has_key('L1ReadMiss'):
        fileVars['L1ReadMiss'].data = [0] + [int(x) for x in fileVars['L1ReadMiss'].data]

    if fileVars.has_key('L1TextMiss'):
        fileVars['L1TextMiss'].data = [0] + fileVars['L1TextMiss'].data
    
    if fileVars.has_key('L1ConstMiss'):
        fileVars['L1ConstMiss'].data = [0] + fileVars['L1ConstMiss'].data
    
    if fileVars.has_key('shaderWarpDiv'):
        fileVars['shaderWarpDiv'].data = nullOrganizedShader(fileVars['shaderWarpDiv'].data)
    
    if fileVars.has_key('globalTotInsn'):
        fileVars['globalTotInsn'].data = fileVars['globalTotInsn'].data

    if fileVars.has_key('STmemlatdist'):
        fileVars['STmemlatdist'].data = nullOrganizedShader(fileVars['STmemlatdist'].data)
        
    if fileVars.has_key('LDmemlatdist'):
        fileVars['LDmemlatdist'].data = nullOrganizedShader(fileVars['LDmemlatdist'].data)    

    if fileVars.has_key('WarpDivergenceBreakdown'):
        fileVars['WarpDivergenceBreakdown'].data = nullOrganizedShader(fileVars['WarpDivergenceBreakdown'].data)    

    if fileVars.has_key('dramCMD'):
        fileVars['dramCMD'].data = nullOrganizedDram(fileVars['dramCMD'].data)
    
    if fileVars.has_key('dramNOP'):
        fileVars['dramNOP'].data = nullOrganizedDram(fileVars['dramNOP'].data)
    
    if fileVars.has_key('dramNACT'):
        fileVars['dramNACT'].data = nullOrganizedDram(fileVars['dramNACT'].data)

    if fileVars.has_key('dramNPRE'):            
        fileVars['dramNPRE'].data = nullOrganizedDram(fileVars['dramNPRE'].data)
    
    if fileVars.has_key('dramNREQ'):
        fileVars['dramNREQ'].data = nullOrganizedDram(fileVars['dramNREQ'].data)
    
    if fileVars.has_key('dramAveMRQS'):
        fileVars['dramAveMRQS'].data = nullOrganizedDram(fileVars['dramAveMRQS'].data)

    if fileVars.has_key('dramUtil'):
        fileVars['dramUtil'].data = nullOrganizedDram(fileVars['dramUtil'].data)
    
    if fileVars.has_key('dramEff'):
        fileVars['dramEff'].data = nullOrganizedDram(fileVars['dramEff'].data)
    
    if fileVars.has_key('dramglobal_acc_r'):
        fileVars['dramglobal_acc_r'].data  = nullOrganizedDramV2(fileVars['dramglobal_acc_r'].data)
    
    if fileVars.has_key('dramglobal_acc_w'):
        fileVars['dramglobal_acc_w'].data  = nullOrganizedDramV2(fileVars['dramglobal_acc_w'].data)
    
    if fileVars.has_key('dramlocal_acc_r'):
        fileVars['dramlocal_acc_r'].data  = nullOrganizedDramV2(fileVars['dramlocal_acc_r'].data)
    
    if fileVars.has_key('dramlocal_acc_w'):
        fileVars['dramlocal_acc_w'].data  = nullOrganizedDramV2(fileVars['dramlocal_acc_w'].data)
    
    if fileVars.has_key('dramconst_acc_r'):
        fileVars['dramconst_acc_r'].data  = nullOrganizedDramV2(fileVars['dramconst_acc_r'].data)
    
    if fileVars.has_key('dramtexture_acc_r'):
        fileVars['dramtexture_acc_r'].data  = nullOrganizedDramV2(fileVars['dramtexture_acc_r'].data)
            
    if fileVars.has_key('globalCompletedThreads'):
        fileVars['globalCompletedThreads'].data = [0] + fileVars['globalCompletedThreads'].data
    
    if fileVars.has_key('globalSentWrites'):
        fileVars['globalSentWrites'].data = [0] + fileVars['globalSentWrites'].data
    
    if fileVars.has_key('globalProcessedWrites'):
        fileVars['globalProcessedWrites'].data = [0] + fileVars['globalProcessedWrites'].data
    
    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 fileVars.has_key('gpu_stall_by_MSHRwb'):
        fileVars['gpu_stall_by_MSHRwb'].data = [0] + fileVars['gpu_stall_by_MSHRwb'].data
    
    if (skipCFLog == 0) and fileVars.has_key('CFLOG'):
        loadfile = open('recentfiles.txt', 'r')
        bool = 0
        while loadfile:
            line = loadfile.readline()
            if not line: break
            if '.ptx' in line:
                ptxFile = line
                bool += 1
            if 'gpgpu_inst_stats' in line:
                statFile = line
                bool += 1
            if bool == 2:
                break
        
        print "PC Histogram to CUDA Src = %d" % convertCFLog2CUDAsrc
        parseCFLOGCUDA = convertCFLog2CUDAsrc

        if parseCFLOGCUDA == 1:
            map = lexyacctexteditor.ptxToCudaMapping(ptxFile.rstrip())
            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
Exemple #3
0
        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
            print "    Total number of CUDA src lines = %s..." % len(newMap)
            
            markForDel = []
            for ptxLines in newMap:
                if ptxLines > maxStats:
                    markForDel.append(ptxLines)
            for lines in markForDel:
                del newMap[lines]
            print "    Number of touched CUDA src lines = %s..." % len(newMap)
def organizedata(fileVars):

    organizeFunction = {
        'scalar': OrganizeScalar,  # Scalar data
        'impVec':
        nullOrganizedShader,  # Implicit vector data for multiple units (used by Shader Core stats)
        'stackbar': nullOrganizedStackedBar,  # Stacked bars 
        'idxVec':
        nullOrganizedDram,  # Vector data with index  (used by DRAM stats)
        'idx2DVec':
        nullOrganizedDramV2,  # Vector data with 2D index  (used by DRAM access stats)
        'sparse':
        OrganizeSparse,  # Vector data with 2D index  (used by DRAM access stats)
        'custom': 0
    }
    data_type_char = {int: 'I', float: 'f'}

    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, data_type_char[statData.datatype])

    # 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, data_type_char[statData.datatype])

    # 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