def plot_subplots(self): # SIZE runs = CGStorage().get_for_param(self.cache, 'SIZE') sizes = [ CGPlotter.convert_to_bit_str(s) for s in Config.CACHE_PARAMS[self.cache]['SIZE'] ] miss_rates = [ CGAnalyzer.get_count_for_cache(self.cache, r.summary) for r in runs ] self.min_miss_rates.append(min(miss_rates)) self.max_miss_rates.append(max(miss_rates)) self.axs[0].plot(sizes, miss_rates, 's-r') self.axs[0].yaxis.set_major_formatter(ticker.PercentFormatter()) self.axs[0].set_title('size') self.axs[0].grid() # ASSOC runs = CGStorage().get_for_param(self.cache, 'ASSOC') sizes = [r.get_specs()[self.cache]['ASSOC'] for r in runs] miss_rates = [ CGAnalyzer.get_count_for_cache(self.cache, r.summary) for r in runs ] self.min_miss_rates.append(min(miss_rates)) self.max_miss_rates.append(max(miss_rates)) self.axs[1].plot(sizes, miss_rates, 's-r') self.axs[1].yaxis.set_major_formatter(ticker.PercentFormatter()) self.axs[1].set_title('set-associativity') self.axs[1].grid() # LINE runs = CGStorage().get_for_param(self.cache, 'LINE_SIZE') sizes = [r.get_specs()[self.cache]['LINE_SIZE'] + 'B' for r in runs] miss_rates = [ CGAnalyzer.get_count_for_cache(self.cache, r.summary) for r in runs ] self.min_miss_rates.append(min(miss_rates)) self.max_miss_rates.append(max(miss_rates)) self.axs[2].plot(sizes, miss_rates, 's-r') self.axs[2].yaxis.set_major_formatter(ticker.PercentFormatter()) self.axs[2].set_title('line size') self.axs[2].grid() min_miss_rate = floor(min(self.min_miss_rates)) max_miss_rate = max(self.max_miss_rates) self.axs[0].set_ylim([min_miss_rate, max_miss_rate]) self.axs[1].set_ylim([min_miss_rate, max_miss_rate]) self.axs[2].set_ylim([min_miss_rate, max_miss_rate]) self.axs[0].set_ylabel(f'{self.cache} r+w miss rate')
def plot_thresholded_most_changing_lines_for_func(cache, func_mapping): outputs = CGStorage().get_for_program() analyser = CGGlobalAnalyzer(outputs) func = outputs[0].get_func(CGFuncMapper().get_func(func_mapping)) pre_def_lines = analyser.get_thresholded_lines_for_func(func) pre_def_lines = [l.number for l in pre_def_lines] ch_lines = analyser.get_lines_by_change_for_func( cache, func, pre_def_lines) CGPlotter.plot_lines(cache, func, ch_lines)
def plot_thresholded_most_changing_funcs(cache): outputs = CGStorage().get_for_program() analyser = CGGlobalAnalyzer(outputs) thres_funcs = analyser.get_thresholded_funcs() ch_funcs = analyser.get_functions_by_change(cache, thres_funcs) fil_ch_funcs = analyser.filter_callees(outputs[0], ch_funcs) for f in thres_funcs: print(f'{CGFuncMapper().get_mapping(f)} - {f}') CGPlotter.plot_funcs(cache, fil_ch_funcs)
def run(self): CGFuncMapper().fill_mapping(CGStorage().get_for_program()[0]) if self.type == 'regions': CGPlotter.plot_thresholded_most_changing_funcs(self.cache) elif self.type == 'region': CGPlotter.plot_func(self.cache, CGFuncMapper().get_func(self.region)) elif self.type == 'region-lines': CGPlotter.plot_thresholded_most_changing_lines_for_func( self.cache, self.region) else: CGPlotter.plot_global(self.cache)
def run(): pass CGFuncMapper().fill_mapping(CGStorage().get_for_run_conf(CGRunConf()))
def plot_subplots(self): # SIZE runs = CGStorage().get_for_param(self.cache, 'SIZE') sizes = [ CGPlotter.convert_to_bit_str(s) for s in Config.CACHE_PARAMS[self.cache]['SIZE'] ] for gg, line in enumerate(self.lines): funcs = [ f for r in runs for f in r.get_funcs() if str(f) == str(self.func) ] lines = [ l for f in funcs for l in f.lines.values() if l.number == line ] miss_rates = [ CGAnalyzer.get_count_for_cache(self.cache, l.events) for l in lines ] ls = ['-', '--', '-.', ':'][gg % 4] self.axs[0].plot(sizes, miss_rates, 's-', label=str(line), alpha=0.7, linestyle=ls) self.min_miss_rates.append(min(miss_rates)) self.max_miss_rates.append(max(miss_rates)) self.axs[0].yaxis.set_major_formatter(ticker.PercentFormatter()) self.axs[0].set_title('size') self.axs[0].grid() self.axs[0].legend() # ASSOC runs = CGStorage().get_for_param(self.cache, 'ASSOC') sizes = [r.get_specs()[self.cache]['ASSOC'] for r in runs] for gg, line in enumerate(self.lines): funcs = [ f for r in runs for f in r.get_funcs() if str(f) == str(self.func) ] lines = [ l for f in funcs for l in f.lines.values() if l.number == line ] miss_rates = [ CGAnalyzer.get_count_for_cache(self.cache, l.events) for l in lines ] ls = ['-', '--', '-.', ':'][gg % 4] self.axs[1].plot(sizes, miss_rates, 's-', label=str(line), alpha=0.7, linestyle=ls) self.min_miss_rates.append(min(miss_rates)) self.max_miss_rates.append(max(miss_rates)) self.axs[1].yaxis.set_major_formatter(ticker.PercentFormatter()) self.axs[1].set_title('set-associativity') self.axs[1].grid() # LINE runs = CGStorage().get_for_param(self.cache, 'LINE_SIZE') sizes = [r.get_specs()[self.cache]['LINE_SIZE'] + 'B' for r in runs] for gg, line in enumerate(self.lines): funcs = [ f for r in runs for f in r.get_funcs() if str(f) == str(self.func) ] lines = [ l for f in funcs for l in f.lines.values() if l.number == line ] miss_rates = [ CGAnalyzer.get_count_for_cache(self.cache, l.events) for l in lines ] ls = ['-', '--', '-.', ':'][gg % 4] self.axs[2].plot(sizes, miss_rates, 's-', label=str(line), alpha=0.7, linestyle=ls) self.min_miss_rates.append(min(miss_rates)) self.max_miss_rates.append(max(miss_rates)) self.axs[2].yaxis.set_major_formatter(ticker.PercentFormatter()) self.axs[2].set_title('line size') self.axs[2].grid() min_miss_rate = floor(min(self.min_miss_rates)) max_miss_rate = max(self.max_miss_rates) self.axs[0].set_ylim([min_miss_rate, max_miss_rate]) self.axs[1].set_ylim([min_miss_rate, max_miss_rate]) self.axs[2].set_ylim([min_miss_rate, max_miss_rate]) self.axs[0].set_ylabel(f'{self.cache} r+w miss rate')