@@ -24,6 +24,7 @@ limitations under the License. */
24
24
#include " paddle/fluid/operators/listen_and_serv_op.h"
25
25
#include " paddle/fluid/operators/math/math_function.h"
26
26
#include " paddle/fluid/operators/math/selected_rows_functor.h"
27
+ #include " paddle/fluid/platform/nccl_helper.h"
27
28
#include " paddle/fluid/string/printf.h"
28
29
29
30
USE_NO_KERNEL_OP (listen_and_serv);
@@ -36,7 +37,7 @@ namespace string = paddle::string;
36
37
37
38
std::unique_ptr<detail::AsyncGRPCServer> rpc_service;
38
39
39
- void StartServer () {
40
+ void StartServer (std::atomic< bool >* initialized ) {
40
41
f::Scope scope;
41
42
p::CPUPlace place;
42
43
scope.Var (NCCL_ID_VARNAME);
@@ -54,6 +55,7 @@ void StartServer() {
54
55
55
56
std::thread server_thread (
56
57
std::bind (&detail::AsyncGRPCServer::RunSyncUpdate, rpc_service.get ()));
58
+ *initialized = true ;
57
59
rpc_service->SetCond (0 );
58
60
auto recv = rpc_service->Get ();
59
61
LOG (INFO) << " got nccl id and stop server..." ;
@@ -62,9 +64,13 @@ void StartServer() {
62
64
}
63
65
64
66
TEST (SendNcclId, Normal) {
65
- std::thread server_thread (StartServer);
67
+ std::atomic<bool > initialized{false };
68
+ std::thread server_thread (StartServer, &initialized);
69
+ while (!initialized) {
70
+ }
66
71
// wait server to start
67
- rpc_service.WaitServerReady ();
72
+ // sleep(2);
73
+ rpc_service->WaitServerReady ();
68
74
69
75
f::Scope scope;
70
76
p::CPUPlace place;
0 commit comments