Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mc: simplification: do not repeat information in parameters
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 15 May 2019 22:18:32 +0000 (00:18 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 15 May 2019 22:18:32 +0000 (00:18 +0200)
src/mc/VisitedState.cpp
src/mc/checker/LivenessChecker.cpp
src/mc/checker/SafetyChecker.cpp
src/mc/compare.cpp
src/mc/mc_private.hpp

index 85bf68f..a17dbb4 100644 (file)
@@ -28,9 +28,7 @@ static int snapshot_compare(simgrid::mc::VisitedState* state1, simgrid::mc::Visi
 {
   simgrid::mc::Snapshot* s1 = state1->system_state.get();
   simgrid::mc::Snapshot* s2 = state2->system_state.get();
-  int num1 = state1->num;
-  int num2 = state2->num;
-  return snapshot_compare(num1, s1, num2, s2);
+  return snapshot_compare(s1, s2);
 }
 
 /** @brief Save the current state */
index 4c5a2ca..cd49a87 100644 (file)
@@ -100,9 +100,7 @@ int LivenessChecker::compare(simgrid::mc::VisitedPair* state1, simgrid::mc::Visi
 {
   simgrid::mc::Snapshot* s1 = state1->graph_state->system_state.get();
   simgrid::mc::Snapshot* s2 = state2->graph_state->system_state.get();
-  int num1 = state1->num;
-  int num2 = state2->num;
-  return simgrid::mc::snapshot_compare(num1, s1, num2, s2);
+  return simgrid::mc::snapshot_compare(s1, s2);
 }
 
 std::shared_ptr<VisitedPair> LivenessChecker::insertAcceptancePair(simgrid::mc::Pair* pair)
index b37e2d8..faca5d2 100644 (file)
@@ -34,9 +34,7 @@ static int snapshot_compare(simgrid::mc::State* state1, simgrid::mc::State* stat
 {
   simgrid::mc::Snapshot* s1 = state1->system_state.get();
   simgrid::mc::Snapshot* s2 = state2->system_state.get();
-  int num1 = state1->num;
-  int num2 = state2->num;
-  return snapshot_compare(num1, s1, num2, s2);
+  return snapshot_compare(s1, s2);
 }
 
 void SafetyChecker::checkNonTermination(simgrid::mc::State* current_state)
index 7393aab..946b92a 100644 (file)
@@ -1454,10 +1454,9 @@ namespace mc {
 
 static std::unique_ptr<simgrid::mc::StateComparator> state_comparator;
 
-int snapshot_compare(int num1, Snapshot* s1, int num2, Snapshot* s2)
+int snapshot_compare(Snapshot* s1, Snapshot* s2)
 {
   // TODO, make this a field of ModelChecker or something similar
-
   if (state_comparator == nullptr)
     state_comparator.reset(new StateComparator());
   else
@@ -1471,17 +1470,17 @@ int snapshot_compare(int num1, Snapshot* s1, int num2, Snapshot* s2)
   if (_sg_mc_hash) {
     hash_result = (s1->hash != s2->hash);
     if (hash_result) {
-      XBT_VERB("(%d - %d) Different hash: 0x%" PRIx64 "--0x%" PRIx64, num1, num2, s1->hash, s2->hash);
+      XBT_VERB("(%d - %d) Different hash: 0x%" PRIx64 "--0x%" PRIx64, s1->num_state, s2->num_state, s1->hash, s2->hash);
 #ifndef MC_DEBUG
       return 1;
 #endif
     } else
-      XBT_VERB("(%d - %d) Same hash: 0x%" PRIx64, num1, num2, s1->hash);
+      XBT_VERB("(%d - %d) Same hash: 0x%" PRIx64, s1->num_state, s2->num_state, s1->hash);
   }
 
   /* Compare enabled processes */
   if (s1->enabled_processes != s2->enabled_processes) {
-    XBT_VERB("(%d - %d) Different amount of enabled processes", num1, num2);
+    XBT_VERB("(%d - %d) Different amount of enabled processes", s1->num_state, s2->num_state);
     return 1;
   }
 
@@ -1492,12 +1491,14 @@ int snapshot_compare(int num1, Snapshot* s1, int num2, Snapshot* s2)
     size_t size_used2 = s2->stack_sizes[i];
     if (size_used1 != size_used2) {
 #ifdef MC_DEBUG
-      XBT_DEBUG("(%d - %d) Different size used in stacks: %zu - %zu", num1, num2, size_used1, size_used2);
+      XBT_DEBUG("(%d - %d) Different size used in stacks: %zu - %zu", s1->num_state, s2->num_state, size_used1,
+                size_used2);
       errors++;
       is_diff = 1;
 #else
 #ifdef MC_VERBOSE
-      XBT_VERB("(%d - %d) Different size used in stacks: %zu - %zu", num1, num2, size_used1, size_used2);
+      XBT_VERB("(%d - %d) Different size used in stacks: %zu - %zu", s1->num_state, s2->num_state, size_used1,
+               size_used2);
 #endif
       return 1;
 #endif
@@ -1519,11 +1520,11 @@ int snapshot_compare(int num1, Snapshot* s1, int num2, Snapshot* s2)
 
   if (res_init == -1) {
 #ifdef MC_DEBUG
-    XBT_DEBUG("(%d - %d) Different heap information", num1, num2);
+    XBT_DEBUG("(%d - %d) Different heap information", num1, nus1->num_state, s2->num_statem2);
     errors++;
 #else
 #ifdef MC_VERBOSE
-    XBT_VERB("(%d - %d) Different heap information", num1, num2);
+    XBT_VERB("(%d - %d) Different heap information", s1->num_state, s2->num_state);
 #endif
 
     return 1;
@@ -1538,8 +1539,8 @@ int snapshot_compare(int num1, Snapshot* s1, int num2, Snapshot* s2)
 
     if (stack1->process_index != stack2->process_index) {
       diff_local = 1;
-      XBT_DEBUG("(%d - %d) Stacks with different process index (%i vs %i)", num1, num2,
-        stack1->process_index, stack2->process_index);
+      XBT_DEBUG("(%d - %d) Stacks with different process index (%i vs %i)", s1->num_state, s2->num_state,
+                stack1->process_index, stack2->process_index);
     }
     else diff_local = compare_local_variables(*state_comparator,
       stack1->process_index, s1, s2, stack1, stack2);
@@ -1551,7 +1552,7 @@ int snapshot_compare(int num1, Snapshot* s1, int num2, Snapshot* s2)
 #else
 
 #ifdef MC_VERBOSE
-      XBT_VERB("(%d - %d) Different local variables between stacks %u", num1, num2, cursor + 1);
+      XBT_VERB("(%d - %d) Different local variables between stacks %u", s1->num_state, s2->num_state, cursor + 1);
 #endif
 
       return 1;
@@ -1582,13 +1583,11 @@ int snapshot_compare(int num1, Snapshot* s1, int num2, Snapshot* s2)
                                  region2, s1, s2)) {
 
 #ifdef MC_DEBUG
-      XBT_DEBUG("(%d - %d) Different global variables in %s",
-        num1, num2, name.c_str());
+      XBT_DEBUG("(%d - %d) Different global variables in %s", s1->num_state, s2->num_state, name.c_str());
       errors++;
 #else
 #ifdef MC_VERBOSE
-      XBT_VERB("(%d - %d) Different global variables in %s",
-        num1, num2, name.c_str());
+      XBT_VERB("(%d - %d) Different global variables in %s", s1->num_state, s2->num_state, name.c_str());
 #endif
 
       return 1;
@@ -1600,12 +1599,12 @@ int snapshot_compare(int num1, Snapshot* s1, int num2, Snapshot* s2)
   if (mmalloc_compare_heap(*state_comparator, s1, s2) > 0) {
 
 #ifdef MC_DEBUG
-    XBT_DEBUG("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
+    XBT_DEBUG("(%d - %d) Different heap (mmalloc_compare)", s1->num_state, s2->num_state);
     errors++;
 #else
 
 #ifdef MC_VERBOSE
-    XBT_VERB("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
+    XBT_VERB("(%d - %d) Different heap (mmalloc_compare)", s1->num_state, s2->num_state);
 #endif
     return 1;
 #endif
@@ -1613,9 +1612,9 @@ int snapshot_compare(int num1, Snapshot* s1, int num2, Snapshot* s2)
 
 #ifdef MC_VERBOSE
   if (errors || hash_result)
-    XBT_VERB("(%d - %d) Difference found", num1, num2);
+    XBT_VERB("(%d - %d) Difference found", s1->num_state, s2->num_state);
   else
-    XBT_VERB("(%d - %d) No difference found", num1, num2);
+    XBT_VERB("(%d - %d) No difference found", s1->num_state, s2->num_state);
 #endif
 
 #if defined(MC_DEBUG) && defined(MC_VERBOSE)
@@ -1623,7 +1622,7 @@ int snapshot_compare(int num1, Snapshot* s1, int num2, Snapshot* s2)
     // * false positive SHOULD be avoided.
     // * There MUST not be any false negative.
 
-    XBT_VERB("(%d - %d) State equality hash test is %s %s", num1, num2,
+    XBT_VERB("(%d - %d) State equality hash test is %s %s", s1->num_state, s2->num_state,
              (hash_result != 0) == (errors != 0) ? "true" : "false", not hash_result ? "positive" : "negative");
   }
 #endif
index 1f6ad5d..d12942f 100644 (file)
@@ -45,7 +45,7 @@ XBT_PRIVATE void find_object_address(std::vector<simgrid::xbt::VmMap> const& map
                                      simgrid::mc::ObjectInformation* result);
 
 XBT_PRIVATE
-int snapshot_compare(int num1, simgrid::mc::Snapshot* s1, int num2, simgrid::mc::Snapshot* s2);
+int snapshot_compare(Snapshot* s1, Snapshot* s2);
 
 // Move is somewhere else (in the LivenessChecker class, in the Session class?):
 extern XBT_PRIVATE xbt_automaton_t property_automaton;