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, ©_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);
-
- 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);
}
}
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<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));
}
}
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;
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(),
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) */
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();
- ~State();
-
- State(State const&) = delete;
- State operator=(State const&) = delete;
- State(State const&&) = delete;
- State operator=(State const&&) = delete;
std::size_t interleaveSize() const;
};