Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Make Snapshot::enabled_process a std::set
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 8 Jun 2015 09:17:28 +0000 (11:17 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 9 Jun 2015 08:20:44 +0000 (10:20 +0200)
src/mc/mc_checkpoint.cpp
src/mc/mc_compare.cpp
src/mc/mc_snapshot.cpp
src/mc/mc_snapshot.h

index 77bbfd6..341e81b 100644 (file)
@@ -636,11 +636,9 @@ mc_snapshot_t MC_take_snapshot(int num_state)
   snapshot->process = mc_process;
   snapshot->num_state = num_state;
 
   snapshot->process = mc_process;
   snapshot->num_state = num_state;
 
-  snapshot->enabled_processes = xbt_dynar_new(sizeof(int), NULL);
-
   smx_process_t process;
   MC_EACH_SIMIX_PROCESS(process,
   smx_process_t process;
   MC_EACH_SIMIX_PROCESS(process,
-    xbt_dynar_push_as(snapshot->enabled_processes, int, (int)process->pid));
+    snapshot->enabled_processes.insert(process->pid));
 
   MC_snapshot_handle_ignore(snapshot);
 
 
   MC_snapshot_handle_ignore(snapshot);
 
index 89b495b..356a1ec 100644 (file)
@@ -440,14 +440,10 @@ int snapshot_compare(void *state1, void *state2)
   }
 
   /* Compare enabled processes */
   }
 
   /* Compare enabled processes */
-  unsigned int cursor;
-  int pid;
-  xbt_dynar_foreach(s1->enabled_processes, cursor, pid){
-    if(!xbt_dynar_member(s2->enabled_processes, &pid)) {
+  if (s1->enabled_processes != s2->enabled_processes) {
       //XBT_TRACE3(mc, state_diff, num1, num2, "Different enabled processes");
       XBT_VERB("(%d - %d) Different enabled processes", num1, num2);
       // return 1; ??
       //XBT_TRACE3(mc, state_diff, num1, num2, "Different enabled processes");
       XBT_VERB("(%d - %d) Different enabled processes", num1, num2);
       // return 1; ??
-    }
   }
 
   unsigned long i = 0;
   }
 
   unsigned long i = 0;
@@ -526,7 +522,7 @@ int snapshot_compare(void *state1, void *state2)
 #endif
 
   /* Stacks comparison */
 #endif
 
   /* Stacks comparison */
-  cursor = 0;
+  unsigned cursor = 0;
   int diff_local = 0;
 #ifdef MC_DEBUG
   is_diff = 0;
   int diff_local = 0;
 #ifdef MC_DEBUG
   is_diff = 0;
index 08eb1b1..c394871 100644 (file)
@@ -159,7 +159,7 @@ Snapshot::Snapshot() :
   heap_bytes_used(0),
   snapshot_regions(nullptr),
   snapshot_regions_count(0),
   heap_bytes_used(0),
   snapshot_regions(nullptr),
   snapshot_regions_count(0),
-  enabled_processes(0),
+  enabled_processes(),
   privatization_index(0),
   stack_sizes(nullptr),
   stacks(nullptr),
   privatization_index(0),
   stack_sizes(nullptr),
   stacks(nullptr),
index d6bd33b..6a23ca0 100644 (file)
@@ -10,6 +10,8 @@
 #include <sys/types.h> // off_t
 #include <stdint.h> // size_t
 
 #include <sys/types.h> // off_t
 #include <stdint.h> // size_t
 
+#include <set>
+
 #include <simgrid_config.h>
 #include "../xbt/mmalloc/mmprivate.h"
 #include <xbt/asserts.h>
 #include <simgrid_config.h>
 #include "../xbt/mmalloc/mmprivate.h"
 #include <xbt/asserts.h>
@@ -108,7 +110,7 @@ public: // To be private
   size_t heap_bytes_used;
   mc_mem_region_t* snapshot_regions;
   size_t snapshot_regions_count;
   size_t heap_bytes_used;
   mc_mem_region_t* snapshot_regions;
   size_t snapshot_regions_count;
-  xbt_dynar_t enabled_processes;
+  std::set<pid_t> enabled_processes;
   int privatization_index;
   size_t *stack_sizes;
   xbt_dynar_t stacks;
   int privatization_index;
   size_t *stack_sizes;
   xbt_dynar_t stacks;