From: Martin Quinson Date: Wed, 15 May 2019 22:18:32 +0000 (+0200) Subject: mc: simplification: do not repeat information in parameters X-Git-Tag: v3.22.4~127^2~7 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/257911c6117e14fe757b77d9720cbfa88c86fa3c mc: simplification: do not repeat information in parameters --- diff --git a/src/mc/VisitedState.cpp b/src/mc/VisitedState.cpp index 85bf68f1b3..a17dbb49ad 100644 --- a/src/mc/VisitedState.cpp +++ b/src/mc/VisitedState.cpp @@ -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 */ diff --git a/src/mc/checker/LivenessChecker.cpp b/src/mc/checker/LivenessChecker.cpp index 4c5a2ca033..cd49a87e4d 100644 --- a/src/mc/checker/LivenessChecker.cpp +++ b/src/mc/checker/LivenessChecker.cpp @@ -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 LivenessChecker::insertAcceptancePair(simgrid::mc::Pair* pair) diff --git a/src/mc/checker/SafetyChecker.cpp b/src/mc/checker/SafetyChecker.cpp index b37e2d8846..faca5d2273 100644 --- a/src/mc/checker/SafetyChecker.cpp +++ b/src/mc/checker/SafetyChecker.cpp @@ -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) diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index 7393aab83d..946b92a192 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -1454,10 +1454,9 @@ namespace mc { static std::unique_ptr 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 diff --git a/src/mc/mc_private.hpp b/src/mc/mc_private.hpp index 1f6ad5db90..d12942f6fd 100644 --- a/src/mc/mc_private.hpp +++ b/src/mc/mc_private.hpp @@ -45,7 +45,7 @@ XBT_PRIVATE void find_object_address(std::vector 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;