From 5ae0c664b01d36a0fbdaf78886b08bc9e5d3b883 Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Sat, 12 May 2018 09:02:39 +0800 Subject: [PATCH] fix build and merge develop --- paddle/fluid/operators/test_send_nccl_id.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/operators/test_send_nccl_id.cc b/paddle/fluid/operators/test_send_nccl_id.cc index 2c3c5ea0a..bbae1d54a 100644 --- a/paddle/fluid/operators/test_send_nccl_id.cc +++ b/paddle/fluid/operators/test_send_nccl_id.cc @@ -24,6 +24,7 @@ limitations under the License. */ #include "paddle/fluid/operators/listen_and_serv_op.h" #include "paddle/fluid/operators/math/math_function.h" #include "paddle/fluid/operators/math/selected_rows_functor.h" +#include "paddle/fluid/platform/nccl_helper.h" #include "paddle/fluid/string/printf.h" USE_NO_KERNEL_OP(listen_and_serv); @@ -36,7 +37,7 @@ namespace string = paddle::string; std::unique_ptr rpc_service; -void StartServer() { +void StartServer(std::atomic* initialized) { f::Scope scope; p::CPUPlace place; scope.Var(NCCL_ID_VARNAME); @@ -54,6 +55,7 @@ void StartServer() { std::thread server_thread( std::bind(&detail::AsyncGRPCServer::RunSyncUpdate, rpc_service.get())); + *initialized = true; rpc_service->SetCond(0); auto recv = rpc_service->Get(); LOG(INFO) << "got nccl id and stop server..."; @@ -62,9 +64,13 @@ void StartServer() { } TEST(SendNcclId, Normal) { - std::thread server_thread(StartServer); + std::atomic initialized{false}; + std::thread server_thread(StartServer, &initialized); + while (!initialized) { + } // wait server to start - rpc_service.WaitServerReady(); + // sleep(2); + rpc_service->WaitServerReady(); f::Scope scope; p::CPUPlace place; -- GitLab