main.cc revision 2889
12SN/A/*
21762SN/A * Copyright (c) 2000-2005 The Regents of The University of Michigan
32SN/A * All rights reserved.
42SN/A *
52SN/A * Redistribution and use in source and binary forms, with or without
62SN/A * modification, are permitted provided that the following conditions are
72SN/A * met: redistributions of source code must retain the above copyright
82SN/A * notice, this list of conditions and the following disclaimer;
92SN/A * redistributions in binary form must reproduce the above copyright
102SN/A * notice, this list of conditions and the following disclaimer in the
112SN/A * documentation and/or other materials provided with the distribution;
122SN/A * neither the name of the copyright holders nor the names of its
132SN/A * contributors may be used to endorse or promote products derived from
142SN/A * this software without specific prior written permission.
152SN/A *
162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Steve Raasch
292665Ssaidi@eecs.umich.edu *          Nathan Binkert
302665Ssaidi@eecs.umich.edu *          Steve Reinhardt
312SN/A */
322SN/A
332SN/A///
342SN/A/// @file sim/main.cc
352SN/A///
362655Sstever@eecs.umich.edu#include <Python.h>	// must be before system headers... see Python docs
372655Sstever@eecs.umich.edu
382SN/A#include <sys/types.h>
392SN/A#include <sys/stat.h>
401399SN/A#include <errno.h>
411396SN/A#include <libgen.h>
422SN/A#include <stdlib.h>
432SN/A#include <signal.h>
442729Ssaidi@eecs.umich.edu#include <getopt.h>
452SN/A
461310SN/A#include <list>
472SN/A#include <string>
482SN/A#include <vector>
492SN/A
502667Sstever@eecs.umich.edu#include "base/callback.hh"
5156SN/A#include "base/inifile.hh"
52146SN/A#include "base/misc.hh"
531388SN/A#include "base/output.hh"
5456SN/A#include "base/pollevent.hh"
5556SN/A#include "base/statistics.hh"
561311SN/A#include "base/str.hh"
57400SN/A#include "base/time.hh"
581717SN/A#include "cpu/base.hh"
591717SN/A#include "cpu/smt.hh"
602738Sstever@eecs.umich.edu#include "mem/mem_object.hh"
612738Sstever@eecs.umich.edu#include "mem/port.hh"
62146SN/A#include "sim/async.hh"
63146SN/A#include "sim/builder.hh"
64146SN/A#include "sim/host.hh"
652797Sktlim@umich.edu#include "sim/serialize.hh"
6656SN/A#include "sim/sim_events.hh"
6756SN/A#include "sim/sim_exit.hh"
6856SN/A#include "sim/sim_object.hh"
69695SN/A#include "sim/stat_control.hh"
70695SN/A#include "sim/stats.hh"
711696SN/A#include "sim/root.hh"
722SN/A
732SN/Ausing namespace std;
742SN/A
752SN/A// See async.h.
762SN/Avolatile bool async_event = false;
772SN/Avolatile bool async_dump = false;
78329SN/Avolatile bool async_dumpreset = false;
792SN/Avolatile bool async_exit = false;
802SN/Avolatile bool async_io = false;
812SN/Avolatile bool async_alarm = false;
822SN/A
832SN/A/// Stats signal handler.
842SN/Avoid
852SN/AdumpStatsHandler(int sigtype)
862SN/A{
872SN/A    async_event = true;
882SN/A    async_dump = true;
892SN/A}
902SN/A
91329SN/Avoid
92329SN/AdumprstStatsHandler(int sigtype)
93329SN/A{
94329SN/A    async_event = true;
95329SN/A    async_dumpreset = true;
96329SN/A}
97329SN/A
982SN/A/// Exit signal handler.
992SN/Avoid
1002SN/AexitNowHandler(int sigtype)
1012SN/A{
1022SN/A    async_event = true;
1032SN/A    async_exit = true;
1042SN/A}
1052SN/A
106764SN/A/// Abort signal handler.
107764SN/Avoid
108764SN/AabortHandler(int sigtype)
109764SN/A{
110764SN/A    cerr << "Program aborted at cycle " << curTick << endl;
111764SN/A
112764SN/A#if TRACING_ON
113764SN/A    // dump trace buffer, if there is one
114764SN/A    Trace::theLog.dump(cerr);
115764SN/A#endif
116764SN/A}
117764SN/A
1182763Sstever@eecs.umich.eduextern "C" { void init_cc_main(); }
1192SN/A
1202SN/Aint
1212SN/Amain(int argc, char **argv)
1222SN/A{
1232SN/A    signal(SIGFPE, SIG_IGN);		// may occur on misspeculated paths
1242SN/A    signal(SIGTRAP, SIG_IGN);
125329SN/A    signal(SIGUSR1, dumpStatsHandler);		// dump intermediate stats
126329SN/A    signal(SIGUSR2, dumprstStatsHandler);	// dump and reset stats
127329SN/A    signal(SIGINT, exitNowHandler);		// dump final stats and exit
128764SN/A    signal(SIGABRT, abortHandler);
1292SN/A
1302655Sstever@eecs.umich.edu    Py_SetProgramName(argv[0]);
1312667Sstever@eecs.umich.edu
1322667Sstever@eecs.umich.edu    // default path to m5 python code is the currently executing
1332889Sbinkertn@umich.edu    // file... Python ZipImporter will find embedded zip archive.
1342889Sbinkertn@umich.edu    // The M5_ARCHIVE environment variable can be used to override this.
1352889Sbinkertn@umich.edu    char *m5_archive = getenv("M5_ARCHIVE");
1362889Sbinkertn@umich.edu    string pythonpath = m5_archive ? m5_archive : argv[0];
1372667Sstever@eecs.umich.edu
1382667Sstever@eecs.umich.edu    char *oldpath = getenv("PYTHONPATH");
1392667Sstever@eecs.umich.edu    if (oldpath != NULL) {
1402889Sbinkertn@umich.edu        pythonpath += ":";
1412889Sbinkertn@umich.edu        pythonpath += oldpath;
1422667Sstever@eecs.umich.edu    }
1432667Sstever@eecs.umich.edu
1442889Sbinkertn@umich.edu    if (setenv("PYTHONPATH", pythonpath.c_str(), true) == -1)
1452667Sstever@eecs.umich.edu        fatal("setenv: %s\n", strerror(errno));
1462667Sstever@eecs.umich.edu
1472667Sstever@eecs.umich.edu    // initialize embedded Python interpreter
1482655Sstever@eecs.umich.edu    Py_Initialize();
1492655Sstever@eecs.umich.edu    PySys_SetArgv(argc, argv);
1501311SN/A
1512763Sstever@eecs.umich.edu    // initialize SWIG 'cc_main' module
1522763Sstever@eecs.umich.edu    init_cc_main();
1531703SN/A
1542889Sbinkertn@umich.edu    PyRun_SimpleString("import m5");
1552889Sbinkertn@umich.edu    PyRun_SimpleString("m5.main()");
1562667Sstever@eecs.umich.edu
1572667Sstever@eecs.umich.edu    // clean up Python intepreter.
1582655Sstever@eecs.umich.edu    Py_Finalize();
1592667Sstever@eecs.umich.edu}
1601388SN/A
1612762Sstever@eecs.umich.edu
1622762Sstever@eecs.umich.eduvoid
1632762Sstever@eecs.umich.edusetOutputDir(const string &dir)
1642762Sstever@eecs.umich.edu{
1652762Sstever@eecs.umich.edu    simout.setDirectory(dir);
1662762Sstever@eecs.umich.edu}
1672762Sstever@eecs.umich.edu
1682762Sstever@eecs.umich.edu
1692738Sstever@eecs.umich.eduIniFile inifile;
1702667Sstever@eecs.umich.edu
1712738Sstever@eecs.umich.eduSimObject *
1722738Sstever@eecs.umich.educreateSimObject(const string &name)
1732738Sstever@eecs.umich.edu{
1742738Sstever@eecs.umich.edu    return SimObjectClass::createObject(inifile, name);
1752738Sstever@eecs.umich.edu}
1762738Sstever@eecs.umich.edu
1772738Sstever@eecs.umich.edu
1782738Sstever@eecs.umich.edu/**
1792738Sstever@eecs.umich.edu * Pointer to the Python function that maps names to SimObjects.
1802738Sstever@eecs.umich.edu */
1812738Sstever@eecs.umich.eduPyObject *resolveFunc = NULL;
1822738Sstever@eecs.umich.edu
1832738Sstever@eecs.umich.edu/**
1842738Sstever@eecs.umich.edu * Convert a pointer to the Python object that SWIG wraps around a C++
1852738Sstever@eecs.umich.edu * SimObject pointer back to the actual C++ pointer.  See main.i.
1862738Sstever@eecs.umich.edu */
1872738Sstever@eecs.umich.eduextern "C" SimObject *convertSwigSimObjectPtr(PyObject *);
1882738Sstever@eecs.umich.edu
1892738Sstever@eecs.umich.edu
1902738Sstever@eecs.umich.eduSimObject *
1912738Sstever@eecs.umich.eduresolveSimObject(const string &name)
1922738Sstever@eecs.umich.edu{
1932738Sstever@eecs.umich.edu    PyObject *pyPtr = PyEval_CallFunction(resolveFunc, "(s)", name.c_str());
1942738Sstever@eecs.umich.edu    if (pyPtr == NULL) {
1952738Sstever@eecs.umich.edu        PyErr_Print();
1962738Sstever@eecs.umich.edu        panic("resolveSimObject: failure on call to Python for %s", name);
1972738Sstever@eecs.umich.edu    }
1982738Sstever@eecs.umich.edu
1992738Sstever@eecs.umich.edu    SimObject *simObj = convertSwigSimObjectPtr(pyPtr);
2002738Sstever@eecs.umich.edu    if (simObj == NULL)
2012738Sstever@eecs.umich.edu        panic("resolveSimObject: failure on pointer conversion for %s", name);
2022738Sstever@eecs.umich.edu
2032738Sstever@eecs.umich.edu    return simObj;
2042738Sstever@eecs.umich.edu}
2052738Sstever@eecs.umich.edu
2062738Sstever@eecs.umich.edu
2072738Sstever@eecs.umich.edu/**
2082738Sstever@eecs.umich.edu * Load config.ini into C++ database.  Exported to Python via SWIG;
2092738Sstever@eecs.umich.edu * invoked from m5.instantiate().
2102738Sstever@eecs.umich.edu */
2112667Sstever@eecs.umich.eduvoid
2122738Sstever@eecs.umich.eduloadIniFile(PyObject *_resolveFunc)
2132667Sstever@eecs.umich.edu{
2142738Sstever@eecs.umich.edu    resolveFunc = _resolveFunc;
2152655Sstever@eecs.umich.edu    configStream = simout.find("config.out");
2161388SN/A
2172SN/A    // The configuration database is now complete; start processing it.
2182655Sstever@eecs.umich.edu    inifile.load("config.ini");
2192SN/A
2201388SN/A    // Initialize statistics database
2211388SN/A    Stats::InitSimStats();
2222738Sstever@eecs.umich.edu}
2232SN/A
2241310SN/A
2252738Sstever@eecs.umich.edu/**
2262738Sstever@eecs.umich.edu * Look up a MemObject port.  Helper function for connectPorts().
2272738Sstever@eecs.umich.edu */
2282738Sstever@eecs.umich.eduPort *
2292738Sstever@eecs.umich.edulookupPort(SimObject *so, const std::string &name, int i)
2302738Sstever@eecs.umich.edu{
2312738Sstever@eecs.umich.edu    MemObject *mo = dynamic_cast<MemObject *>(so);
2322738Sstever@eecs.umich.edu    if (mo == NULL) {
2332738Sstever@eecs.umich.edu        warn("error casting SimObject %s to MemObject", so->name());
2342738Sstever@eecs.umich.edu        return NULL;
2352738Sstever@eecs.umich.edu    }
2362738Sstever@eecs.umich.edu
2372738Sstever@eecs.umich.edu    Port *p = mo->getPort(name, i);
2382738Sstever@eecs.umich.edu    if (p == NULL)
2392738Sstever@eecs.umich.edu        warn("error looking up port %s on object %s", name, so->name());
2402738Sstever@eecs.umich.edu    return p;
2412738Sstever@eecs.umich.edu}
2422738Sstever@eecs.umich.edu
2432738Sstever@eecs.umich.edu
2442738Sstever@eecs.umich.edu/**
2452738Sstever@eecs.umich.edu * Connect the described MemObject ports.  Called from Python via SWIG.
2462738Sstever@eecs.umich.edu */
2472738Sstever@eecs.umich.eduint
2482738Sstever@eecs.umich.educonnectPorts(SimObject *o1, const std::string &name1, int i1,
2492738Sstever@eecs.umich.edu             SimObject *o2, const std::string &name2, int i2)
2502738Sstever@eecs.umich.edu{
2512738Sstever@eecs.umich.edu    Port *p1 = lookupPort(o1, name1, i1);
2522738Sstever@eecs.umich.edu    Port *p2 = lookupPort(o2, name2, i2);
2532738Sstever@eecs.umich.edu
2542738Sstever@eecs.umich.edu    if (p1 == NULL || p2 == NULL) {
2552738Sstever@eecs.umich.edu        warn("connectPorts: port lookup error");
2562738Sstever@eecs.umich.edu        return 0;
2572738Sstever@eecs.umich.edu    }
2582738Sstever@eecs.umich.edu
2592738Sstever@eecs.umich.edu    p1->setPeer(p2);
2602738Sstever@eecs.umich.edu    p2->setPeer(p1);
2612738Sstever@eecs.umich.edu
2622738Sstever@eecs.umich.edu    return 1;
2632738Sstever@eecs.umich.edu}
2642738Sstever@eecs.umich.edu
2652738Sstever@eecs.umich.edu/**
2662738Sstever@eecs.umich.edu * Do final initialization steps after object construction but before
2672738Sstever@eecs.umich.edu * start of simulation.
2682738Sstever@eecs.umich.edu */
2692738Sstever@eecs.umich.eduvoid
2702738Sstever@eecs.umich.edufinalInit()
2712738Sstever@eecs.umich.edu{
2721388SN/A    // Parse and check all non-config-hierarchy parameters.
2731388SN/A    ParamContext::parseAllContexts(inifile);
2741388SN/A    ParamContext::checkAllContexts();
2751388SN/A
2762667Sstever@eecs.umich.edu    // Echo all parameter settings to stats file as well.
2771104SN/A    ParamContext::showAllContexts(*configStream);
2782SN/A
2791127SN/A    // Do a second pass to finish initializing the sim objects
2801127SN/A    SimObject::initAll();
2811127SN/A
2822SN/A    // Restore checkpointed state, if any.
2832738Sstever@eecs.umich.edu#if 0
2842SN/A    configHierarchy.unserializeSimObjects();
2852738Sstever@eecs.umich.edu#endif
2862SN/A
2872SN/A    SimObject::regAllStats();
2882SN/A
2892SN/A    // Check to make sure that the stats package is properly initialized
290729SN/A    Stats::check();
2912SN/A
292395SN/A    // Reset to put the stats in a consistent state.
293729SN/A    Stats::reset();
294395SN/A
2951127SN/A    SimStartup();
2962667Sstever@eecs.umich.edu}
2972667Sstever@eecs.umich.edu
2982667Sstever@eecs.umich.edu
2992667Sstever@eecs.umich.edu/** Simulate for num_cycles additional cycles.  If num_cycles is -1
3002667Sstever@eecs.umich.edu * (the default), do not limit simulation; some other event must
3012667Sstever@eecs.umich.edu * terminate the loop.  Exported to Python via SWIG.
3022667Sstever@eecs.umich.edu * @return The SimLoopExitEvent that caused the loop to exit.
3032667Sstever@eecs.umich.edu */
3042667Sstever@eecs.umich.eduSimLoopExitEvent *
3052667Sstever@eecs.umich.edusimulate(Tick num_cycles = -1)
3062667Sstever@eecs.umich.edu{
3072667Sstever@eecs.umich.edu    warn("Entering event queue @ %d.  Starting simulation...\n", curTick);
3082667Sstever@eecs.umich.edu
3092667Sstever@eecs.umich.edu    // Fix up num_cycles.  Special default value -1 means simulate
3102667Sstever@eecs.umich.edu    // "forever"... schedule event at MaxTick just to be safe.
3112667Sstever@eecs.umich.edu    // Otherwise it's a delta for additional cycles to simulate past
3122667Sstever@eecs.umich.edu    // curTick, and thus must be non-negative.
3132667Sstever@eecs.umich.edu    if (num_cycles == -1)
3142667Sstever@eecs.umich.edu        num_cycles = MaxTick;
3152667Sstever@eecs.umich.edu    else if (num_cycles < 0)
3162667Sstever@eecs.umich.edu        fatal("simulate: num_cycles must be >= 0 (was %d)\n", num_cycles);
3172667Sstever@eecs.umich.edu    else
3182667Sstever@eecs.umich.edu        num_cycles = curTick + num_cycles;
3192667Sstever@eecs.umich.edu
3202667Sstever@eecs.umich.edu    Event *limit_event = new SimLoopExitEvent(num_cycles,
3212667Sstever@eecs.umich.edu                                              "simulate() limit reached");
3222667Sstever@eecs.umich.edu
3232667Sstever@eecs.umich.edu    while (1) {
3242667Sstever@eecs.umich.edu        // there should always be at least one event (the SimLoopExitEvent
3252667Sstever@eecs.umich.edu        // we just scheduled) in the queue
3262667Sstever@eecs.umich.edu        assert(!mainEventQueue.empty());
3272SN/A        assert(curTick <= mainEventQueue.nextTick() &&
3282SN/A               "event scheduled in the past");
3292SN/A
3302SN/A        // forward current cycle to the time of the first event on the
3312SN/A        // queue
3322SN/A        curTick = mainEventQueue.nextTick();
3332667Sstever@eecs.umich.edu        Event *exit_event = mainEventQueue.serviceOne();
3342667Sstever@eecs.umich.edu        if (exit_event != NULL) {
3352667Sstever@eecs.umich.edu            // hit some kind of exit event; return to Python
3362667Sstever@eecs.umich.edu            // event must be subclass of SimLoopExitEvent...
3372667Sstever@eecs.umich.edu            SimLoopExitEvent *se_event = dynamic_cast<SimLoopExitEvent *>(exit_event);
3382667Sstever@eecs.umich.edu            if (se_event == NULL)
3392667Sstever@eecs.umich.edu                panic("Bogus exit event class!");
3402667Sstever@eecs.umich.edu
3412667Sstever@eecs.umich.edu            // if we didn't hit limit_event, delete it
3422667Sstever@eecs.umich.edu            if (se_event != limit_event) {
3432667Sstever@eecs.umich.edu                assert(limit_event->scheduled());
3442667Sstever@eecs.umich.edu                limit_event->deschedule();
3452667Sstever@eecs.umich.edu                delete limit_event;
3462667Sstever@eecs.umich.edu            }
3472667Sstever@eecs.umich.edu
3482667Sstever@eecs.umich.edu            return se_event;
3492667Sstever@eecs.umich.edu        }
3502SN/A
3512SN/A        if (async_event) {
3522SN/A            async_event = false;
3532SN/A            if (async_dump) {
3542SN/A                async_dump = false;
355294SN/A
356729SN/A                using namespace Stats;
357294SN/A                SetupEvent(Dump, curTick);
3582SN/A            }
3592SN/A
360329SN/A            if (async_dumpreset) {
361329SN/A                async_dumpreset = false;
362329SN/A
363729SN/A                using namespace Stats;
364329SN/A                SetupEvent(Dump | Reset, curTick);
365329SN/A            }
366329SN/A
3672SN/A            if (async_exit) {
3682SN/A                async_exit = false;
3692667Sstever@eecs.umich.edu                exitSimLoop("user interrupt received");
3702SN/A            }
3712SN/A
3722SN/A            if (async_io || async_alarm) {
3732SN/A                async_io = false;
3742SN/A                async_alarm = false;
3752SN/A                pollQueue.service();
3762SN/A            }
3772SN/A        }
3782SN/A    }
3792SN/A
3802667Sstever@eecs.umich.edu    // not reached... only exit is return on SimLoopExitEvent
3812667Sstever@eecs.umich.edu}
3822SN/A
3832797Sktlim@umich.eduEvent *
3842839Sktlim@umich.educreateCountedDrain()
3852797Sktlim@umich.edu{
3862839Sktlim@umich.edu    return new CountedDrainEvent();
3872797Sktlim@umich.edu}
3882797Sktlim@umich.edu
3892797Sktlim@umich.eduvoid
3902839Sktlim@umich.educleanupCountedDrain(Event *counted_drain)
3912797Sktlim@umich.edu{
3922839Sktlim@umich.edu    CountedDrainEvent *event =
3932839Sktlim@umich.edu        dynamic_cast<CountedDrainEvent *>(counted_drain);
3942797Sktlim@umich.edu    if (event == NULL) {
3952839Sktlim@umich.edu        fatal("Called cleanupCountedDrain() on an event that was not "
3962839Sktlim@umich.edu              "a CountedDrainEvent.");
3972797Sktlim@umich.edu    }
3982797Sktlim@umich.edu    assert(event->getCount() == 0);
3992797Sktlim@umich.edu    delete event;
4002797Sktlim@umich.edu}
4012797Sktlim@umich.edu
4022797Sktlim@umich.eduvoid
4032868Sktlim@umich.eduserializeAll(const std::string &cpt_dir)
4042797Sktlim@umich.edu{
4052868Sktlim@umich.edu    Serializable::serializeAll(cpt_dir);
4062797Sktlim@umich.edu}
4072797Sktlim@umich.edu
4082797Sktlim@umich.eduvoid
4092868Sktlim@umich.eduunserializeAll(const std::string &cpt_dir)
4102797Sktlim@umich.edu{
4112868Sktlim@umich.edu    Serializable::unserializeAll(cpt_dir);
4122797Sktlim@umich.edu}
4132797Sktlim@umich.edu
4142667Sstever@eecs.umich.edu/**
4152667Sstever@eecs.umich.edu * Queue of C++ callbacks to invoke on simulator exit.
4162667Sstever@eecs.umich.edu */
4172667Sstever@eecs.umich.eduCallbackQueue exitCallbacks;
4182667Sstever@eecs.umich.edu
4192667Sstever@eecs.umich.edu/**
4202667Sstever@eecs.umich.edu * Register an exit callback.
4212667Sstever@eecs.umich.edu */
4222667Sstever@eecs.umich.eduvoid
4232667Sstever@eecs.umich.eduregisterExitCallback(Callback *callback)
4242667Sstever@eecs.umich.edu{
4252667Sstever@eecs.umich.edu    exitCallbacks.add(callback);
4262SN/A}
4272667Sstever@eecs.umich.edu
4282797Sktlim@umich.eduBaseCPU *
4292797Sktlim@umich.educonvertToBaseCPUPtr(SimObject *obj)
4302797Sktlim@umich.edu{
4312797Sktlim@umich.edu    BaseCPU *ptr = dynamic_cast<BaseCPU *>(obj);
4322797Sktlim@umich.edu
4332797Sktlim@umich.edu    if (ptr == NULL)
4342797Sktlim@umich.edu        warn("Casting to BaseCPU pointer failed");
4352797Sktlim@umich.edu    return ptr;
4362797Sktlim@umich.edu}
4372797Sktlim@umich.edu
4382667Sstever@eecs.umich.edu/**
4392667Sstever@eecs.umich.edu * Do C++ simulator exit processing.  Exported to SWIG to be invoked
4402667Sstever@eecs.umich.edu * when simulator terminates via Python's atexit mechanism.
4412667Sstever@eecs.umich.edu */
4422667Sstever@eecs.umich.eduvoid
4432667Sstever@eecs.umich.edudoExitCleanup()
4442667Sstever@eecs.umich.edu{
4452667Sstever@eecs.umich.edu    exitCallbacks.process();
4462667Sstever@eecs.umich.edu    exitCallbacks.clear();
4472667Sstever@eecs.umich.edu
4482667Sstever@eecs.umich.edu    cout.flush();
4492667Sstever@eecs.umich.edu
4502667Sstever@eecs.umich.edu    ParamContext::cleanupAllContexts();
4512667Sstever@eecs.umich.edu
4522667Sstever@eecs.umich.edu    // print simulation stats
4532667Sstever@eecs.umich.edu    Stats::DumpNow();
4542667Sstever@eecs.umich.edu}
455