Skip to content

Commit b78ffde

Browse files
committed
Add stopped sign for grpc client
1 parent bc5555b commit b78ffde

File tree

6 files changed

+457
-4
lines changed

6 files changed

+457
-4
lines changed

cmake/external/grpc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ExternalProject_Add(
5050
UPDATE_COMMAND ""
5151
CONFIGURE_COMMAND ""
5252
BUILD_IN_SOURCE 1
53-
PATCH_COMMAND cp ${PADDLE_SOURCE_DIR}/patches/grpc/grpc_library.h ${GRPC_SOURCES_DIR}/include/grpcpp/impl/codegen/grpc_library.h && cp ${PADDLE_SOURCE_DIR}/patches/grpc/completion_queue.h ${GRPC_SOURCES_DIR}/include/grpcpp/impl/codegen/completion_queue.h
53+
PATCH_COMMAND cp ${PADDLE_SOURCE_DIR}/patches/grpc/grpc_library.h ${GRPC_SOURCES_DIR}/src/extern_grpc/include/grpcpp/impl/codegen/grpc_library.h && cp ${PADDLE_SOURCE_DIR}/patches/grpc/completion_queue.h ${GRPC_SOURCES_DIR}/src/extern_grpc/include/grpcpp/impl/codegen/completion_queue.h
5454
# NOTE(yuyang18):
5555
# Disable -Werror, otherwise the compile will fail in MacOS.
5656
# It seems that we cannot configure that by make command.

paddle/fluid/operators/distributed/grpc_client.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void GRPCClient::SendComplete() {
4949
}
5050

5151
GRPCClient::~GRPCClient() {
52+
stopped_ = true;
5253
Wait();
5354
cq_.Shutdown();
5455
{
@@ -275,7 +276,7 @@ void GRPCClient::Proceed() {
275276
void* tag = nullptr;
276277
bool ok = false;
277278

278-
while (cq_.Next(&tag, &ok)) {
279+
while (!stopped_ && cq_.Next(&tag, &ok)) {
279280
BaseProcessor* c = static_cast<BaseProcessor*>(tag);
280281
GPR_ASSERT(ok);
281282
PADDLE_ENFORCE(c);

paddle/fluid/operators/distributed/grpc_client.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class CheckpointNotifyProcessor : public BaseProcessor {
174174

175175
class GRPCClient : public RPCClient {
176176
public:
177-
GRPCClient() : ok_(true), completed_(false) {}
177+
GRPCClient() : ok_(true), completed_(false), stopped_(false) {}
178178
virtual ~GRPCClient();
179179

180180
bool AsyncSendVar(const std::string& ep, const platform::DeviceContext& ctx,
@@ -237,6 +237,8 @@ class GRPCClient : public RPCClient {
237237
// mutex for sending complete message only once
238238
std::mutex completed_mutex_;
239239
bool completed_;
240+
241+
bool stopped_;
240242
};
241243

242244
} // namespace distributed

0 commit comments

Comments
 (0)