m5stats2streamline.py (10016:dffa80408656) | m5stats2streamline.py (10354:2d6d7a056a38) |
---|---|
1#!/usr/bin/env python 2 | 1#!/usr/bin/env python 2 |
3# Copyright (c) 2012 ARM Limited | 3# Copyright (c) 2012, 2014 ARM Limited |
4# All rights reserved 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating 9# to a hardware implementation of the functionality of the software 10# licensed hereunder. You may use the software subject to the license 11# terms below provided that you ensure that this notice is replicated --- 125 unchanged lines hidden (view full) --- 137 print "Parsing gem5 config.ini file..." 138 print config_file 139 print "===============================\n" 140 config = ConfigParser() 141 if not config.read(config_file): 142 print "ERROR: config file '", config_file, "' not found" 143 sys.exit(1) 144 | 4# All rights reserved 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating 9# to a hardware implementation of the functionality of the software 10# licensed hereunder. You may use the software subject to the license 11# terms below provided that you ensure that this notice is replicated --- 125 unchanged lines hidden (view full) --- 137 print "Parsing gem5 config.ini file..." 138 print config_file 139 print "===============================\n" 140 config = ConfigParser() 141 if not config.read(config_file): 142 print "ERROR: config file '", config_file, "' not found" 143 sys.exit(1) 144 |
145 if config.has_section("system.cpu"): | 145 if config.has_section("system.cluster.cpu"): |
146 num_cpus = 1 147 else: 148 num_cpus = 0 | 146 num_cpus = 1 147 else: 148 num_cpus = 0 |
149 while config.has_section("system.cpu" + str(num_cpus)): | 149 while config.has_section("system.cluster.cpu" + str(num_cpus)): |
150 num_cpus += 1 151 | 150 num_cpus += 1 151 |
152 if config.has_section("system.l2"): | 152 if config.has_section("system.cluster.l2_cache"): |
153 num_l2 = 1 154 else: 155 num_l2 = 0 | 153 num_l2 = 1 154 else: 155 num_l2 = 0 |
156 while config.has_section("system.l2" + str(num_l2)): | 156 while config.has_section("system.cluster.l2_cache" + str(num_l2)): |
157 num_l2 += 1 158 159 print "Num CPUs:", num_cpus 160 print "Num L2s:", num_l2 161 print "" 162 163 return (num_cpus, num_l2) 164 --- 543 unchanged lines hidden (view full) --- 708 f = open(filename, "w") 709 txt = ET.tostring(xml) 710 f.write(minidom.parseString(txt).toprettyxml()) 711 f.close() 712 713 714# StatsEntry that contains individual statistics 715class StatsEntry(object): | 157 num_l2 += 1 158 159 print "Num CPUs:", num_cpus 160 print "Num L2s:", num_l2 161 print "" 162 163 return (num_cpus, num_l2) 164 --- 543 unchanged lines hidden (view full) --- 708 f = open(filename, "w") 709 txt = ET.tostring(xml) 710 f.write(minidom.parseString(txt).toprettyxml()) 711 f.close() 712 713 714# StatsEntry that contains individual statistics 715class StatsEntry(object): |
716 def __init__(self, name, group, group_index, per_cpu, per_switchcpu, key): | 716 def __init__(self, name, group, group_index, per_cpu, key): |
717 718 # Full name of statistics 719 self.name = name 720 721 # Streamline group name that statistic will belong to 722 self.group = group 723 724 # Index of statistics within group (used to change colors within groups) --- 6 unchanged lines hidden (view full) --- 731 732 # Regex for this stat (string version used to construct union regex) 733 self.regex_string = "^" + name + "\s+([\d\.]+)" 734 self.regex = re.compile("^" + name + "\s+([\d\.e\-]+)\s+# (.*)$", re.M) 735 self.description = "" 736 737 # Whether this stat is use per CPU or not 738 self.per_cpu = per_cpu | 717 718 # Full name of statistics 719 self.name = name 720 721 # Streamline group name that statistic will belong to 722 self.group = group 723 724 # Index of statistics within group (used to change colors within groups) --- 6 unchanged lines hidden (view full) --- 731 732 # Regex for this stat (string version used to construct union regex) 733 self.regex_string = "^" + name + "\s+([\d\.]+)" 734 self.regex = re.compile("^" + name + "\s+([\d\.e\-]+)\s+# (.*)$", re.M) 735 self.description = "" 736 737 # Whether this stat is use per CPU or not 738 self.per_cpu = per_cpu |
739 self.per_switchcpu = per_switchcpu | |
740 741 # Key used in .apc protocol (as described in captured.xml) 742 self.key = key 743 744 # List of values of stat per timestamp 745 self.values = [] 746 747 # Whether this stat has been found for the current timestamp --- 8 unchanged lines hidden (view full) --- 756 757 # Create per-CPU stat name and regex, etc. 758 if self.per_cpu: 759 self.per_cpu_regex_string = [] 760 self.per_cpu_regex = [] 761 self.per_cpu_name = [] 762 self.per_cpu_found = [] 763 for i in range(num_cpus): | 739 740 # Key used in .apc protocol (as described in captured.xml) 741 self.key = key 742 743 # List of values of stat per timestamp 744 self.values = [] 745 746 # Whether this stat has been found for the current timestamp --- 8 unchanged lines hidden (view full) --- 755 756 # Create per-CPU stat name and regex, etc. 757 if self.per_cpu: 758 self.per_cpu_regex_string = [] 759 self.per_cpu_regex = [] 760 self.per_cpu_name = [] 761 self.per_cpu_found = [] 762 for i in range(num_cpus): |
764 # Resuming from checkpoints results in using "switch_cpus" 765 if per_switchcpu: 766 per_cpu_name = "system.switch_cpus" | 763 if num_cpus > 1: 764 per_cpu_name = re.sub("#", str(i), self.name) |
767 else: | 765 else: |
768 per_cpu_name = "system.cpu" | 766 per_cpu_name = re.sub("#", "", self.name) |
769 | 767 |
770 # No CPU number appends if num_cpus == 1 771 if num_cpus > 1: 772 per_cpu_name += str(i) 773 per_cpu_name += "." + self.name | |
774 self.per_cpu_name.append(per_cpu_name) 775 print "\t", per_cpu_name 776 777 self.per_cpu_regex_string.\ 778 append("^" + per_cpu_name + "\s+[\d\.]+") 779 self.per_cpu_regex.append(re.compile("^" + per_cpu_name + \ 780 "\s+([\d\.e\-]+)\s+# (.*)$", re.M)) 781 self.values.append([]) --- 8 unchanged lines hidden (view full) --- 790# Global stats object that contains the list of stats entries 791# and other utility functions 792class Stats(object): 793 def __init__(self): 794 self.stats_list = [] 795 self.tick_list = [] 796 self.next_key = 1 797 | 768 self.per_cpu_name.append(per_cpu_name) 769 print "\t", per_cpu_name 770 771 self.per_cpu_regex_string.\ 772 append("^" + per_cpu_name + "\s+[\d\.]+") 773 self.per_cpu_regex.append(re.compile("^" + per_cpu_name + \ 774 "\s+([\d\.e\-]+)\s+# (.*)$", re.M)) 775 self.values.append([]) --- 8 unchanged lines hidden (view full) --- 784# Global stats object that contains the list of stats entries 785# and other utility functions 786class Stats(object): 787 def __init__(self): 788 self.stats_list = [] 789 self.tick_list = [] 790 self.next_key = 1 791 |
798 def register(self, name, group, group_index, per_cpu, per_switchcpu): | 792 def register(self, name, group, group_index, per_cpu): |
799 print "registering stat:", name, "group:", group, group_index 800 self.stats_list.append(StatsEntry(name, group, group_index, per_cpu, \ | 793 print "registering stat:", name, "group:", group, group_index 794 self.stats_list.append(StatsEntry(name, group, group_index, per_cpu, \ |
801 per_switchcpu, self.next_key)) | 795 self.next_key)) |
802 self.next_key += 1 803 804 # Union of all stats to accelerate parsing speed 805 def createStatsRegex(self): 806 regex_strings = []; 807 print "\nnum entries in stats_list", len(self.stats_list) 808 for entry in self.stats_list: 809 if entry.per_cpu: --- 21 unchanged lines hidden (view full) --- 831 stats = Stats() 832 833 per_cpu_stat_groups = config.options('PER_CPU_STATS') 834 for group in per_cpu_stat_groups: 835 i = 0 836 per_cpu_stats_list = config.get('PER_CPU_STATS', group).split('\n') 837 for item in per_cpu_stats_list: 838 if item: | 796 self.next_key += 1 797 798 # Union of all stats to accelerate parsing speed 799 def createStatsRegex(self): 800 regex_strings = []; 801 print "\nnum entries in stats_list", len(self.stats_list) 802 for entry in self.stats_list: 803 if entry.per_cpu: --- 21 unchanged lines hidden (view full) --- 825 stats = Stats() 826 827 per_cpu_stat_groups = config.options('PER_CPU_STATS') 828 for group in per_cpu_stat_groups: 829 i = 0 830 per_cpu_stats_list = config.get('PER_CPU_STATS', group).split('\n') 831 for item in per_cpu_stats_list: 832 if item: |
839 stats.register(item, group, i, True, False) | 833 stats.register(item, group, i, True) |
840 i += 1 841 | 834 i += 1 835 |
842 per_cpu_stat_groups = config.options('PER_SWITCHCPU_STATS') 843 for group in per_cpu_stat_groups: 844 i = 0 845 per_cpu_stats_list = \ 846 config.get('PER_SWITCHCPU_STATS', group).split('\n') 847 for item in per_cpu_stats_list: 848 if item: 849 stats.register(item, group, i, True, True) 850 i += 1 851 | |
852 per_l2_stat_groups = config.options('PER_L2_STATS') 853 for group in per_l2_stat_groups: 854 i = 0 855 per_l2_stats_list = config.get('PER_L2_STATS', group).split('\n') 856 for item in per_l2_stats_list: 857 if item: 858 for l2 in range(num_l2): | 836 per_l2_stat_groups = config.options('PER_L2_STATS') 837 for group in per_l2_stat_groups: 838 i = 0 839 per_l2_stats_list = config.get('PER_L2_STATS', group).split('\n') 840 for item in per_l2_stats_list: 841 if item: 842 for l2 in range(num_l2): |
859 name = item 860 prefix = "system.l2" | |
861 if num_l2 > 1: | 843 if num_l2 > 1: |
862 prefix += str(l2) 863 prefix += "." 864 name = prefix + name 865 stats.register(name, group, i, False, False) | 844 name = re.sub("#", str(l2), item) 845 else: 846 name = re.sub("#", "", item) 847 stats.register(name, group, i, False) |
866 i += 1 867 868 other_stat_groups = config.options('OTHER_STATS') 869 for group in other_stat_groups: 870 i = 0 871 other_stats_list = config.get('OTHER_STATS', group).split('\n') 872 for item in other_stats_list: 873 if item: | 848 i += 1 849 850 other_stat_groups = config.options('OTHER_STATS') 851 for group in other_stat_groups: 852 i = 0 853 other_stats_list = config.get('OTHER_STATS', group).split('\n') 854 for item in other_stats_list: 855 if item: |
874 stats.register(item, group, i, False, False) | 856 stats.register(item, group, i, False) |
875 i += 1 876 877 stats.createStatsRegex() 878 879 return stats 880 881# Parse and read in gem5 stats file 882# Streamline counters are organized per CPU --- 158 unchanged lines hidden (view full) --- 1041 target.set("name", "gem5") 1042 target.set("sample_rate", "1000") 1043 target.set("cores", str(num_cpus)) 1044 1045 counters = ET.SubElement(xml, "counters") 1046 for stat in stats.stats_list: 1047 s = ET.SubElement(counters, "counter") 1048 stat_name = re.sub("\.", "_", stat.short_name) | 857 i += 1 858 859 stats.createStatsRegex() 860 861 return stats 862 863# Parse and read in gem5 stats file 864# Streamline counters are organized per CPU --- 158 unchanged lines hidden (view full) --- 1023 target.set("name", "gem5") 1024 target.set("sample_rate", "1000") 1025 target.set("cores", str(num_cpus)) 1026 1027 counters = ET.SubElement(xml, "counters") 1028 for stat in stats.stats_list: 1029 s = ET.SubElement(counters, "counter") 1030 stat_name = re.sub("\.", "_", stat.short_name) |
1031 stat_name = re.sub("#", "", stat_name) |
|
1049 s.set("title", stat.group) 1050 s.set("name", stat_name) 1051 s.set("color", "0x00000000") 1052 s.set("key", "0x%08x" % stat.key) 1053 s.set("type", stat_name) 1054 s.set("event", "0x00000000") 1055 if stat.per_cpu: 1056 s.set("per_cpu", "yes") --- 212 unchanged lines hidden --- | 1032 s.set("title", stat.group) 1033 s.set("name", stat_name) 1034 s.set("color", "0x00000000") 1035 s.set("key", "0x%08x" % stat.key) 1036 s.set("type", stat_name) 1037 s.set("event", "0x00000000") 1038 if stat.per_cpu: 1039 s.set("per_cpu", "yes") --- 212 unchanged lines hidden --- |