From 3238ce06727d1daadfd5c93c12b7e9073f75e695 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Tue, 20 Mar 2018 12:47:01 +0800 Subject: [PATCH] Add wait --- paddle/fluid/framework/parallel_executor.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/paddle/fluid/framework/parallel_executor.cc b/paddle/fluid/framework/parallel_executor.cc index 409cb3fbb91..6408ecdd376 100644 --- a/paddle/fluid/framework/parallel_executor.cc +++ b/paddle/fluid/framework/parallel_executor.cc @@ -813,6 +813,16 @@ void ParallelExecutor::Run(const std::vector &fetch_tensors, fetch_ops.clear(); *member_->global_scope_->Var(fetched_var_name)->GetMutable() = fetched_data->tensors_; + // FIXME: + // It could be optimized by using multiple events in an operator. + // Manually sync computation during iter. + for (auto &s : member_->communication_streams_) { + s.second.ctx_->Wait(); + } + + for (auto &p : member_->places_) { + platform::DeviceContextPool::Instance().Get(p)->Wait(); + } } void ParallelExecutor::RunOp( -- GitLab