On Thu, Jun 24, 2010 at 9:34 AM, nathan binkert <n...@binkert.org> wrote: >> if checkpoint arg provided: >> for each SimObject: >> if checkpoint has section for this SimObject: >> call unserialize() >> else: >> call unserializeNoData() >> else: >> for each SimObject: >> call initWithoutCheckpoint() > > I don't have a major objection to the code, but what if we instead > added a flags argument to startup? > > checkpoint_data = set() > if checkpoint arg provided: > for obj in SimObject: > if checkpoint has section for obj: > checkpoint_data.add(obj) > obj.unserialize() > > for obj in SimObject: > obj.startup(checkpoint arg provided, checkpoint_data[obj]) > > I'm just slightly concerned about adding yet more functions to the > startup process that could be confusing. It also seems pretty likely > that a lot of the code in startup() won't care about the status of the > flags.
In fact the vast majority of the code that's currently in various startup() functions is code that only gets executed when there was no checkpoint restored. According to doxygen, the only objects that override startup are: - Process, LiveProcess, and ISA-specific subclasses (12 total, almost entirely non-checkpoint initialization) - System, X86System, and LinuxX86System (the ones giving me problems, again almost entirely non-checkpoint initialization) - AlphaBackdoor and MIPSBackdoor (checkpoint-independent initialization, could go in init() I think) - BaseCPU - Bus Only the last two really do anything I'd characterize as "startup", and only BaseCPU seems to use startup() to actually schedule any events (though Bus::startup() does depend on curTick, so it needs to come after unserialization). My inclination right now is to do this: if checkpoint: internal.core.unserializeGlobals(checkpoint) for obj in SimObject: obj.setState(checkpoint) else: for obj in SimObject: obj.setState() for obj in SimObject: obj.startup() where setState() (w/no arg) is the same as initWithoutCheckpoint() above (only a nicer name). The default implementation of SimObject::setState(checkpoint) in C++ is: void SimObject::setState(Checkpoint *cp) { if (cp && cp->sectionExists(name())) unserialize(cp, name()); } So now if someone really wants the "unserializeNoData()" hook (e.g., to print the warning we now issue by default) they can override setState(Checkpoint*) to get it, but by default the current unserialize() interface still works. Steve _______________________________________________ m5-dev mailing list m5-dev@m5sim.org http://m5sim.org/mailman/listinfo/m5-dev