diff --git a/paddle/fluid/framework/parallel_executor.cc b/paddle/fluid/framework/parallel_executor.cc index 2898c5ffd973b0d76bee4b9e3a24a8fce912fad2..875b5d8ba7acc826e6d657f96f1b26acb06141f6 100644 --- a/paddle/fluid/framework/parallel_executor.cc +++ b/paddle/fluid/framework/parallel_executor.cc @@ -702,7 +702,7 @@ void ParallelExecutor::Run(const std::vector &fetch_tensors, while (!pending_ops.empty()) { VarHandleBase *ready_var = nullptr; for (auto &pair : pending_vars) { - if (pair.second) { + if (pair.second.load(std::memory_order_acquire)) { ready_var = pair.first; } } @@ -714,7 +714,6 @@ void ParallelExecutor::Run(const std::vector &fetch_tensors, throw * member_->exception_; } - std::this_thread::yield(); continue; } @@ -753,7 +752,7 @@ void ParallelExecutor::RunOp( VLOG(10) << op->DebugString(); op->Run(); for (auto *ready : ready_buffer) { - *ready = true; + ready->store(true, std::memory_order_release); } } catch (platform::EnforceNotMet ex) { member_->exception_.reset(new platform::EnforceNotMet(ex)); @@ -762,8 +761,7 @@ void ParallelExecutor::RunOp( } }; - op_run(); - // member_->pool_.enqueue(op_run); + member_->pool_.enqueue(op_run); } } // namespace framework } // namespace paddle