From 8af9454b81041efa93b131eb9dd5f251ac16f3b9 Mon Sep 17 00:00:00 2001 From: Neil McGlohon Date: Fri, 17 Nov 2017 15:15:28 -0500 Subject: [PATCH] Fix deserialization order to match serialization The previous commit, 86240a3, addressed the hardcoding of all LP deserialization being mapped to the first LP type. This fix was a positive step but still left a previously unaddressed issue: The deserialization was not done in the same order as serialization. The result of this was that in simulations with more than one KP, LPs may end up with GIDs and RNGs different than what they had been given at the start of the original simulation. This bug could have gone unnoticed in simulations with only one LP type as there would not be any runtime errors generated unless change in GID or RNG detection was done at the model level. This commit addresses the issue and makes the deserialization match the serialiation process. --- io-mpi.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/io-mpi.c b/io-mpi.c index 22ae7bf..c653a1e 100644 --- a/io-mpi.c +++ b/io-mpi.c @@ -204,13 +204,19 @@ void io_read_checkpoint() { } MPI_File_close(&fh); - // Load Data - for (i = 0; i < my_partitions[cur_part].lp_count; i++, all_lp_i++) { - b += io_lp_deserialize(g_tw_lp[all_lp_i], b); - int lp_type_index = g_tw_lp_typemap(g_tw_lp[all_lp_i]->gid); - ((deserialize_f)g_io_lp_types[lp_type_index].deserialize)(g_tw_lp[all_lp_i]->cur_state, b, g_tw_lp[all_lp_i]); - b += model_sizes[all_lp_i]; + + // Load LPs + int c; + for (c = 0; c < g_tw_nlp; c++) { + if (g_tw_lp[c]->kp->id == cur_part) { + b += io_lp_deserialize(g_tw_lp[c], b); + int lp_type_index = g_tw_lp_typemap(g_tw_lp[c]->gid); + ((deserialize_f)g_io_lp_types[lp_type_index].deserialize)(g_tw_lp[c]->cur_state, b, g_tw_lp[c]); + b += model_sizes[all_lp_i]; + all_lp_i++; + } } + assert(my_partitions[cur_part].ev_count <= g_io_free_events.size); for (i = 0; i < my_partitions[cur_part].ev_count; i++) { // SEND THESE EVENTS