Implement committed output - #124
Conversation
Define code structure and developer contract Work needs to be done. Needs testing. Signed-off-by: AdrianoPi <24545691+AdrianoPi@users.noreply.github.com>
Signed-off-by: AdrianoPi <24545691+AdrianoPi@users.noreply.github.com>
Signed-off-by: AdrianoPi <24545691+AdrianoPi@users.noreply.github.com>
Signed-off-by: AdrianoPi <24545691+AdrianoPi@users.noreply.github.com>
Signed-off-by: AdrianoPi <24545691+AdrianoPi@users.noreply.github.com>
Plus changed some docstring wording Signed-off-by: AdrianoPi <24545691+AdrianoPi@users.noreply.github.com>
Added test for committed output in presence of stragglers. Requires 2 threads. Signed-off-by: AdrianoPi <24545691+AdrianoPi@users.noreply.github.com>
Signed-off-by: AdrianoPi <24545691+AdrianoPi@users.noreply.github.com>
Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it> # Conflicts: # src/gvt/fossil.c # src/lp/process.c # src/mm/msg_allocator.h
8e8cff2 to
843fbb0
Compare
This commit avoids accessing output buffers if not necessary. Also, output buffers are initialized upon message creation. Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #124 +/- ##
===========================================
- Coverage 85.51% 85.41% -0.10%
===========================================
Files 46 47 +1
Lines 1553 1742 +189
Branches 39 46 +7
===========================================
+ Hits 1328 1488 +160
- Misses 209 235 +26
- Partials 16 19 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Three bugs are fixed in the committed output implementation: - msg_allocator_alloc() did not initialize msg->outputs to NULL. Since mm_alloc() wraps malloc(), freshly allocated messages could contain a garbage pointer in that field. All functions guarding on if(!outputs) would then skip the NULL check and dereference the garbage value, leading to a crash or memory corruption. - The outputs field in struct lp_msg was placed between pl_size and pl[], inside the MPI-transmitted region. When a message was sent to a remote node the local pointer value was serialized, and the receiving side would overwrite the field with that garbage value via MPI_Mrecv. The field is moved into the message preamble (before dest) so it is never transmitted. - fossil_lp_collect() called execute_outputs() on every PES entry, including PES_ENTRY_SENT_LOCAL ones. Sent messages do not carry outputs; only received messages do. The call is moved after the sent-local guard and the already-extracted m pointer is reused to avoid a redundant pes_entry_msg() call. Two additional correctness issues are also addressed in output.c: - The silent_processing guard in ScheduleOutput() was checked after the serial fast-path. This meant that calling ScheduleOutput() during LP_FINI in serial mode would incorrectly fire the output callback, contrary to what the API documentation states. The guard is now checked first. - The serial mode detection used the deprecated global_config.serial boolean instead of global_config.synchronization == SERIAL, leading to lose all output: ScheduleOutput() would buffer entries on current_msg->outputs that execute_outputs() never flushes in serial mode. The committed_output test is extended with: - A serial mode test case, verifying that the output callback fires immediately and in causal order. - A total output count assertion in the Time Warp test that detects any phantom outputs from events that were rolled back but whose outputs were not correctly suppressed by committed_output_on_rollback(). - Per-invocation output_size verification in the output callback. - Bounds checking on the output buffer before writing to it. Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
…/committed_output
In the fixing process, I started adding a store that is now unnecessary given the other fixes. Remove it. Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
|
@AdrianoPi I have rebased the PR againts the current code base. I have made some changes (mostly documented in commit messages), it could be great if you could quickly recheck! |
|
Thanks! msg->outputs = NULL;in The rest looks good! |
In the fixing process, I started adding a store that is now unnecessary given the other fixes. Remove it. Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
|
Good catch! I have removed that. |
Piccions
left a comment
There was a problem hiding this comment.
LGTM, just a minor change suggested
Reversing the order in which the output messages are materialized upon fossil collection ensures a per-LP order. There is no global order yet, as fossil_lp_collect() is executed lazily and possibly concurrently by multiple workers. Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
This pull request adds a committed output management system to the simulation kernel.
This lets simulation models schedule output operations while handling an event. Scheduled operations are then carried out when the originating event is committed, guaranteeing exactly-once execution.
Implementation changes
core/output.cand headercore/output.himplementing committed output management.ROOT-Sim.hto expose new functionScheduleOutput(), which lets the user submit data for handling upon event commitment.struct simulation_configurationto take a user-defined handlerPerformOutput_tthat receives the data submitted viaScheduleOutput()with exactly-once semantics once the generating event is committed.struct lp_msgto store committed output data.current_msgis now used by the committed output system and always needs to be set.Testing
test/core/output.c) that verifies correct output sequence in the presence of straggler messages.