X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=sim%2Fmain.cc;h=f0d10a67cda5583a41fb418c027e436f83b57394;hb=3f7b780af5530cc60228ebd3e895ab26d477614e;hp=ebf96741d1014bbff4f404beac3aa701b47ab7c5;hpb=f722bf515c055847ce44b44a3198a669a7062d33;p=gem5.git diff --git a/sim/main.cc b/sim/main.cc index ebf96741d..f0d10a67c 100644 --- a/sim/main.cc +++ b/sim/main.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003 The Regents of The University of Michigan + * Copyright (c) 2000-2004 The Regents of The University of Michigan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,29 +37,32 @@ #include #include -#include "host.hh" -#include "misc.hh" - -#include "copyright.hh" -#include "inifile.hh" -#include "configfile.hh" -#include "pollevent.hh" -#include "statistics.hh" -#include "sim_events.hh" -#include "sim_exit.hh" -#include "sim_object.hh" -#include "sim_stats.hh" -#include "sim_time.hh" -#include "smt.hh" - -#include "base_cpu.hh" -#include "async.hh" +#include "base/copyright.hh" +#include "base/inifile.hh" +#include "base/misc.hh" +#include "base/pollevent.hh" +#include "base/statistics.hh" +#include "base/time.hh" +#include "cpu/base_cpu.hh" +#include "cpu/full_cpu/smt.hh" +#include "sim/async.hh" +#include "sim/builder.hh" +#include "sim/configfile.hh" +#include "sim/host.hh" +#include "sim/sim_events.hh" +#include "sim/sim_exit.hh" +#include "sim/sim_init.hh" +#include "sim/sim_object.hh" +#include "sim/stat_control.hh" +#include "sim/stats.hh" +#include "sim/universe.hh" using namespace std; // See async.h. volatile bool async_event = false; volatile bool async_dump = false; +volatile bool async_dumpreset = false; volatile bool async_exit = false; volatile bool async_io = false; volatile bool async_alarm = false; @@ -72,6 +75,13 @@ dumpStatsHandler(int sigtype) async_dump = true; } +void +dumprstStatsHandler(int sigtype) +{ + async_event = true; + async_dumpreset = true; +} + /// Exit signal handler. void exitNowHandler(int sigtype) @@ -218,15 +228,15 @@ main(int argc, char **argv) myProgName = argv[0]; signal(SIGFPE, SIG_IGN); // may occur on misspeculated paths - signal(SIGPIPE, SIG_IGN); signal(SIGTRAP, SIG_IGN); - signal(SIGUSR1, dumpStatsHandler); // dump intermediate stats - signal(SIGINT, exitNowHandler); // dump final stats and exit + signal(SIGUSR1, dumpStatsHandler); // dump intermediate stats + signal(SIGUSR2, dumprstStatsHandler); // dump and reset stats + signal(SIGINT, exitNowHandler); // dump final stats and exit sayHello(cerr); // Initialize statistics database - initBaseStats(); + Stats::InitSimStats(); vector cppArgs; @@ -347,12 +357,12 @@ main(int argc, char **argv) // Print hello message to stats file if it's actually a file. If // it's not (i.e. it's cout or cerr) then we already did it above. - if (statStreamIsFile) - sayHello(*statStream); + if (outputStream != &cout && outputStream != &cerr) + sayHello(*outputStream); // Echo command line and all parameter settings to stats file as well. - echoCommandLine(argc, argv, *statStream); - ParamContext::showAllContexts(*statStream); + echoCommandLine(argc, argv, *outputStream); + ParamContext::showAllContexts(builderStream()); // Now process the configuration hierarchy and create the SimObjects. ConfigHierarchy configHierarchy(simConfigDB); @@ -380,7 +390,10 @@ main(int argc, char **argv) #endif // Check to make sure that the stats package is properly initialized - Statistics::check(); + Stats::check(); + + // Reset to put the stats in a consistent state. + Stats::reset(); // Nothing to simulate if we don't have at least one CPU somewhere. if (BaseCPU::numSimulatedCPUs() == 0) { @@ -388,6 +401,9 @@ main(int argc, char **argv) exit(1); } + SimInit(); + warn("Entering event queue. Starting simulation...\n"); + while (!mainEventQueue.empty()) { assert(curTick <= mainEventQueue.nextTick() && "event scheduled in the past"); @@ -401,7 +417,16 @@ main(int argc, char **argv) async_event = false; if (async_dump) { async_dump = false; - new DumpStatsEvent(); + + using namespace Stats; + SetupEvent(Dump, curTick); + } + + if (async_dumpreset) { + async_dumpreset = false; + + using namespace Stats; + SetupEvent(Dump | Reset, curTick); } if (async_exit) { @@ -421,7 +446,7 @@ main(int argc, char **argv) // simulation to terminate (hit max cycles/insts, signal, // simulated system halts/exits) generates an exit event, so we // should never run out of events on the queue. - exitNow("improperly exited event loop!", 1); + exitNow("no events on event loop! All CPUs must be idle.", 1); return 0; }