X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/bef0ab784f7bd9cd0228e5c6a58f6c1170bfbef3..bc2253e2c879ee28ae5153f1d56497ab802aeea9:/src/mc/explo/odpor/WakeupTree.cpp diff --git a/src/mc/explo/odpor/WakeupTree.cpp b/src/mc/explo/odpor/WakeupTree.cpp index 22b03521b4..73b2171894 100644 --- a/src/mc/explo/odpor/WakeupTree.cpp +++ b/src/mc/explo/odpor/WakeupTree.cpp @@ -10,8 +10,11 @@ #include #include +#include #include +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_wut, mc, "Logging specific to ODPOR WakeupTrees"); + namespace simgrid::mc::odpor { void WakeupTreeNode::add_child(WakeupTreeNode* node) @@ -20,6 +23,19 @@ void WakeupTreeNode::add_child(WakeupTreeNode* node) node->parent_ = this; } +std::string WakeupTreeNode::string_of_whole_tree(int indentation_level) const +{ + std::string tabulations = ""; + for (int i = 0; i < indentation_level; i++) + tabulations += " "; + std::string final_string = action_ == nullptr ? "<>\n" + : tabulations + "Actor " + std::to_string(action_->aid_) + ": " + + action_->to_string(true) + "\n"; + for (auto node : children_) + final_string += node->string_of_whole_tree(indentation_level + 1); + return final_string; +} + PartialExecution WakeupTreeNode::get_sequence() const { // TODO: Prevent having to compute this at the node level @@ -46,7 +62,7 @@ void WakeupTreeNode::detatch_from_parent() } } -WakeupTree::WakeupTree() : WakeupTree(std::unique_ptr(new WakeupTreeNode({}))) {} +WakeupTree::WakeupTree() : WakeupTree(std::make_unique()) {} WakeupTree::WakeupTree(std::unique_ptr root) : root_(root.get()) { this->insert_node(std::move(root)); @@ -56,9 +72,9 @@ std::vector WakeupTree::get_single_process_texts() const { std::vector trace; for (const auto* child : root_->children_) { - const auto t = child->get_action(); - const auto message = xbt::string_printf("Actor %ld: %s", t->aid_, t->to_string(true).c_str()); - trace.push_back(std::move(message)); + const auto t = child->get_action(); + auto message = xbt::string_printf("Actor %ld: %s", t->aid_, t->to_string(true).c_str()); + trace.emplace_back(std::move(message)); } return trace; } @@ -84,6 +100,11 @@ std::optional WakeupTree::get_min_single_process_node() const return this->root_->children_.front(); } +std::string WakeupTree::string_of_whole_tree() const +{ + return root_->string_of_whole_tree(0); +} + WakeupTree WakeupTree::make_subtree_rooted_at(WakeupTreeNode* root) { // Perform a BFS search to perform a deep copy of the portion @@ -138,6 +159,15 @@ void WakeupTree::remove_subtree_rooted_at(WakeupTreeNode* root) } } +void WakeupTree::remove_subtree_at_aid(aid_t proc) +{ + for (const auto& child : root_->get_ordered_children()) + if (child->get_actor() == proc) { + this->remove_subtree_rooted_at(child); + break; + } +} + void WakeupTree::remove_min_single_process_subtree() { if (const auto node = get_min_single_process_node(); node.has_value()) { @@ -153,7 +183,7 @@ bool WakeupTree::contains(const WakeupTreeNode* node) const WakeupTreeNode* WakeupTree::make_node(std::shared_ptr u) { - auto node = std::unique_ptr(new WakeupTreeNode(std::move(u))); + auto node = std::make_unique(std::move(u)); auto* node_handle = node.get(); this->nodes_[node_handle] = std::move(node); return node_handle;