Esempio n. 1
0
    def _generateErrorBars(self, f, li_bench, fl_barStart, fl_width, str_tool,
                           str_bench):
        di_limit = {}
        di_limit["bench"] = str_bench
        di_limit["tool"] = str_tool
        di_limitedRs = ResultSet.limitResultSetWithDict(self.rs, di_limit)
        li_values = []
        for d in di_limitedRs:
            li_values.append(d.get(self.key))
        m, lci, uci = self.__mean_confidence_interval(li_values)
        if self.normalize:
            if m > 0.0:
                li_actValue = ResultSet.limitResultSetWithDict(
                    li_bench, di_limit)
                assert len(li_actValue) == 1
                di_actValue = li_actValue[0]
                fl_actValue = di_actValue.get(self.key)
                lci = fl_actValue - ((m - lci) / m)
                uci = fl_actValue + ((uci - m) / m)

        # Let us not plot the error bars if the lci is not within the yMax,
        # because otherwise it is going to look weird
        if lci <= self.yMax:
            self.__drawLine(f, fl_width, fl_barStart, lci, fl_barStart, uci)
            self.__drawLine(f, fl_width, fl_barStart - fl_width / 2, lci,
                            fl_barStart + fl_width / 2, lci)
            self.__drawLine(f, fl_width, fl_barStart - fl_width / 2, uci,
                            fl_barStart + fl_width / 2, uci)
    def productTask(options, resultsSet):
        ProductTask.__printTaskInfoStart(options)
        # Copy resultsSet so as to have a backup
        workingRS = resultsSet.copy()
        # Inflate the result set so that each simulator config result includes all the stats keys
        pintoolRS = ResultSet.limitToPintoolResults(workingRS)
        simRS = ResultSet.limitToSimulatorResults(workingRS)
        simRS = ResultSet.extractGlobalStats(simRS)
        li_allKeys = ResultSet.getAllKeys(simRS)
        simRS = ResultSet.inflateResultSetWithKeys(simRS, li_allKeys)
        inflatedRS = []
        inflatedRS.extend(pintoolRS)
        inflatedRS.extend(simRS)

        res = Result(options)
        res.generateResult(inflatedRS)

        if options.generateEnergyStats:
            mp = McPATTask(options)
            mp.parseXml(workingRS)
            mp.runMcPAT()
            mpResultsSet = CollectTask.collectMcpatResults(options, inflatedRS)
            res.generateEnergyResult(mpResultsSet)

        ProductTask.__printTaskInfoEnd(options)
Esempio n. 3
0
 def __init__(self,generatorPower,frequencyRange):
     self.generatorPower = generatorPower
     self.frequencyRange = frequencyRange
     ResultSet.__init__(self,{\
         'frequency':Frequency,
         'forward power':Power,
         'reflected power':Power,
         'reflection coefficient':PowerRatio,
         'transmitted power':Power})
Esempio n. 4
0
 def __init__(self,powerLimits,frequencyRange):
     self.powerLimits = powerLimits
     self.frequencyRange = frequencyRange
     ResultSet.__init__(self,{\
         'injection frequency':Frequency,
         'generator power':Power,
         'pass':bool,
         'forward power':Power,
         'reflected power':Power,
         'reflection coefficent':PowerRatio,
         'transmitted power':Power,
         'limit':bool})
Esempio n. 5
0
    def __plotBenchData(self, data, f):
        """Write jgraph strings for individual benchmarks."""
        fl_benchLabelPos = JGraph.INITIAL_PADDING
        fl_shadeStart = self.SHADE_START
        fl_shadeInc = (
            (self.SHADE_END - self.SHADE_START) / (len(self.options.getSimulatorsTuple())))
        b_printLabel = True

        for bench in self.options.getBenchTuple():
            self._writeHashLabel(f, bench, fl_benchLabelPos)
            di_bench = {}
            di_bench["bench"] = bench
            li_bench = ResultSet.limitResultSetWithDict(data, di_bench)

            if self.normalize:  # Normalize the data
                str_firstTool = self.options.getSimulatorsTuple()[0]
                di_lookup = {}
                di_lookup["tool"] = str_firstTool
                li_div = ResultSet.limitResultSetWithDict(li_bench, di_lookup)
                assert len(li_div) == 1
                if li_div[0].get(self.key) > 0:
                    for tmp in li_bench:
                        tmp[self.key] = (tmp[self.key] / li_div[0].get(self.key))
                else:
                    for tmp in li_bench:
                        tmp[self.key] = float("inf")

            # li_bench now has normalized data if enabled

            in_numBars = len(li_bench)
            fl_width = ((self.BENCH_PADDING - (2 * self.BAR_PADDING)) / in_numBars)

            fl_barStart = (fl_benchLabelPos - ((in_numBars - 1) * fl_width / 2))
            fl_shadeStart = self.SHADE_START
            toolCount = 1

            for tool in self.options.getSimulatorsTuple():
                for di_entry in li_bench:
                    if di_entry.get("tool") == tool:
                        self.__startBar(fl_shadeStart, fl_width, f, b_printLabel, tool)
                        self.__generateBar(f, li_bench, fl_barStart, tool, False, None, toolCount)
                        if self.DRAW_ERROR_BARS:
                            self._generateErrorBars(f, li_bench, fl_barStart, fl_width / 2, tool,
                                                    bench)
                        break
                fl_barStart += fl_width
                fl_shadeStart += fl_shadeInc
                toolCount += 1

            if b_printLabel:
                b_printLabel = False
            fl_benchLabelPos += self.BENCH_PADDING
            f.write("\n")
    def __computeSummaryProps(self, di_compProps, str_compKey, di_toolRawData,
                              di_toolNormData, str_tool):
        assert (len(di_toolRawData) == 1 and len(di_toolNormData) == 1)
        fl_base = float(di_toolRawData[self.key])

        li_di_compKey = self._merge(self.rs, str_compKey)
        # limit to current benchmark and configuration
        di_extractor = {}
        di_extractor["tool"] = str_tool
        li_compData = ResultSet.limitResultSetWithDict(li_di_compKey,
                                                       di_extractor)
        assert len(li_compData) == len(self.options.getBenchTuple())

        di_rawCompMerged = merge.merge(li_compData, str_compKey,
                                       JGraph.SUMMARY_MERGE_TYPE)
        assert len(di_rawCompMerged) == 1
        fl_comp = float(di_rawCompMerged[str_compKey])

        assert fl_comp <= fl_base
        fl_configProp = (fl_comp / fl_base)
        # This is just component by total for one config, but we need to
        # compute the overall proportion normalized to one simulator tool
        assert len(di_toolNormData) == 1
        fl_multiplier = float(di_toolNormData[self.key])
        fl_overallProp = fl_configProp * fl_multiplier
        di_compProps[str_compKey] = fl_overallProp
    def __computeProps(self, di_compProps, str_compKey, li_toolRawData,
                       li_toolNormData, str_bench, str_tool):
        li_di_compKey = self._merge(self.rs, str_compKey)
        # limit to current benchmark and configuration
        di_extractor = {}
        di_extractor["tool"] = str_tool
        di_extractor["bench"] = str_bench
        li_comp = ResultSet.limitResultSetWithDict(li_di_compKey, di_extractor)
        assert len(li_comp) == 1
        di_compValue = li_comp[0]
        fl_comp = float(di_compValue[str_compKey])

        assert len(li_toolRawData) == 1
        fl_base = float(li_toolRawData[0][self.key])

        assert fl_comp <= fl_base
        fl_configProp = (fl_comp / fl_base)
        # This is just component by total for one config, but we need to
        # compute the overall proportion normalized to one simulator tool

        assert len(li_toolNormData) == 1
        fl_multiplier = float(li_toolNormData[0][self.key])

        fl_overallProp = fl_configProp * fl_multiplier

        di_compProps[str_compKey] = fl_overallProp
    def __plotSummary(self, file, li_keyData):
        """Plot summary results, based on tool as the key."""
        str_type = ""
        if JGraph.SUMMARY_MERGE_TYPE == MergeType.MERGE_GEOMEAN:
            str_type = "geomean"
        else:
            str_type = "average"

        fl_barStart = self.xMax - self.BENCH_PADDING + self.SUMMARY_PADDING
        self._writeHashLabel(file, str_type, fl_barStart)

        in_numConfigs = len(self.options.getSimulatorsTuple())
        fl_shadeStart = self.SHADE_START + (self.numComps * self.fl_shadeInc)

        fl_barWidth = ((self.BENCH_PADDING - (2 * self.BAR_PADDING)) /
                       in_numConfigs)
        fl_barStart = (fl_barStart - ((in_numConfigs - 1) * fl_barWidth / 2))

        b_firstTool = True
        fl_Value = 0.0
        toolCount = 1
        for tool in self.options.getSimulatorsTuple():
            di_tool = {}
            di_tool["tool"] = tool
            li_toolRawData = ResultSet.limitResultSetWithDict(
                li_keyData, di_tool)
            assert li_toolRawData and (len(li_toolRawData) == len(
                self.options.getBenchTuple()))
            li_toolNormData = copy.deepcopy(li_toolRawData)

            di_normMerged = merge.merge(li_toolNormData, self.key,
                                        JGraph.SUMMARY_MERGE_TYPE)

            if self.normalize:
                if b_firstTool:
                    fl_Value = di_normMerged.get(self.key)
                    b_firstTool = False
                    if fl_Value > 0.0:
                        di_normMerged[self.key] = 1.0
                    else:
                        fl_Value = 0.0
                else:
                    if fl_Value > 0.0:
                        _factor = di_normMerged.get(self.key) / fl_Value
                    else:
                        # _factor = 0.0
                        _factor = float("inf")
                    di_normMerged[self.key] = _factor

            self.__startSummaryBar(file, fl_shadeStart, fl_barWidth, tool)
            self.__generateSummaryBar(file, fl_barStart, di_normMerged,
                                      toolCount)

            fl_shadeStart += self.fl_shadeInc
            fl_barStart += fl_barWidth
            toolCount += 1

        file.write("\n")
Esempio n. 9
0
    def __plotSummary(self, data, f):
        """Plot summary results, based on tool as the key."""
        str_type = ""
        if JGraph.SUMMARY_MERGE_TYPE == MergeType.MERGE_GEOMEAN:
            str_type = "geomean"
        else:
            str_type = "average"

        fl_barStart = self.xMax - self.BENCH_PADDING + self.SUMMARY_PADDING
        self._writeHashLabel(f, str_type, fl_barStart)

        in_numBars = len(self.options.getSimulatorsTuple())
        fl_shadeInc = ((self.SHADE_END - self.SHADE_START) / in_numBars)
        fl_shadeStart = self.SHADE_START

        fl_width = ((self.BENCH_PADDING - (2 * self.BAR_PADDING)) / in_numBars)
        fl_barStart = (fl_barStart - ((in_numBars - 1) * fl_width / 2))

        b_firstTool = True
        fl_Value = 0.0
        toolCount = 1
        for tool in self.options.getSimulatorsTuple():
            di_tool = {}
            di_tool["tool"] = tool
            li_di_bench = ResultSet.limitResultSetWithDict(data, di_tool)
            di_merged = {}
            if not li_di_bench:
                di_merged[self.key] = 0
            else:
                di_merged = merge.merge(li_di_bench, self.key, JGraph.SUMMARY_MERGE_TYPE)

            if self.normalize:
                if b_firstTool:
                    fl_Value = di_merged.get(self.key)
                    b_firstTool = False
                    if fl_Value > 0.0:
                        di_merged[self.key] = 1.0
                    else:
                        fl_Value = 0.0
                else:
                    if fl_Value > 0.0:
                        _factor = di_merged.get(self.key) / fl_Value
                    else:
                        _factor = 0.0
                    di_merged[self.key] = _factor

            self.__startBar(fl_shadeStart, fl_width, f, False, tool)
            self.__generateBar(f, None, fl_barStart, None, True, di_merged, toolCount)
            fl_barStart += fl_width
            fl_shadeStart += fl_shadeInc
            toolCount += 1

        f.write("\n")
Esempio n. 10
0
    def __generateBar(self, f, li_bench, fl_barStart, str_tool, b_summary, val, toolCount):
        di_tool = {}
        if not b_summary:
            di_tool["tool"] = str_tool
            li_tool = ResultSet.limitResultSetWithDict(li_bench, di_tool)
            assert len(li_tool) == 1
            di_onlyResult = li_tool[0]
        else:
            di_onlyResult = val

        if di_onlyResult[self.key] > self.yMax:
            self.__graphPoint(f, fl_barStart, self.yMax)
            str_text = str(round(di_onlyResult[self.key], JGraph.PRECISION_DIGITS))
            fl_yPos = self.yMax + \
                (self.yMax - self.yMin) * 0.05 * (toolCount - 1)
            str_cmd = self._drawTextCommand(fl_barStart, fl_yPos, str_text)
            self.li_OverflownYValues.append(str_cmd)
        else:
            self.__graphPoint(f, fl_barStart, di_onlyResult[self.key])
Esempio n. 11
0
    def _merge(self, lrs, key):
        """Merge result set over all trials with the given key.  This method takes care of
        benchmarks and configurations/tools.
        """
        li_union = []
        # Limit based on benchmarks and tools
        for bench in self.options.getBenchTuple():
            for tool in self.options.getSimulatorsTuple():
                di_known = {}
                di_known["bench"] = bench
                di_known["tool"] = tool
                rs = ResultSet.limitResultSetWithDict(lrs, di_known)
                if not rs:
                    continue

                di_ms = merge.merge(rs, key)
                # Union the two dictionaries
                di_known = dict(di_known, **di_ms)
                li_union.append(di_known)
        return li_union
Esempio n. 12
0
 def asDom(self,parent):
     element = ResultSet.asDom(self,parent)
     self.appendChildObject(element,self.powerLimits,'power limits')   
     self.appendChildObject(element,self.frequencyRange,'frequency range')
     return element
Esempio n. 13
0
 def asDom(self,parent):
     element = ResultSet.asDom(self,parent)
     self.appendChildObject(element,self.generatorPower,'generator power')   
     self.appendChildObject(element,self.frequencyRange,'frequency range')
     return element
Esempio n. 14
0
 def __init__(self):
     ResultSet.__init__(self,{'position':Position})
Esempio n. 15
0
    def collectMcpatResults(options, resSet):
        cwd = os.getcwd()
        odir = (options.getExpProductsDir() + os.sep +
                McPATTask.McPAT_ROOT_DIR + os.sep +
                McPATTask.McPAT_OUTPUT_FILES)
        os.chdir(odir)
        energyStats = []  # list of dictionaries

        try:
            for w in options.getWorkloadTuple():
                for b in tuple(options.getBenchTuple()):
                    dic = {}
                    dic["bench"] = b
                    dic["workload"] = w
                    for t in options.getToolsTuple():
                        if util.isPintool(t):
                            continue
                        statsFile = b + '-' + t + '-' + w + '.mcpat'

                        if not os.path.exists(statsFile):
                            util.raiseError(
                                "[error] Mcpat output file not present: ",
                                statsFile)

                        mergedDic = dic.copy()
                        mergedDic["tool"] = t
                        li_di_bench = ResultSet.limitResultSetWithDict(
                            resSet, mergedDic)
                        merged_cycles = merge.merge(
                            li_di_bench, SK.BANDWIDTH_CYCLE_COUNT_KEY)[
                                SK.BANDWIDTH_CYCLE_COUNT_KEY]

                        merged_bf_energy = 0.0
                        if not util.isOnlyCEConfigNoAIM(
                                options.getToolsTuple()):
                            merged_bf_energy = merge.merge(
                                li_di_bench, VK.BLOOM_FILTER_TOTAL_ENERGY)[
                                    VK.BLOOM_FILTER_TOTAL_ENERGY]

                        dynamic_aim_energy = 0
                        static_aim_energy = 0
                        simDic = {}
                        if util.isViserConfig(t) or util.isCEConfigWithAIM(t):
                            simDic = Mcpat.parseDetailedStats(
                                statsFile, simDic)
                            if not CollectTask.ADD_AIM_McPAT:  # Estimate from the simulator
                                # dynamic_aim_energy = (merge.merge(
                                #     li_di_bench,
                                #     VK.AIM_DYNAMIC_TOTAL_ENERGY)[VK.AIM_DYNAMIC_TOTAL_ENERGY])
                                simDic[EK.AIM_STATIC_POWER] = 0
                                simDic[EK.AIM_DYNAMIC_POWER] = 0
                            else:
                                dynamic_aim_energy = (
                                    simDic[EK.AIM_DYNAMIC_POWER] *
                                    merged_cycles / CollectTask.CLK_FREQUENCY)
                                static_aim_energy = (
                                    simDic[EK.AIM_STATIC_POWER] *
                                    merged_cycles / CollectTask.CLK_FREQUENCY)
                        else:
                            simDic = Mcpat.parseTerseStats(statsFile, simDic)

                        simDic[EK.STATIC_ENERGY] = (simDic[EK.STATIC_POWER] *
                                                    merged_cycles /
                                                    CollectTask.CLK_FREQUENCY)
                        simDic[EK.DYNAMIC_ENERGY] = (simDic[EK.DYNAMIC_POWER] *
                                                     merged_cycles /
                                                     CollectTask.CLK_FREQUENCY)
                        simDic[EK.BLOOM_FILTER_ENERGY] = merged_bf_energy
                        simDic[EK.AIM_STATIC_ENERGY] = static_aim_energy
                        simDic[EK.AIM_DYNAMIC_ENERGY] = dynamic_aim_energy
                        # McPAT output already includes the AIM component
                        simDic[EK.TOTAL_ENERGY] = (simDic[EK.STATIC_ENERGY] +
                                                   simDic[EK.DYNAMIC_ENERGY] +
                                                   merged_bf_energy)

                        # Union the two dictionaries
                        energyStats.append({**mergedDic, **simDic})

        finally:
            os.chdir(cwd)
        return energyStats
    def __plotData(self, f, li_keyData, b_computeMaxY):
        """Write Jgraph strings for individual benchmarks and configs."""
        fl_benchLabelPos = JGraph.INITIAL_PADDING
        b_printLabel = True  # just for the first benchmark

        for bench in self.options.getBenchTuple():
            if not b_computeMaxY:
                self._writeHashLabel(f, bench, fl_benchLabelPos)

            di_bench = {}
            di_bench["bench"] = bench
            # li_keyData includes results from all benchmarks for the given key
            li_benchRawData = ResultSet.limitResultSetWithDict(
                li_keyData, di_bench)

            li_benchNormData = copy.deepcopy(li_benchRawData)

            # Normalize the data wrt the first configuration
            di_firstTool = {}
            di_firstTool["tool"] = self.options.getSimulatorsTuple()[0]
            li_div = ResultSet.limitResultSetWithDict(li_benchNormData,
                                                      di_firstTool)
            assert len(li_div) == 1
            if li_div[0].get(self.key) > 0:
                for tmp in li_benchNormData:
                    tmp[self.key] = (tmp[self.key] / li_div[0].get(self.key))
            else:
                for tmp in li_benchNormData:
                    tmp[self.key] = float("inf")

            # li_benchNormData now has normalized data

            in_numConfigs = len(li_benchNormData)
            # Dimension of each bar
            fl_barWidth = ((self.BENCH_PADDING - (2 * self.BAR_PADDING)) /
                           in_numConfigs)

            fl_barStart = (fl_benchLabelPos -
                           ((in_numConfigs - 1) * fl_barWidth / 2))

            toolCount = 1
            b_mesiTool = True
            b_viserTool = True
            b_rccsiTool = True
            b_pauseTool = True
            for tool in self.options.getSimulatorsTuple():
                di_tool = {}
                di_tool["tool"] = tool
                li_toolNormData = ResultSet.limitResultSetWithDict(
                    li_benchNormData, di_tool)
                assert len(li_toolNormData) == 1
                li_toolRawData = ResultSet.limitResultSetWithDict(
                    li_benchRawData, di_tool)
                assert len(li_toolRawData) == 1
                # So we have the raw and normalized data corresponding to the
                # benchmark, configuration and the key

                # get the number of components for this tool
                li_comps = []
                if util.isMESIConfig(tool) or util.isCEConfig(tool):
                    li_comps = self.li_components[StackedKeys.MESI_OFFSET]
                    fl_shadeStart = self.fl_MESIStart
                elif util.isViserConfig(tool):
                    li_comps = self.li_components[StackedKeys.VISER_OFFSET]
                    fl_shadeStart = self.fl_ViserStart
                elif util.isRCCSIConfig(tool):
                    li_comps = self.li_components[StackedKeys.RCCSI_OFFSET]
                    fl_shadeStart = self.fl_RCCSIStart
                elif util.isPauseConfig(tool):
                    li_comps = self.li_components[StackedKeys.PAUSE_OFFSET]
                    fl_shadeStart = self.fl_PAUSEStart
                else:
                    assert False

                di_compProps = collections.OrderedDict()
                # Because of the inadequacy with JGraph, we first compute the y
                # proportions for each component and save them, and only then
                # think about writing to the .jgr file
                for i in range(0, len(li_comps)):
                    str_compKey = li_comps[i]
                    self.__computeProps(di_compProps, str_compKey,
                                        li_toolRawData, li_toolNormData, bench,
                                        tool)

                # The sum of all the values should be one, but it is not
                # because we take into account the multiplier

                di_compSums = collections.OrderedDict().fromkeys(
                    di_compProps, 0.0)

                i = 1
                for key in di_compProps:
                    fl_sum = 0
                    di_tmp = itertools.islice(di_compProps.items(), 0, i)
                    for _, value in di_tmp:
                        fl_sum += value
                    di_compSums[key] = fl_sum
                    i = i + 1

                # Now reverse the ordered dict
                li_items = list(di_compSums.items())
                li_items.reverse()
                di_compJGRPositions = collections.OrderedDict(li_items)

                patternCounter = 0
                for str_compKey in di_compJGRPositions:
                    fl_yPos = di_compJGRPositions.get(str_compKey)
                    if fl_yPos > self.fl_computedYMax:
                        self.fl_computedYMax = fl_yPos
                    if not b_computeMaxY:
                        self.__drawWhiteXBar(fl_barWidth, f)
                        self.__generatePoints(f, fl_barStart, fl_yPos,
                                              toolCount)
                        if (b_printLabel and
                            (((util.isMESIConfig(tool)
                               or util.isCEConfig(tool)) and b_mesiTool) or
                             (util.isViserConfig(tool) and b_viserTool) or
                             (util.isRCCSIConfig(tool) and b_rccsiTool) or
                             (util.isPauseConfig(tool) and b_pauseTool))):
                            self.__startXBar(fl_shadeStart, fl_barWidth, f,
                                             True, patternCounter, str_compKey)
                        else:
                            self.__startXBar(fl_shadeStart, fl_barWidth, f,
                                             False, patternCounter,
                                             str_compKey)
                        self.__generatePoints(f, fl_barStart, fl_yPos,
                                              toolCount)
                    patternCounter = patternCounter + 1
                    fl_shadeStart += self.fl_shadeInc

                    if not b_computeMaxY and self.DRAW_ERROR_BARS:
                        self._generateErrorBars(f, li_benchNormData,
                                                fl_barStart, fl_barWidth / 2,
                                                tool, bench)

                fl_barStart += fl_barWidth
                toolCount += 1
                if util.isMESIConfig(tool) or util.isCEConfig(tool):
                    b_mesiTool = False
                elif util.isViserConfig(tool):
                    b_viserTool = False
                elif util.isRCCSIConfig(tool):
                    b_rccsiTool = False
                elif util.isPauseConfig(tool):
                    b_pauseTool = False
            if b_printLabel:
                b_printLabel = False
            fl_benchLabelPos += self.BENCH_PADDING
            if not b_computeMaxY:
                f.write("\n")