提交 f3e983e4 编写于 作者: Y Yu Yang

Memory order

上级 36e04152
...@@ -702,7 +702,7 @@ void ParallelExecutor::Run(const std::vector<std::string> &fetch_tensors, ...@@ -702,7 +702,7 @@ void ParallelExecutor::Run(const std::vector<std::string> &fetch_tensors,
while (!pending_ops.empty()) { while (!pending_ops.empty()) {
VarHandleBase *ready_var = nullptr; VarHandleBase *ready_var = nullptr;
for (auto &pair : pending_vars) { for (auto &pair : pending_vars) {
if (pair.second) { if (pair.second.load(std::memory_order_acquire)) {
ready_var = pair.first; ready_var = pair.first;
} }
} }
...@@ -714,7 +714,6 @@ void ParallelExecutor::Run(const std::vector<std::string> &fetch_tensors, ...@@ -714,7 +714,6 @@ void ParallelExecutor::Run(const std::vector<std::string> &fetch_tensors,
throw * member_->exception_; throw * member_->exception_;
} }
std::this_thread::yield();
continue; continue;
} }
...@@ -753,7 +752,7 @@ void ParallelExecutor::RunOp( ...@@ -753,7 +752,7 @@ void ParallelExecutor::RunOp(
VLOG(10) << op->DebugString(); VLOG(10) << op->DebugString();
op->Run(); op->Run();
for (auto *ready : ready_buffer) { for (auto *ready : ready_buffer) {
*ready = true; ready->store(true, std::memory_order_release);
} }
} catch (platform::EnforceNotMet ex) { } catch (platform::EnforceNotMet ex) {
member_->exception_.reset(new platform::EnforceNotMet(ex)); member_->exception_.reset(new platform::EnforceNotMet(ex));
...@@ -762,8 +761,7 @@ void ParallelExecutor::RunOp( ...@@ -762,8 +761,7 @@ void ParallelExecutor::RunOp(
} }
}; };
op_run(); member_->pool_.enqueue(op_run);
// member_->pool_.enqueue(op_run);
} }
} // namespace framework } // namespace framework
} // namespace paddle } // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册