sst-core
sst-core copied to clipboard
Automatic simulation completion
This issue is to track the idea of having an automatic simulation completion feature so that components do not need to call primaryComponentOKToEndSim()
.
Consider a ring of components. A single event is spawned at component 0. Each component sends to the next component (i.e., k+1). For each event the component pull a random number and compares it to a user configurable value. If the random value is less than or equal to the configuration value, the component will send the event along the ring. If not, the component will do nothing. In this case this component knows the simulation is done but none of the other components know that.
Ideally SST would automatically detect when none of the processes/threads have any work to do and end the simulation. Forcing the component developers to create links with itself or other components to detect when simulation is done is just more work. Is it possible to get around this?
This is not as straightforward as it may seem. We can't just always end simulation when we run out of events because more often than not this means there was an error in the model or the configuration. SST took that stance that models should be explicit about when simulation ends.
However, there are a couple approaches we could take. One idea that has been around for a long time is found in issue #7 (yes, this issue predates our move to GitHub). This would allow you to set up a counter that would exit when the value reached zero. For the case above, each component would request a handle to the counter and the first one to send an event would increment it and the last one to not send the event on would decrement it. This is still explicitly stating the exit condition, but every component would not have to know that it was time to end. You could also pair this with the regular primaryComponent calls to make sure that everyone is okay with the sim ending, but not actually ending until all important outstanding events are received.
Another idea, would be allowing a "exit on empty event queue" mode that would have to be turned on in the input file. This would actually require extra state to be held in the core to be able to wind back when the simulation actually ended since the termination criteria is a lack of something happening, instead of something telling the core when it's done.