From 0594d2a7f086cc64b58f01aeb0299cc06c683825 Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Tue, 12 Oct 2021 10:05:52 +0800 Subject: [PATCH] Revert "refine case when thread_num = 1 (#36201)" (#36347) This reverts commit 7e60cc63c33f0c17df36b0ee52ae50a3d04a6697. --- .../fast_threaded_ssa_graph_executor.cc | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc b/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc index eb027d7c2f..75998e4582 100644 --- a/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc +++ b/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc @@ -47,16 +47,7 @@ FastThreadedSSAGraphExecutor::FastThreadedSSAGraphExecutor( << "Change thread number to 1 because the toposort order is unique"; strategy_.num_threads_ = 1; } - if (strategy_.num_threads_ > 1) { - pool_.reset(new ::ThreadPool(strategy.num_threads_)); - } else { - auto nodes = ir::TopologySortOperations(*graph_); - traced_ops_.clear(); - traced_ops_.reserve(nodes.size()); - for (auto *node : nodes) { - traced_ops_.push_back(&node->Wrapper()); - } - } + pool_.reset(new ::ThreadPool(strategy.num_threads_)); for (auto &op : ir::FilterByNodeWrapper(*graph_)) { int dep = static_cast(op->NotReadyInputSize()); op_deps_.emplace(op, dep); @@ -239,7 +230,7 @@ void FastThreadedSSAGraphExecutor::RunOpAsync( OpHandleBase *op, const std::shared_ptr> &complete_q) { ++remaining_; - auto func = [=] { + this->pool_->enqueue([=] { std::deque op_queue; op_queue.push_front(op); @@ -298,12 +289,7 @@ void FastThreadedSSAGraphExecutor::RunOpAsync( } --remaining_; complete_q->Push(complete); - }; - if (pool_) { - pool_->enqueue(func); - } else { - func(); - } + }); } void FastThreadedSSAGraphExecutor::PrepareAtomicOpDeps() { -- GitLab