util: DrainManager/Checkpoint changes in SystemC coupling

Due to changes in Drain Manager, the lastest systemc coupling doesn't work. The
code for handling Checkpoint has been modified and it is now compatiable with
new drain manager.

Testing is being done on systemC coupling. It needs more testing to verify
checkpointing feature.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>
This commit is contained in:
Abdul Mutaal Ahmad 2015-12-04 17:20:07 -06:00
parent 1a34e23603
commit 0707f4ee63

View file

@ -35,6 +35,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Andrew Bardsley
* Abdul Mutaal Ahmad
*/
/**
@ -243,6 +244,11 @@ SimControl::SimControl(sc_core::sc_module_name name,
fatal("Config problem in sim object %s: %s", e.name, e.message);
}
if (checkpoint_save && checkpoint_restore) {
fatal("Don't try to save and restore a checkpoint in the same"
"run");
}
CxxConfig::statsEnable();
getEventQueue(0)->dump();
@ -266,13 +272,17 @@ void SimControl::run()
if (checkpoint_restore) {
std::cerr << "Restoring checkpoint\n";
Checkpoint *checkpoint = new Checkpoint(checkpoint_dir,
CheckpointIn *checkpoint = new CheckpointIn(checkpoint_dir,
config_manager->getSimObjectResolver());
/* Catch SystemC up with gem5 after checkpoint restore.
* Note that gem5 leading SystemC is always a violation of the
* required relationship between the two, hence this careful
* catchup */
DrainManager::instance().preCheckpointRestore();
Serializable::unserializeGlobals(*checkpoint);
Tick systemc_time = sc_core::sc_time_stamp().value();
if (curTick() > systemc_time) {
Tick wait_period = curTick() - systemc_time;
@ -282,9 +292,11 @@ void SimControl::run()
wait(sc_core::sc_time(wait_period, sc_core::SC_PS));
}
config_manager->loadState(checkpoint);
config_manager->loadState(*checkpoint);
config_manager->startup();
config_manager->drainResume();
std::cerr << "Restored from Checkpoint\n";
} else {
config_manager->initState();
config_manager->startup();
@ -298,16 +310,13 @@ void SimControl::run()
if (checkpoint_save) {
exit_event = simulate(pre_run_time);
DrainManager drain_manager;
unsigned int drain_count = 1;
do {
drain_count = config_manager->drain(&drain_manager);
drain_count = config_manager->drain();
std::cerr << "Draining " << drain_count << '\n';
if (drain_count > 0) {
drain_manager.setCount(drain_count);
exit_event = simulate();
}
} while (drain_count > 0);
@ -337,15 +346,13 @@ void SimControl::run()
BaseCPU &old_cpu = config_manager->getObject<BaseCPU>(from_cpu);
BaseCPU &new_cpu = config_manager->getObject<BaseCPU>(to_cpu);
DrainManager drain_manager;
unsigned int drain_count = 1;
do {
drain_count = config_manager->drain(&drain_manager);
drain_count = config_manager->drain();
std::cerr << "Draining " << drain_count << '\n';
if (drain_count > 0) {
drain_manager.setCount(drain_count);
exit_event = simulate();
}
} while (drain_count > 0);