From 4b95f054f8e620b68676f19b9db38002889538c6 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Wed, 6 Apr 2016 13:35:14 +0200 Subject: [PATCH] [mc] Use std::vector for State::incomplete_comm_pattern (dexbtification) --- src/mc/mc_comm_pattern.cpp | 39 +++++++++++---------------------- src/mc/mc_comm_pattern.h | 37 ------------------------------- src/mc/mc_state.cpp | 5 ----- src/mc/mc_state.h | 45 ++++++++++++++++++++++++++++++++------ 4 files changed, 51 insertions(+), 75 deletions(-) diff --git a/src/mc/mc_comm_pattern.cpp b/src/mc/mc_comm_pattern.cpp index 6a9a467fee..8d064c96c5 100644 --- a/src/mc/mc_comm_pattern.cpp +++ b/src/mc/mc_comm_pattern.cpp @@ -19,28 +19,12 @@ using simgrid::mc::remote; 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* 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, ©_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 const& source) { 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, ©_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), - 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) { - 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++) { - 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, ©); + xbt_dynar_t patterns = xbt_dynar_get_as(incomplete_communications_pattern, i, xbt_dynar_t); + std::vector 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)); } } diff --git a/src/mc/mc_comm_pattern.h b/src/mc/mc_comm_pattern.h index 1bef9c1265..67f321b731 100644 --- a/src/mc/mc_comm_pattern.h +++ b/src/mc/mc_comm_pattern.h @@ -25,43 +25,6 @@ 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 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; diff --git a/src/mc/mc_state.cpp b/src/mc/mc_state.cpp index 03b461fccf..a3420467a6 100644 --- a/src/mc/mc_state.cpp +++ b/src/mc/mc_state.cpp @@ -53,11 +53,6 @@ State::State() 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(), diff --git a/src/mc/mc_state.h b/src/mc/mc_state.h index 5534a570c3..95e1af979c 100644 --- a/src/mc/mc_state.h +++ b/src/mc/mc_state.h @@ -22,6 +22,43 @@ namespace mc { extern XBT_PRIVATE std::unique_ptr 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 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) */ @@ -66,18 +103,12 @@ struct XBT_PRIVATE State { int in_visited_states = 0; // comm determinism verification (xbt_dynar_t): - xbt_dynar_t incomplete_comm_pattern = nullptr; + std::vector> incomplete_comm_pattern; // For communication determinism verification: std::vector 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; }; -- 2.20.1