From 4f5c109ade6f0e9015d5d8d4e1c3c120d973a2c6 Mon Sep 17 00:00:00 2001 From: Changhai Man Date: Fri, 19 Jan 2024 17:30:30 -0500 Subject: [PATCH] [ETFeeder] Resolve deps based on not only data_deps, but also ctrl_deps --- et_feeder/et_feeder.cpp | 19 ++++++------------- et_feeder/et_feeder_node.cpp | 28 ++++++++++++++++++++++++++++ et_feeder/et_feeder_node.h | 8 ++++++++ 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/et_feeder/et_feeder.cpp b/et_feeder/et_feeder.cpp index 714b5d6d..d941649d 100644 --- a/et_feeder/et_feeder.cpp +++ b/et_feeder/et_feeder.cpp @@ -61,15 +61,8 @@ void ETFeeder::freeChildrenNodes(uint64_t node_id) { shared_ptr node = dep_graph_[node_id]; for (auto child : node->getChildren()) { auto child_chakra = child->getChakraNode(); - for (auto it = child_chakra->mutable_data_deps()->begin(); - it != child_chakra->mutable_data_deps()->end(); - ++it) { - if (*it == node_id) { - child_chakra->mutable_data_deps()->erase(it); - break; - } - } - if (child_chakra->data_deps().size() == 0) { + child->releaseParent(node_id); + if (child->getUnreleasedParents().size() == 0) { dep_free_node_id_set_.emplace(child_chakra->id()); dep_free_node_queue_.emplace(child); } @@ -95,13 +88,13 @@ shared_ptr ETFeeder::readNode() { shared_ptr node = make_shared(pkt_msg); bool dep_unresolved = false; - for (int i = 0; i < pkt_msg->data_deps_size(); ++i) { - auto parent_node = dep_graph_.find(pkt_msg->data_deps(i)); + for (uint64_t parent_node_id : node->all_deps()) { + auto parent_node = dep_graph_.find(parent_node_id); if (parent_node != dep_graph_.end()) { parent_node->second->addChild(node); } else { dep_unresolved = true; - node->addDepUnresolvedParentID(pkt_msg->data_deps(i)); + node->addDepUnresolvedParentID(parent_node_id); } } @@ -160,7 +153,7 @@ void ETFeeder::readNextWindow() { uint64_t node_id = node_id_node.first; shared_ptr node = node_id_node.second; if ((dep_free_node_id_set_.count(node_id) == 0) && - (node->getChakraNode()->data_deps().size() == 0)) { + (node->getUnreleasedParents().size() == 0)) { dep_free_node_id_set_.emplace(node_id); dep_free_node_queue_.emplace(node); } diff --git a/et_feeder/et_feeder_node.cpp b/et_feeder/et_feeder_node.cpp index fa5bb3de..f46a94cc 100644 --- a/et_feeder/et_feeder_node.cpp +++ b/et_feeder/et_feeder_node.cpp @@ -34,6 +34,14 @@ ETFeederNode::ETFeederNode(std::shared_ptr node) { assign_attr_val(node, i, (void*)(&comm_tag_)); } } + + for (const auto& parent_id : node->data_deps()) + this->all_deps_.emplace(parent_id); + for (const auto& parent_id : node->ctrl_deps()) + this->all_deps_.emplace(parent_id); + + for (const auto& parent_id : this->all_deps_) + this->unreleased_parent_ids_.emplace(parent_id); } shared_ptr ETFeederNode::getChakraNode() { @@ -67,6 +75,26 @@ void ETFeederNode::setDepUnresolvedParentIDs( dep_unresolved_parent_ids_ = dep_unresolved_parent_ids; } +void ETFeederNode::releaseParent(const uint64_t& parent_id) { + this->unreleased_parent_ids_.erase(parent_id); +} + +const std::unordered_set& ETFeederNode::getUnreleasedParents() { + return this->unreleased_parent_ids_; +} + +const auto& ETFeederNode::data_deps() { + return this->getChakraNode()->data_deps(); +} + +const auto& ETFeederNode::ctrl_deps() { + return this->getChakraNode()->ctrl_deps(); +} + +const std::unordered_set& ETFeederNode::all_deps() { + return this->all_deps_; +} + void ETFeederNode::assign_attr_val( shared_ptr node, int i, diff --git a/et_feeder/et_feeder_node.h b/et_feeder/et_feeder_node.h index 9a592325..008e10ff 100644 --- a/et_feeder/et_feeder_node.h +++ b/et_feeder/et_feeder_node.h @@ -18,6 +18,11 @@ class ETFeederNode { std::vector getDepUnresolvedParentIDs(); void setDepUnresolvedParentIDs( std::vector const& dep_unresolved_parent_ids); + void releaseParent(const uint64_t& parent_id); + const std::unordered_set& getUnreleasedParents(); + const auto& data_deps(); + const auto& ctrl_deps(); + const std::unordered_set& all_deps(); uint64_t id(); std::string name(); @@ -46,6 +51,9 @@ class ETFeederNode { std::unordered_set> children_set_{}; std::vector> children_vec_{}; std::vector dep_unresolved_parent_ids_{}; + std::unordered_set unreleased_parent_ids_{}; + + std::unordered_set all_deps_{}; uint64_t id_; std::string name_;