checkpoint_aggregator.py (7443:cbedf338fc44) checkpoint_aggregator.py (8166:c40d598146ec)
1# Copyright (c) 2009 The Regents of The University of Michigan
1# Copyright (c) 2009 The Regents of The University of Michigan
2# Copyright (c) 2011 Advanced Micro Devices, Inc.
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the

--- 69 unchanged lines hidden (view full) ---

79 for sec in config.sections():
80 if re.compile("cpu").search(sec):
81 newsec = re.sub("cpu", "cpu" + str(i), sec)
82 merged.add_section(newsec)
83 if re.compile("workload$").search(sec):
84 merged.set(newsec, "M5_pid", i)
85
86 items = config.items(sec)
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;
9# redistributions in binary form must reproduce the above copyright
10# notice, this list of conditions and the following disclaimer in the

--- 69 unchanged lines hidden (view full) ---

80 for sec in config.sections():
81 if re.compile("cpu").search(sec):
82 newsec = re.sub("cpu", "cpu" + str(i), sec)
83 merged.add_section(newsec)
84 if re.compile("workload$").search(sec):
85 merged.set(newsec, "M5_pid", i)
86
87 items = config.items(sec)
87 for item in items:
88 if item[0] == "ppn":
89 if config.getint(sec, "tag") != 0:
90 merged.set(newsec, item[0], int(item[1]) + page_ptr)
91 continue
92 elif item[0] == "asn":
93 tmp = re.compile("(.*).Entry(\d+)").search(sec).groups()
94 if config.has_option(tmp[0], "nlu"):
95 size = config.getint(tmp[0], "nlu")
96 if int(tmp[1]) < size:
88 if options.alpha:
89 for item in items:
90 if item[0] == "ppn":
91 if config.getint(sec, "tag") != 0:
92 merged.set(newsec, item[0], int(item[1]) + page_ptr)
93 continue
94 elif item[0] == "asn":
95 tmp = re.compile("(.*).Entry(\d+)").search(sec).groups()
96 if config.has_option(tmp[0], "nlu"):
97 size = config.getint(tmp[0], "nlu")
98 if int(tmp[1]) < size:
99 merged.set(newsec, item[0], i)
100 continue
101 else:
97 merged.set(newsec, item[0], i)
98 continue
102 merged.set(newsec, item[0], i)
103 continue
99 else:
100 merged.set(newsec, item[0], i)
104 merged.set(newsec, item[0], item[1])
105 else:a #x86
106 for item in items:
107 if item[0] == "paddr":
108 merged.set(newsec, item[0], int(item[1]) + (page_ptr << 12))
101 continue
109 continue
102 merged.set(newsec, item[0], item[1])
110 merged.set(newsec, item[0], item[1])
111
103 elif sec == "system":
104 pass
105 elif sec == "Globals":
106 tick = config.getint(sec, "curTick")
107 if tick > max_curtick:
108 max_curtick = tick
109 when = config.getint("system.cpu.tickEvent", "_when")
110 else:
111 if i == 0:
112 merged.add_section(sec)
113 for item in config.items(sec):
114 merged.set(sec, item[0], item[1])
115 if item[0] == "curtick":
116 merged.optionxform(str("curTick"))
117 elif item[0] == "numevents":
118 merged.optionxform(str("numEvents"))
119
112 elif sec == "system":
113 pass
114 elif sec == "Globals":
115 tick = config.getint(sec, "curTick")
116 if tick > max_curtick:
117 max_curtick = tick
118 when = config.getint("system.cpu.tickEvent", "_when")
119 else:
120 if i == 0:
121 merged.add_section(sec)
122 for item in config.items(sec):
123 merged.set(sec, item[0], item[1])
124 if item[0] == "curtick":
125 merged.optionxform(str("curTick"))
126 elif item[0] == "numevents":
127 merged.optionxform(str("numEvents"))
128
120 page_ptr = page_ptr + int(config.get("system", "page_ptr"))
129 page_ptr = page_ptr + int(config.get("system", "pagePtr"))
121
122 ### memory stuff
123 f = open(cpts[i] + "/system.physmem.physmem", "rb")
124 gf = gzip.GzipFile(fileobj=f, mode="rb")
130
131 ### memory stuff
132 f = open(cpts[i] + "/system.physmem.physmem", "rb")
133 gf = gzip.GzipFile(fileobj=f, mode="rb")
125 pages = int(config.get("system", "page_ptr"))
134 pages = int(config.get("system", "pagePtr"))
126 print "pages to be read: ", pages
127
128 x = 0
129 while x < pages:
135 print "pages to be read: ", pages
136
137 x = 0
138 while x < pages:
130 bytesRead = gf.read(1 << 13)
139 if options.alpha:
140 bytesRead = gf.read(1 << 13)
141 else: #x86
142 bytesRead = gf.read(1 << 12)
131 merged_mem.write(bytesRead)
132 x += 1
133
134 gf.close()
135 f.close()
136
137 merged.add_section("system")
143 merged_mem.write(bytesRead)
144 x += 1
145
146 gf.close()
147 f.close()
148
149 merged.add_section("system")
138 merged.set("system", "page_ptr", page_ptr)
150 merged.set("system", "pagePtr", page_ptr)
151 merged.set("system", "nextPID", len(args))
152
139 print "WARNING: "
153 print "WARNING: "
140 print "Make sure the simulation using this checkpoint has at least "
141 if page_ptr > (1<<20):
142 print "8G ",
143 elif page_ptr > (1<<19):
144 print "4G ",
145 elif page_ptr > (1<<18):
146 print "2G ",
147 elif page_ptr > (1<<17):
148 print "1G ",
149 elif page_ptr > (1<<16):
150 print "512KB ",
151 else:
152 print "this is a small sim, you're probably fine",
153 print "of memory."
154 print "Make sure the simulation using this checkpoint has at least ",
155 if options.alpha:
156 print page_ptr, "x 8K of memory"
157 else: # assume x86
158 print page_ptr, "x 4K of memory"
154
155 merged.add_section("Globals")
156 merged.set("Globals", "curTick", max_curtick)
157
158 for i in xrange(len(args)):
159 merged.set("system.cpu" + str(i) + ".tickEvent", "_when", when)
160
161 merged.write(file(fullpath + "/m5.cpt", "wb"))
162 merged_mem.close()
163 myfile.close()
164
165if __name__ == "__main__":
166
167 parser = optparse.OptionParser()
168 parser.add_option("--prefix", type="string", default="agg")
159
160 merged.add_section("Globals")
161 merged.set("Globals", "curTick", max_curtick)
162
163 for i in xrange(len(args)):
164 merged.set("system.cpu" + str(i) + ".tickEvent", "_when", when)
165
166 merged.write(file(fullpath + "/m5.cpt", "wb"))
167 merged_mem.close()
168 myfile.close()
169
170if __name__ == "__main__":
171
172 parser = optparse.OptionParser()
173 parser.add_option("--prefix", type="string", default="agg")
174 # If not alpha, then assume x86. Any other ISAs would need
175 # extra stuff in this script to appropriately parse their page tables
176 # and understand page sizes.
177 parser.add_option("--alpha", action="store_true")
169
170 (options, args) = parser.parse_args()
171
172 aggregate(options, args)
173
178
179 (options, args) = parser.parse_args()
180
181 aggregate(options, args)
182