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 __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")
Пример #3
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")
Пример #4
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
Пример #5
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