From 37410a0c752cc87751bad8810971fa049f101d74 Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Mon, 2 Jul 2018 14:46:09 +0800 Subject: [PATCH] update by comment --- paddle/fluid/framework/executor.cc | 16 ++++++---------- .../fluid/operators/distributed/grpc_client.cc | 2 ++ paddle/fluid/operators/distributed/rpc_server.cc | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/paddle/fluid/framework/executor.cc b/paddle/fluid/framework/executor.cc index 39287501385..84f67fafa19 100644 --- a/paddle/fluid/framework/executor.cc +++ b/paddle/fluid/framework/executor.cc @@ -47,19 +47,15 @@ Executor::Executor(const platform::Place& place) : place_(place) {} #ifdef PADDLE_WITH_DISTRIBUTE void Executor::BeginPass() { - auto client = ::paddle::operators::distributed::RPCClient::GetInstance< - ::paddle::operators::distributed::GRPCClient>(); - - client->SendBeginPass(); - client->Wait(); + ::paddle::operators::distributed::RPCClient::GetInstance< + ::paddle::operators::distributed::GRPCClient>() + ->SendBeginPass(); } void Executor::EndPass() { - auto client = ::paddle::operators::distributed::RPCClient::GetInstance< - ::paddle::operators::distributed::GRPCClient>(); - - client->SendEndPass(); - client->Wait(); + ::paddle::operators::distributed::RPCClient::GetInstance< + ::paddle::operators::distributed::GRPCClient>() + ->SendEndPass(); } #endif diff --git a/paddle/fluid/operators/distributed/grpc_client.cc b/paddle/fluid/operators/distributed/grpc_client.cc index 5d2e3688797..4a09f3870d6 100644 --- a/paddle/fluid/operators/distributed/grpc_client.cc +++ b/paddle/fluid/operators/distributed/grpc_client.cc @@ -40,6 +40,7 @@ void GRPCClient::SendBeginPass() { VLOG(3) << "send begin pass to: " << it.first; this->AsyncSendBeginPass(it.first); } + this->Wait(); } void GRPCClient::SendEndPass() { @@ -47,6 +48,7 @@ void GRPCClient::SendEndPass() { VLOG(3) << "send end pass to " << it.first; this->AsyncSendEndPass(it.first); } + this->Wait(); } GRPCClient::~GRPCClient() { diff --git a/paddle/fluid/operators/distributed/rpc_server.cc b/paddle/fluid/operators/distributed/rpc_server.cc index 5f4c1348375..d49ee34eeaf 100644 --- a/paddle/fluid/operators/distributed/rpc_server.cc +++ b/paddle/fluid/operators/distributed/rpc_server.cc @@ -67,7 +67,7 @@ void RPCServer::IncreaseBatchBarrier(const std::string rpc_name) { void RPCServer::BeginPass() { VLOG(4) << "RPCServer begin increase pass barrier"; { - std::unique_lock locl(mutex_); + std::unique_lock lock(mutex_); client_num_++; VLOG(4) << "increase client_num to: " << client_num_; } @@ -77,7 +77,7 @@ void RPCServer::BeginPass() { void RPCServer::EndPass() { VLOG(4) << "RPCServer begin increase pass barrier"; { - std::unique_lock locl(mutex_); + std::unique_lock lock(mutex_); client_num_--; VLOG(4) << "decrease client_num to: " << client_num_; if (cur_cond_.load() == rpc_cond_map_[kRequestGet]) { -- GitLab