config: Fix to SystemC example's event handling
Review Request #2504 - Created Nov. 16, 2014 and submitted
| Information | |
|---|---|
| Andreas Hansson | |
| gem5 | |
| default | |
| Reviewers | |
| Default | |
Changeset 10567:5b89628d387b
---------------------------
config: Fix to SystemC example's event handling
This patch fixes checkpoint restore in the SystemC hosting example by handling
early PollEvent events correctly before any EventQueue events are posted.
The SystemC event queue handler (SCEventQueue) reports an error if the event
loop is entered with no Events posted. It is possible for this to happen
after instantiate due to PollEvent events. This patch separates out
`external' events into a different handler in sc_module.cc to prevent the
error from occurring.
This fix also improves the event handling of asynchronous events by:
1) Making asynchronous events 'catch up' gem5 time to SystemC
time to avoid the appearance that events have been lost
while servicing an asynchronous event that schedules an
event loop exit event
2) Add an in_simulate data member to Module to allow the event
loop to check whether events should be processed or deferred
until the next time Module::simulate is entered
3) Cancel pending events around the entry/exit of the event loop
in Module::simulate
4) Moving the state initialisation of the example entirely into
run to correct a problem with early events in checkpoint
restore.
It is still possible to schedule asynchronous events (and talk PollQueue
actions) while simulate is not running. This behaviour may stil cause
some problems.
Posted (Nov. 17, 2014, 3:45 p.m.)
I think you are missing the call to SimControl::before_end_of_elaboration(). May be after sim_control is instantiated, but before sc_start is called?
int
sc_main(int argc, char **argv)
{
SimControl sim_control("gem5", argc, argv);
==> sim_control.before_end_of_elaboration();
sc_core::sc_start();
return EXIT_SUCCESS;
}
Posted (Nov. 18, 2014, 1:07 p.m.)
I think there are still synchronization issues with curTick and systemc time I am testing FS, X86 with a small array manipulation program. I booted using python variant, created a checkpoint right before ROI. Python variant seems to restore checkpoint and run. But systemc variant cannot. I have both r2503 and this patch applied. Checkpoint restores in FS mode, but right after it fails the check assert(curTick() <= systemc_time) on Module::EventLoop info: kernel located at: ... Listening for com_1 connection on port 3456 Info: rtc: Real-time clock set to Sun Jan 1 00:00:00 2012 0: system.remote_gdb.listener: listening for remote gdb #0 on port 7000 warn: Reading current count from inactive timer. Restoring checkpoint Waiting for 5714639839500ps for SystemC to catch up to gem5 gem5.opt.sc: sc_module.cc:148: void Gem5SystemC::Module::eventLoop(): Assertion `curTick() <= systemc_time' failed. Program aborted at cycle 5714639839500 Aborted
Posted (Nov. 18, 2014, 4:22 p.m.)
Please ignore my last review. I made a mistake with my patches. In FS, X86 mode I was able to boot with python variant, checkpoint, run a short program. Then I was able to restore from checkpoint and run the same program again. And in systemc variant then I was able to restore from checkpoint and run the same program. The exit was not clean though. It failed with fatal: Missed an event at time 123366500 gem5: 5699875688000, SystemC: 5699875688000 @ tick 5699875688000 [eventLoop:sc_module.cc, line 192] But that may be due to m5_exit in the test program.
Review request changed
Updated (Nov. 20, 2014, 7:48 a.m.)
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+151 -67) |
Posted (Nov. 20, 2014, 12:54 p.m.)
I am afraid you have to move config_manager->instantiate() call into SimControl::run() after wait.
Currently it is tripping at:
fatal condition !eventq->empty() occurred: There must be no posted events before SimControl::run @ tick 0
[run:main.cc, line 266]
If add add getEventQueue(0)->dump() after config_manager->instantiate(), this is what I get:
SimControl::SimControl(sc_core::sc_module_name name,....
{
....
CxxConfig::statsEnable();
getEventQueue(0)->dump();
try {
config_manager->instantiate();
} catch (CxxConfigManager::Exception &e) {
fatal("Config problem in sim object %s: %s", e.name, e.message);
}
==> std::cout << "Called config_manager->instantiate()." << std::endl;
==> getEventQueue(0)->dump();
}
The output is:
============================================================
EventQueue Dump (cycle 0)
------------------------------------------------------------
<No Events>
============================================================
info: kernel located at: /proj/adg/REV/sim/cdirik/gem5-sims/full-system-x86/binaries/x86_64-vmlinux-2.6.26
Listening for com_1 connection on port 3456
Info: rtc: Real-time clock set to Sun Jan 1 00:00:00 2012
0: system.remote_gdb.listener: listening for remote gdb #0 on port 7000
warn: Reading current count from inactive timer.
Called config_manager->instantiate().
============================================================
EventQueue Dump (cycle 0)
------------------------------------------------------------
Event Event_69 (RTC interrupt)
Flags: 0x7a42
Scheduled for 5000000000, priority 0
Event Event_80 (Intel 8254 Interval timer)
Flags: 0x7a42
Scheduled for 54924621360, priority 0
Event Event_70 (RTC clock tick)
Flags: 0x7a42
Scheduled for 1000000000000, priority 0
============================================================
fatal condition !eventq->empty() occurred: There must be no posted events before SimControl::run @ tick 0
[run:main.cc, line 266]
