Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Declare functions "const" (sonar).
[simgrid.git] / src / mc / explo / LivenessChecker.cpp
index 3d45e8d..8f1ecb2 100644 (file)
@@ -25,7 +25,7 @@ VisitedPair::VisitedPair(int pair_num, xbt_automaton_state_t prop_state,
   this->app_state_ = std::move(app_state);
   if (not this->app_state_->get_system_state())
     this->app_state_->set_system_state(std::make_shared<Snapshot>(pair_num));
-  this->heap_bytes_used     = Api::get().get_remote_heap_bytes();
+  this->heap_bytes_used     = mc_model_checker->get_remote_process().get_remote_heap_bytes();
   this->actor_count_        = app_state_->get_actor_count();
   this->other_num           = -1;
   this->atomic_propositions = std::move(atomic_propositions);
@@ -62,15 +62,17 @@ std::shared_ptr<VisitedPair> LivenessChecker::insert_acceptance_pair(simgrid::mc
   auto new_pair =
       std::make_shared<VisitedPair>(pair->num, pair->prop_state_, pair->atomic_propositions, pair->app_state_);
 
-  auto [res_begin, res_end] = boost::range::equal_range(acceptance_pairs_, new_pair.get(), Api::get().compare_pair());
+  auto [res_begin,
+        res_end] = boost::range::equal_range(acceptance_pairs_, new_pair.get(), [](auto const& a, auto const& b) {
+    return std::make_pair(a->actor_count_, a->heap_bytes_used) < std::make_pair(b->actor_count_, b->heap_bytes_used);
+  });
 
   if (pair->search_cycle)
     for (auto i = res_begin; i != res_end; ++i) {
       std::shared_ptr<simgrid::mc::VisitedPair> const& pair_test = *i;
       if (xbt_automaton_state_compare(pair_test->prop_state_, new_pair->prop_state_) != 0 ||
           *(pair_test->atomic_propositions) != *(new_pair->atomic_propositions) ||
-          not Api::get().snapshot_equal(pair_test->app_state_->get_system_state(),
-                                        new_pair->app_state_->get_system_state()))
+          (*pair_test->app_state_->get_system_state() != *new_pair->app_state_->get_system_state()))
         continue;
       XBT_INFO("Pair %d already reached (equal to pair %d) !", new_pair->num, pair_test->num);
       exploration_stack_.pop_back();
@@ -139,15 +141,16 @@ int LivenessChecker::insert_visited_pair(std::shared_ptr<VisitedPair> visited_pa
     visited_pair =
         std::make_shared<VisitedPair>(pair->num, pair->prop_state_, pair->atomic_propositions, pair->app_state_);
 
-  auto [range_begin, range_end] =
-      boost::range::equal_range(visited_pairs_, visited_pair.get(), Api::get().compare_pair());
+  auto [range_begin,
+        range_end] = boost::range::equal_range(visited_pairs_, visited_pair.get(), [](auto const& a, auto const& b) {
+    return std::make_pair(a->actor_count_, a->heap_bytes_used) < std::make_pair(b->actor_count_, b->heap_bytes_used);
+  });
 
   for (auto i = range_begin; i != range_end; ++i) {
     const VisitedPair* pair_test = i->get();
     if (xbt_automaton_state_compare(pair_test->prop_state_, visited_pair->prop_state_) != 0 ||
         *(pair_test->atomic_propositions) != *(visited_pair->atomic_propositions) ||
-        not Api::get().snapshot_equal(pair_test->app_state_->get_system_state(),
-                                      visited_pair->app_state_->get_system_state()))
+        (*pair_test->app_state_->get_system_state() != *visited_pair->app_state_->get_system_state()))
       continue;
     if (pair_test->other_num == -1)
       visited_pair->other_num = pair_test->num;
@@ -177,13 +180,12 @@ void LivenessChecker::purge_visited_pairs()
 LivenessChecker::LivenessChecker(const std::vector<char*>& args) : Exploration(args) {}
 LivenessChecker::~LivenessChecker()
 {
-  if (property_automaton_ != nullptr)
-    xbt_automaton_free(property_automaton_);
+  xbt_automaton_free(property_automaton_);
 }
 
 xbt_automaton_t LivenessChecker::property_automaton_ = nullptr;
 
-void LivenessChecker::automaton_load(const char* file)
+void LivenessChecker::automaton_load(const char* file) const
 {
   if (property_automaton_ == nullptr)
     property_automaton_ = xbt_automaton_new();
@@ -239,7 +241,8 @@ xbt_automaton_state_t LivenessChecker::get_automaton_transition_dst(xbt_dynar_t
   const xbt_automaton_transition* transition = xbt_dynar_get_as(dynar, index, xbt_automaton_transition_t);
   return transition->dst;
 }
-void LivenessChecker::automaton_register_symbol(RemoteProcess& remote_process, const char* name, RemotePtr<int> address)
+void LivenessChecker::automaton_register_symbol(RemoteProcess const& remote_process, const char* name,
+                                                RemotePtr<int> address)
 {
   if (property_automaton_ == nullptr)
     property_automaton_ = xbt_automaton_new();