Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: maintain a copy of simix_global->process_to_destroy in a dynar.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 5 Dec 2017 13:42:16 +0000 (14:42 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 5 Dec 2017 16:30:10 +0000 (17:30 +0100)
src/mc/mc_smx.cpp
src/simix/ActorImpl.cpp
src/simix/smx_global.cpp
src/simix/smx_private.hpp

index 8be69df..bcdec8b 100644 (file)
@@ -25,38 +25,12 @@ static inline simgrid::mc::ActorInformation* actor_info_cast(smx_actor_t actor)
   return process_info;
 }
 
-/** Load the remote swag of processes into a vector
+/** Load the remote list of processes into a vector
  *
- *  @param process     MCed process
- *  @param target      Local vector (to be filled with copies of `s_smx_actor_t`)
- *  @param remote_swag Address of the process SWAG in the remote list
+ *  @param process      MCed process
+ *  @param target       Local vector (to be filled with copies of `s_smx_actor_t`)
+ *  @param remote_dynar Address of the process dynar in the remote list
  */
-static void MC_process_refresh_simix_process_list(simgrid::mc::RemoteClient* process,
-                                                  std::vector<simgrid::mc::ActorInformation>& target,
-                                                  simgrid::mc::RemotePtr<s_xbt_swag_t> remote_swag)
-{
-  target.clear();
-
-  // swag = REMOTE(*simix_global->process_list)
-  s_xbt_swag_t swag;
-  process->read_bytes(&swag, sizeof(swag), remote_swag);
-
-  // Load each element of the vector from the MCed process:
-  int i = 0;
-  for (smx_actor_t p = (smx_actor_t) swag.head; p; ++i) {
-
-    simgrid::mc::ActorInformation info;
-    info.address = p;
-    info.hostname = nullptr;
-    process->read_bytes(&info.copy, sizeof(info.copy), remote(p));
-    target.push_back(std::move(info));
-
-    // Lookup next process address:
-    p = (smx_actor_t) xbt_swag_getNext(&info.copy, swag.offset);
-  }
-  assert(i == swag.count);
-}
-
 static void MC_process_refresh_simix_actor_dynar(simgrid::mc::RemoteClient* process,
                                                  std::vector<simgrid::mc::ActorInformation>& target,
                                                  simgrid::mc::RemotePtr<s_xbt_dynar_t> remote_dynar)
@@ -105,8 +79,8 @@ void RemoteClient::refresh_simix()
     this->read<simgrid::simix::Global>(simix_global_p);
 
   MC_process_refresh_simix_actor_dynar(this, this->smx_actors_infos, remote(simix_global.getBuffer()->actors_vector));
-  MC_process_refresh_simix_process_list(this, this->smx_dead_actors_infos,
-                                        remote(simix_global.getBuffer()->process_to_destroy));
+  MC_process_refresh_simix_actor_dynar(this, this->smx_dead_actors_infos,
+                                       remote(simix_global.getBuffer()->dead_actors_vector));
 
   this->cache_flags_ |= RemoteClient::cache_simix_processes;
 }
index 2295dd3..1491a9e 100644 (file)
@@ -115,7 +115,12 @@ void SIMIX_process_cleanup(smx_actor_t process)
   simix_global->process_list.erase(process->pid);
   if (process->host && process->host_process_list_hook.is_linked())
     simgrid::xbt::intrusive_erase(process->host->extension<simgrid::simix::Host>()->process_list, *process);
-  xbt_swag_insert(process, simix_global->process_to_destroy);
+  if (not xbt_swag_belongs(process, simix_global->process_to_destroy)) {
+#if SIMGRID_HAVE_MC
+    xbt_dynar_push_as(simix_global->dead_actors_vector, smx_actor_t, process);
+#endif
+    xbt_swag_insert(process, simix_global->process_to_destroy);
+  }
   process->context->iwannadie = 0;
 
   xbt_os_mutex_release(simix_global->mutex);
@@ -135,6 +140,9 @@ void SIMIX_process_empty_trash()
     intrusive_ptr_release(process);
     process = static_cast<smx_actor_t>(xbt_swag_extract(simix_global->process_to_destroy));
   }
+#if SIMGRID_HAVE_MC
+  xbt_dynar_reset(simix_global->dead_actors_vector);
+#endif
 }
 
 namespace simgrid {
index ad2d351..8ba76bd 100644 (file)
@@ -308,6 +308,7 @@ void SIMIX_clean()
   simix_global->mutex = nullptr;
 #if SIMGRID_HAVE_MC
   xbt_dynar_free(&simix_global->actors_vector);
+  xbt_dynar_free(&simix_global->dead_actors_vector);
 #endif
 
   /* Let's free maestro now */
index 1a2ba34..55664e2 100644 (file)
@@ -26,17 +26,19 @@ public:
   std::vector<smx_actor_t> process_to_run;
   std::vector<smx_actor_t> process_that_ran;
   std::map<aid_t, smx_actor_t> process_list;
+  xbt_swag_t process_to_destroy = nullptr;
 #if SIMGRID_HAVE_MC
-  /* MCer cannot read the std::map above in the remote process, so we copy the info it needs in a dynar.
+  /* MCer cannot read members process_list and process_to_destroy above in the remote process, so we copy the info it
+   * needs in a dynar.
    * FIXME: This is supposed to be a temporary hack.
    * A better solution would be to change the split between MCer and MCed, where the responsibility
    *   to compute the list of the enabled transitions goes to the MCed.
    * That way, the MCer would not need to have the list of actors on its side.
    * These info could be published by the MCed to the MCer in a way inspired of vd.so
    */
-  xbt_dynar_t actors_vector = xbt_dynar_new(sizeof(smx_actor_t), nullptr);
+  xbt_dynar_t actors_vector      = xbt_dynar_new(sizeof(smx_actor_t), nullptr);
+  xbt_dynar_t dead_actors_vector = xbt_dynar_new(sizeof(smx_actor_t), nullptr);
 #endif
-  xbt_swag_t process_to_destroy = nullptr;
   smx_actor_t maestro_process   = nullptr;
 
   // Maps function names to actor code: