diff --git a/paddle/fluid/framework/executor.cc b/paddle/fluid/framework/executor.cc index 39287501385844a7ee1225d132c9372325135342..84f67fafa19ac545ebb7a1019059e3c74c363c56 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 5d2e3688797d9328b2d4b797b7a628b1f76f4547..4a09f3870d64d8e14b2db41ff3ea7c2f9e67b558 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 5f4c134837507dc0600bac5c3d39dc04bbe507e3..d49ee34eeaf4e80f6fd4f8cdc548cc2b938d0f2a 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]) {