From f3e983e49987b32af57e2e7924be8b245041ec4d Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Mon, 19 Mar 2018 17:08:19 +0800 Subject: [PATCH] Memory order --- paddle/fluid/framework/parallel_executor.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/framework/parallel_executor.cc b/paddle/fluid/framework/parallel_executor.cc index 2898c5ffd9..875b5d8ba7 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 -- GitLab