Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use std::vector for State::incomplete_comm_pattern (dexbtification)
authorGabriel Corona <gabriel.corona@loria.fr>
Wed, 6 Apr 2016 11:35:14 +0000 (13:35 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Wed, 6 Apr 2016 12:03:15 +0000 (14:03 +0200)
src/mc/mc_comm_pattern.cpp
src/mc/mc_comm_pattern.h
src/mc/mc_state.cpp
src/mc/mc_state.h

index 6a9a467..8d064c9 100644 (file)
@@ -19,28 +19,12 @@ using simgrid::mc::remote;
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_comm_pattern, mc,
                                 "Logging specific to MC communication patterns");
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_comm_pattern, mc,
                                 "Logging specific to MC communication patterns");
 
-static xbt_dynar_t MC_comm_patterns_dup(xbt_dynar_t patterns)
-{
-  xbt_dynar_t res = simgrid::xbt::newDeleteDynar<simgrid::mc::PatternCommunication>();
-
-  simgrid::mc::PatternCommunication* comm;
-  unsigned int cursor;
-  xbt_dynar_foreach(patterns, cursor, comm) {
-    simgrid::mc::PatternCommunication* copy_comm = new simgrid::mc::PatternCommunication(comm->dup());
-    xbt_dynar_push(res, &copy_comm);
-  }
-
-  return res;
-}
-
-static void MC_patterns_copy(xbt_dynar_t dest, xbt_dynar_t source)
+static void MC_patterns_copy(xbt_dynar_t dest,
+  std::vector<simgrid::mc::PatternCommunication> const& source)
 {
   xbt_dynar_reset(dest);
 {
   xbt_dynar_reset(dest);
-
-  unsigned int cursor;
-  simgrid::mc::PatternCommunication* comm;
-  xbt_dynar_foreach(source, cursor, comm) {
-    simgrid::mc::PatternCommunication* copy_comm = new simgrid::mc::PatternCommunication(comm->dup());
+  for (simgrid::mc::PatternCommunication const& comm : source) {
+    simgrid::mc::PatternCommunication* copy_comm = new simgrid::mc::PatternCommunication(comm.dup());
     xbt_dynar_push(dest, &copy_comm);
   }
 }
     xbt_dynar_push(dest, &copy_comm);
   }
 }
@@ -56,18 +40,21 @@ void MC_restore_communications_pattern(simgrid::mc::State* state)
   for (unsigned i = 0; i < MC_smx_get_maxpid(); i++)
     MC_patterns_copy(
       xbt_dynar_get_as(incomplete_communications_pattern, i, xbt_dynar_t),
   for (unsigned i = 0; i < MC_smx_get_maxpid(); i++)
     MC_patterns_copy(
       xbt_dynar_get_as(incomplete_communications_pattern, i, xbt_dynar_t),
-      xbt_dynar_get_as(state->incomplete_comm_pattern, i, xbt_dynar_t)
+      state->incomplete_comm_pattern[i]
     );
 }
 
 void MC_state_copy_incomplete_communications_pattern(simgrid::mc::State* state)
 {
     );
 }
 
 void MC_state_copy_incomplete_communications_pattern(simgrid::mc::State* state)
 {
-  state->incomplete_comm_pattern = xbt_dynar_new(sizeof(xbt_dynar_t), xbt_dynar_free_voidp);
-
+  state->incomplete_comm_pattern.clear();
   for (unsigned i=0; i < MC_smx_get_maxpid(); i++) {
   for (unsigned i=0; i < MC_smx_get_maxpid(); i++) {
-    xbt_dynar_t comms = xbt_dynar_get_as(incomplete_communications_pattern, i, xbt_dynar_t);
-    xbt_dynar_t copy = MC_comm_patterns_dup(comms);
-    xbt_dynar_insert_at(state->incomplete_comm_pattern, i, &copy);
+    xbt_dynar_t patterns = xbt_dynar_get_as(incomplete_communications_pattern, i, xbt_dynar_t);
+    std::vector<simgrid::mc::PatternCommunication> res;
+    simgrid::mc::PatternCommunication* comm;
+    unsigned int cursor;
+    xbt_dynar_foreach(patterns, cursor, comm)
+      res.push_back(comm->dup());
+    state->incomplete_comm_pattern.push_back(std::move(res));
   }
 }
 
   }
 }
 
index 1bef9c1..67f321b 100644 (file)
 namespace simgrid {
 namespace mc {
 
 namespace simgrid {
 namespace mc {
 
-struct PatternCommunication {
-  int num = 0;
-  smx_synchro_t comm_addr;
-  e_smx_comm_type_t type = SIMIX_COMM_SEND;
-  unsigned long src_proc = 0;
-  unsigned long dst_proc = 0;
-  const char *src_host = nullptr;
-  const char *dst_host = nullptr;
-  std::string rdv;
-  std::vector<char> data;
-  int tag = 0;
-  int index = 0;
-
-  PatternCommunication()
-  {
-    std::memset(&comm_addr, 0, sizeof(comm_addr));
-  }
-
-  PatternCommunication dup() const
-  {
-    simgrid::mc::PatternCommunication res;
-    // num?
-    res.comm_addr = this->comm_addr;
-    res.type = this->type;
-    // src_proc?
-    // dst_proc?
-    res.dst_proc = this->dst_proc;
-    res.dst_host = this->dst_host;
-    res.rdv = this->rdv;
-    res.data = this->data;
-    // tag?
-    res.index = this->index;
-    return res;
-  }
-
-};
-
 struct PatternCommunicationList {
   unsigned int index_comm = 0;
   xbt_dynar_t list = nullptr;
 struct PatternCommunicationList {
   unsigned int index_comm = 0;
   xbt_dynar_t list = nullptr;
index 03b461f..a342046 100644 (file)
@@ -53,11 +53,6 @@ State::State()
   std::memset(&this->executed_req, 0, sizeof(this->executed_req));
 }
 
   std::memset(&this->executed_req, 0, sizeof(this->executed_req));
 }
 
-State::~State()
-{
-  xbt_free(this->incomplete_comm_pattern);
-}
-
 std::size_t State::interleaveSize() const
 {
   return std::count_if(this->processStates.begin(), this->processStates.end(),
 std::size_t State::interleaveSize() const
 {
   return std::count_if(this->processStates.begin(), this->processStates.end(),
index 5534a57..95e1af9 100644 (file)
@@ -22,6 +22,43 @@ namespace mc {
 
 extern XBT_PRIVATE std::unique_ptr<s_mc_global_t> initial_global_state;
 
 
 extern XBT_PRIVATE std::unique_ptr<s_mc_global_t> initial_global_state;
 
+struct PatternCommunication {
+  int num = 0;
+  smx_synchro_t comm_addr;
+  e_smx_comm_type_t type = SIMIX_COMM_SEND;
+  unsigned long src_proc = 0;
+  unsigned long dst_proc = 0;
+  const char *src_host = nullptr;
+  const char *dst_host = nullptr;
+  std::string rdv;
+  std::vector<char> data;
+  int tag = 0;
+  int index = 0;
+
+  PatternCommunication()
+  {
+    std::memset(&comm_addr, 0, sizeof(comm_addr));
+  }
+
+  PatternCommunication dup() const
+  {
+    simgrid::mc::PatternCommunication res;
+    // num?
+    res.comm_addr = this->comm_addr;
+    res.type = this->type;
+    // src_proc?
+    // dst_proc?
+    res.dst_proc = this->dst_proc;
+    res.dst_host = this->dst_host;
+    res.rdv = this->rdv;
+    res.data = this->data;
+    // tag?
+    res.index = this->index;
+    return res;
+  }
+
+};
+
 /* Possible exploration status of a process in a state */
 enum class ProcessInterleaveState {
   no_interleave=0, /* Do not interleave (do not execute) */
 /* Possible exploration status of a process in a state */
 enum class ProcessInterleaveState {
   no_interleave=0, /* Do not interleave (do not execute) */
@@ -66,18 +103,12 @@ struct XBT_PRIVATE State {
   int in_visited_states = 0;
 
   // comm determinism verification (xbt_dynar_t<xbt_dynar_t<simgrid::mc::PatternCommunication*>):
   int in_visited_states = 0;
 
   // comm determinism verification (xbt_dynar_t<xbt_dynar_t<simgrid::mc::PatternCommunication*>):
-  xbt_dynar_t incomplete_comm_pattern = nullptr;
+  std::vector<std::vector<simgrid::mc::PatternCommunication>> incomplete_comm_pattern;
 
   // For communication determinism verification:
   std::vector<unsigned> communicationIndices;
 
   State();
 
   // For communication determinism verification:
   std::vector<unsigned> communicationIndices;
 
   State();
-  ~State();
-
-  State(State const&) = delete;
-  State operator=(State const&) = delete;
-  State(State const&&) = delete;
-  State operator=(State const&&) = delete;
 
   std::size_t interleaveSize() const;
 };
 
   std::size_t interleaveSize() const;
 };