Simulation.py (9140:cfd2a8364ea1) | Simulation.py (9151:a4faa7dde56c) |
---|---|
1# Copyright (c) 2006-2008 The Regents of The University of Michigan 2# Copyright (c) 2010 Advanced Micro Devices, Inc. 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; --- 200 unchanged lines hidden (view full) --- 209 exit_event = m5.simulate(sim_ticks - m5.curTick()) 210 if exit_event.getCause() == "simulate() limit reached": 211 m5.checkpoint(joinpath(cptdir, "cpt.%d")) 212 num_checkpoints += 1 213 214 return exit_cause 215 216def benchCheckpoints(options, maxtick, cptdir): | 1# Copyright (c) 2006-2008 The Regents of The University of Michigan 2# Copyright (c) 2010 Advanced Micro Devices, Inc. 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; --- 200 unchanged lines hidden (view full) --- 209 exit_event = m5.simulate(sim_ticks - m5.curTick()) 210 if exit_event.getCause() == "simulate() limit reached": 211 m5.checkpoint(joinpath(cptdir, "cpt.%d")) 212 num_checkpoints += 1 213 214 return exit_cause 215 216def benchCheckpoints(options, maxtick, cptdir): |
217 if options.fast_forward: 218 m5.stats.reset() 219 220 print "**** REAL SIMULATION ****" | |
221 exit_event = m5.simulate(maxtick) 222 exit_cause = exit_event.getCause() 223 224 num_checkpoints = 0 225 max_checkpoints = options.max_checkpoints 226 227 while exit_cause == "checkpoint": 228 m5.checkpoint(joinpath(cptdir, "cpt.%d")) 229 num_checkpoints += 1 230 if num_checkpoints == max_checkpoints: 231 exit_cause = "maximum %d checkpoints dropped" % max_checkpoints 232 break 233 234 exit_event = m5.simulate(maxtick - m5.curTick()) 235 exit_cause = exit_event.getCause() 236 237 return exit_cause 238 | 217 exit_event = m5.simulate(maxtick) 218 exit_cause = exit_event.getCause() 219 220 num_checkpoints = 0 221 max_checkpoints = options.max_checkpoints 222 223 while exit_cause == "checkpoint": 224 m5.checkpoint(joinpath(cptdir, "cpt.%d")) 225 num_checkpoints += 1 226 if num_checkpoints == max_checkpoints: 227 exit_cause = "maximum %d checkpoints dropped" % max_checkpoints 228 break 229 230 exit_event = m5.simulate(maxtick - m5.curTick()) 231 exit_cause = exit_event.getCause() 232 233 return exit_cause 234 |
235def repeatSwitch(testsys, repeat_switch_cpu_list, maxtick, switch_freq): 236 print "starting switch loop" 237 while True: 238 exit_event = m5.simulate(switch_freq) 239 exit_cause = exit_event.getCause() 240 241 if exit_cause != "simulate() limit reached": 242 return exit_cause 243 244 print "draining the system" 245 m5.doDrain(testsys) 246 m5.switchCpus(repeat_switch_cpu_list) 247 m5.resume(testsys) 248 249 tmp_cpu_list = [] 250 for old_cpu, new_cpu in repeat_switch_cpu_list: 251 tmp_cpu_list.append((new_cpu, old_cpu)) 252 repeat_switch_cpu_list = tmp_cpu_list 253 254 if (maxtick - m5.curTick()) <= switch_freq: 255 exit_event = m5.simulate(maxtick - m5.curTick()) 256 return exit_event.getCause() 257 |
|
239def run(options, root, testsys, cpu_class): 240 if options.maxtick: 241 maxtick = options.maxtick 242 elif options.maxtime: 243 simtime = m5.ticks.seconds(simtime) 244 print "simulating for: ", simtime 245 maxtick = simtime 246 else: --- 7 unchanged lines hidden (view full) --- 254 cptdir = getcwd() 255 256 if options.fast_forward and options.checkpoint_restore != None: 257 fatal("Can't specify both --fast-forward and --checkpoint-restore") 258 259 if options.standard_switch and not options.caches: 260 fatal("Must specify --caches when using --standard-switch") 261 | 258def run(options, root, testsys, cpu_class): 259 if options.maxtick: 260 maxtick = options.maxtick 261 elif options.maxtime: 262 simtime = m5.ticks.seconds(simtime) 263 print "simulating for: ", simtime 264 maxtick = simtime 265 else: --- 7 unchanged lines hidden (view full) --- 273 cptdir = getcwd() 274 275 if options.fast_forward and options.checkpoint_restore != None: 276 fatal("Can't specify both --fast-forward and --checkpoint-restore") 277 278 if options.standard_switch and not options.caches: 279 fatal("Must specify --caches when using --standard-switch") 280 |
281 if options.standard_switch and options.repeat_switch: 282 fatal("Can't specify both --standard-switch and --repeat-switch") 283 284 if options.repeat_switch and options.take_checkpoints: 285 fatal("Can't specify both --repeat-switch and --take-checkpoints") 286 |
|
262 np = options.num_cpus 263 switch_cpus = None 264 265 if options.prog_interval: 266 for i in xrange(np): 267 testsys.cpu[i].progress_interval = options.prog_interval 268 269 if options.maxinsts: 270 for i in xrange(np): 271 testsys.cpu[i].max_insts_any_thread = options.maxinsts 272 273 if cpu_class: | 287 np = options.num_cpus 288 switch_cpus = None 289 290 if options.prog_interval: 291 for i in xrange(np): 292 testsys.cpu[i].progress_interval = options.prog_interval 293 294 if options.maxinsts: 295 for i in xrange(np): 296 testsys.cpu[i].max_insts_any_thread = options.maxinsts 297 298 if cpu_class: |
274 switch_cpus = [cpu_class(defer_registration=True, cpu_id=(np+i)) | 299 switch_cpus = [cpu_class(defer_registration=True, cpu_id=(i)) |
275 for i in xrange(np)] 276 277 for i in xrange(np): 278 if options.fast_forward: 279 testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) 280 switch_cpus[i].system = testsys 281 switch_cpus[i].workload = testsys.cpu[i].workload 282 switch_cpus[i].clock = testsys.cpu[i].clock 283 # simulation period 284 if options.maxinsts: 285 switch_cpus[i].max_insts_any_thread = options.maxinsts 286 # Add checker cpu if selected 287 if options.checker: 288 switch_cpus[i].addCheckerCpu() 289 290 testsys.switch_cpus = switch_cpus 291 switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] 292 | 300 for i in xrange(np)] 301 302 for i in xrange(np): 303 if options.fast_forward: 304 testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) 305 switch_cpus[i].system = testsys 306 switch_cpus[i].workload = testsys.cpu[i].workload 307 switch_cpus[i].clock = testsys.cpu[i].clock 308 # simulation period 309 if options.maxinsts: 310 switch_cpus[i].max_insts_any_thread = options.maxinsts 311 # Add checker cpu if selected 312 if options.checker: 313 switch_cpus[i].addCheckerCpu() 314 315 testsys.switch_cpus = switch_cpus 316 switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] 317 |
293 if options.standard_switch: 294 if not options.caches: 295 # O3 CPU must have a cache to work. 296 print "O3 CPU must be used with caches" | 318 if options.repeat_switch: 319 if options.cpu_type == "arm_detailed": 320 if not options.caches: 321 print "O3 CPU must be used with caches" 322 sys.exit(1) 323 324 repeat_switch_cpus = [O3_ARM_v7a_3(defer_registration=True, \ 325 cpu_id=(i)) for i in xrange(np)] 326 elif options.cpu_type == "detailed": 327 if not options.caches: 328 print "O3 CPU must be used with caches" 329 sys.exit(1) 330 331 repeat_switch_cpus = [DerivO3CPU(defer_registration=True, \ 332 cpu_id=(i)) for i in xrange(np)] 333 elif options.cpu_type == "inorder": 334 print "inorder CPU switching not supported" |
297 sys.exit(1) | 335 sys.exit(1) |
336 elif options.cpu_type == "timing": 337 repeat_switch_cpus = [TimingSimpleCPU(defer_registration=True, \ 338 cpu_id=(i)) for i in xrange(np)] 339 else: 340 repeat_switch_cpus = [AtomicSimpleCPU(defer_registration=True, \ 341 cpu_id=(i)) for i in xrange(np)] |
|
298 | 342 |
299 switch_cpus = [TimingSimpleCPU(defer_registration=True, cpu_id=(np+i)) | 343 for i in xrange(np): 344 repeat_switch_cpus[i].system = testsys 345 repeat_switch_cpus[i].workload = testsys.cpu[i].workload 346 repeat_switch_cpus[i].clock = testsys.cpu[i].clock 347 348 if options.maxinsts: 349 repeat_switch_cpus[i].max_insts_any_thread = options.maxinsts 350 351 if options.checker: 352 repeat_switch_cpus[i].addCheckerCpu() 353 354 testsys.repeat_switch_cpus = repeat_switch_cpus 355 356 if cpu_class: 357 repeat_switch_cpu_list = [(switch_cpus[i], repeat_switch_cpus[i]) 358 for i in xrange(np)] 359 else: 360 repeat_switch_cpu_list = [(testsys.cpu[i], repeat_switch_cpus[i]) 361 for i in xrange(np)] 362 363 if options.standard_switch: 364 switch_cpus = [TimingSimpleCPU(defer_registration=True, cpu_id=(i)) |
300 for i in xrange(np)] | 365 for i in xrange(np)] |
301 switch_cpus_1 = [DerivO3CPU(defer_registration=True, cpu_id=(2*np+i)) | 366 switch_cpus_1 = [DerivO3CPU(defer_registration=True, cpu_id=(i)) |
302 for i in xrange(np)] 303 304 for i in xrange(np): 305 switch_cpus[i].system = testsys 306 switch_cpus_1[i].system = testsys 307 switch_cpus[i].workload = testsys.cpu[i].workload 308 switch_cpus_1[i].workload = testsys.cpu[i].workload 309 switch_cpus[i].clock = testsys.cpu[i].clock --- 85 unchanged lines hidden (view full) --- 395 if options.standard_switch: 396 print "Switch at instruction count:%d" % \ 397 (testsys.switch_cpus[0].max_insts_any_thread) 398 399 #warmup instruction count may have already been set 400 if options.warmup_insts: 401 exit_event = m5.simulate() 402 else: | 367 for i in xrange(np)] 368 369 for i in xrange(np): 370 switch_cpus[i].system = testsys 371 switch_cpus_1[i].system = testsys 372 switch_cpus[i].workload = testsys.cpu[i].workload 373 switch_cpus_1[i].workload = testsys.cpu[i].workload 374 switch_cpus[i].clock = testsys.cpu[i].clock --- 85 unchanged lines hidden (view full) --- 460 if options.standard_switch: 461 print "Switch at instruction count:%d" % \ 462 (testsys.switch_cpus[0].max_insts_any_thread) 463 464 #warmup instruction count may have already been set 465 if options.warmup_insts: 466 exit_event = m5.simulate() 467 else: |
403 exit_event = m5.simulate(options.warmup) | 468 exit_event = m5.simulate(options.standard_switch) |
404 print "Switching CPUS @ tick %s" % (m5.curTick()) 405 print "Simulation ends instruction count:%d" % \ 406 (testsys.switch_cpus_1[0].max_insts_any_thread) 407 m5.drain(testsys) 408 m5.switchCpus(switch_cpu_list1) 409 m5.resume(testsys) 410 411 # If we're taking and restoring checkpoints, use checkpoint_dir --- 8 unchanged lines hidden (view full) --- 420 421 if options.take_checkpoints != None : 422 # Checkpoints being taken via the command line at <when> and at 423 # subsequent periods of <period>. Checkpoint instructions 424 # received from the benchmark running are ignored and skipped in 425 # favor of command line checkpoint instructions. 426 exit_cause = scriptCheckpoints(options) 427 else: | 469 print "Switching CPUS @ tick %s" % (m5.curTick()) 470 print "Simulation ends instruction count:%d" % \ 471 (testsys.switch_cpus_1[0].max_insts_any_thread) 472 m5.drain(testsys) 473 m5.switchCpus(switch_cpu_list1) 474 m5.resume(testsys) 475 476 # If we're taking and restoring checkpoints, use checkpoint_dir --- 8 unchanged lines hidden (view full) --- 485 486 if options.take_checkpoints != None : 487 # Checkpoints being taken via the command line at <when> and at 488 # subsequent periods of <period>. Checkpoint instructions 489 # received from the benchmark running are ignored and skipped in 490 # favor of command line checkpoint instructions. 491 exit_cause = scriptCheckpoints(options) 492 else: |
493 if options.fast_forward: 494 m5.stats.reset() 495 print "**** REAL SIMULATION ****" 496 |
|
428 # If checkpoints are being taken, then the checkpoint instruction 429 # will occur in the benchmark code it self. | 497 # If checkpoints are being taken, then the checkpoint instruction 498 # will occur in the benchmark code it self. |
430 exit_cause = benchCheckpoints(options, maxtick, cptdir) | 499 if options.repeat_switch and maxtick > options.repeat_switch: 500 exit_cause = repeatSwitch(testsys, repeat_switch_cpu_list, 501 maxtick, options.repeat_switch) 502 else: 503 exit_cause = benchCheckpoints(options, maxtick, cptdir) |
431 432 print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause) 433 if options.checkpoint_at_end: 434 m5.checkpoint(joinpath(cptdir, "cpt.%d")) | 504 505 print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause) 506 if options.checkpoint_at_end: 507 m5.checkpoint(joinpath(cptdir, "cpt.%d")) |