sim: Reuse the same limit_event in simulate()
Review Request #2665 - Created Feb. 20, 2015 and submitted
| Information | |
|---|---|
| Curtis Dunham | |
| gem5 | |
| default | |
| Reviewers | |
| Default | |
Changeset 10706:e77f25583997 --------------------------- sim: Reuse the same limit_event in simulate() This patch accomplishes two things: 1. Makes simulate() reuse the same GlobalSimLoopExitEvent across calls. This is slightly more efficient than recreating it every time. 2. Gives callers to simulate() (especially other simulators) a foolproof way of knowing that the simulation period ended successfully by hitting the limit event. They can compare the global simulate_limit_event to the return value of simulate(). This change was motivated by an ongoing effort to integrate gem5 and SST, with SST as the master sim and gem5 as the slave sim.
Posted (Feb. 24, 2015, 9:17 a.m.)
I like the idea of having a single global limit event, with a function to access it so clients can check whether that's what was hit. However I don't think the GlobalSimLoopExitEvent should be a singleton, as there are a bunch of other instances that get created (see exitSimLoop() in sim_events.cc). I think it's clearer just to have a global variable for limit_event. (One of the extremely rare cases where a global variable is OK.) There's already support in simulate() for first-time initialization with the threads_initialized flag. I think we should basically leverage this flag to create the global limit_event (rename the flag if you want to make it more general). We may want to take the static vars inside simulate() and make them all global for consistency; I don't have a strong opinion there.
Review request changed
Updated (Feb. 24, 2015, 5:22 p.m.)
Change Summary:
Correct the patch description.
Description: |
|
|---|
Posted (Feb. 24, 2015, 8:26 p.m.)
Looks much better, thanks... just one more little thing
-
src/sim/sim_events.hh (Diff revision 2) -
seems like it would be safer just to say: if (scheduled()) deschedule(); then if some derived class no longer meets the condition of always being scheduled, we'll still be OK
Review request changed
Updated (March 3, 2015, 3:43 p.m.)
Diff: |
Revision 3 (+8 -9) |
|---|
Thanks for the changes!
