Fix event-generator bugs in model (#439)
There were two latent bugs in the event generation part of `model`. 1. A segmentation fault when initializing the `event_generators` in the `model` constructor caused by using an index variable after it had been incremented. 2. Events generated during the first epoch were not delivered on time. The first issue was simple to fix, by ensuring that the coutning variable is incremented at the end of the loop. The second issue required refactoring the event wrangling inside `model`. Events can be introduced into a model via three sources: 1. Generated by spike exchange 2. By calling the `model::inject_events()` interface 3. `event_generator`s attached to cells. The refactoring was required to ensure that all three sources are handled correctly. There is further opportunities for refactoring the code to make it a bit cleaner, specifically putting the wrangling code in its own type that could be tested seperately, outside `model`, but that is beyond the scope of this fix.
Showing
- src/communication/communicator.hpp 11 additions, 8 deletionssrc/communication/communicator.hpp
- src/merge_events.hpp 4 additions, 4 deletionssrc/merge_events.hpp
- src/model.cpp 62 additions, 37 deletionssrc/model.cpp
- src/model.hpp 6 additions, 0 deletionssrc/model.hpp
- tests/global_communication/test_communicator.cpp 4 additions, 6 deletionstests/global_communication/test_communicator.cpp
Please register or sign in to comment