Skip to content

Commit 00f8e63

Browse files
committed
update
1 parent 94eea16 commit 00f8e63

File tree

4 files changed

+33
-36
lines changed

4 files changed

+33
-36
lines changed

paddle/fluid/operators/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ if(WITH_DISTRIBUTE)
193193
set_source_files_properties(send_vars_op.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
194194
op_library(send_barrier_op DEPS ${DISTRIBUTE_DEPS})
195195
set_source_files_properties(send_barrier_op.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
196+
set_source_files_properties(send_recv_op_test.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
196197
cc_test(test_send_recv SRCS send_recv_op_test.cc DEPS prefetch_op send_op listen_and_serv_op sum_op executor)
197198
else()
198199
set(DEPS_OPS ${DEPS_OPS} send_op prefetch_op recv_op listen_and_serv_op send_vars_op send_barrier_op)

paddle/fluid/operators/detail/grpc_server.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,6 @@ void AsyncGRPCServer::TryToRegisterNewSendOne() {
244244
VLOG(3) << "shutdown, do not TryToRegisterNewSendOne";
245245
return;
246246
}
247-
while (scope_ == nullptr) {
248-
sleep(0.01);
249-
}
250247
RequestSend* send = new RequestSend(&service_, cq_send_.get(), scope_,
251248
&var_recv_queue_, dev_ctx_);
252249
VLOG(4) << "Create RequestSend status:" << send->Status();

paddle/fluid/operators/listen_and_serv_op.cc

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,38 @@ void RunServer(std::shared_ptr<detail::AsyncGRPCServer> service) {
2525
VLOG(4) << "RunServer thread end";
2626
}
2727

28+
static void CreateTensorFromMessageType(framework::Variable *var,
29+
sendrecv::VarType var_type) {
30+
if (var_type == sendrecv::VarType::LOD_TENSOR) {
31+
var->GetMutable<framework::LoDTensor>();
32+
} else if (var_type == sendrecv::VarType::SELECTED_ROWS) {
33+
var->GetMutable<framework::SelectedRows>();
34+
} else {
35+
PADDLE_THROW(
36+
"VariableMessage type %d is not in "
37+
"[LoDTensor, SelectedRows]",
38+
var_type);
39+
}
40+
}
41+
42+
static void ParallelExecuteBlocks(const std::vector<size_t> &parallel_blkids,
43+
framework::Executor *executor,
44+
framework::ProgramDesc *program,
45+
framework::Scope *scope) {
46+
std::vector<std::future<void>> fs;
47+
for (size_t idx : parallel_blkids) {
48+
fs.push_back(framework::Async([&executor, &program, &scope, idx]() {
49+
int run_block = idx; // thread local
50+
try {
51+
executor->Run(*program, scope, run_block, false, false);
52+
} catch (std::exception &e) {
53+
LOG(ERROR) << "run sub program error " << e.what();
54+
}
55+
}));
56+
}
57+
for (size_t i = 0; i < fs.size(); ++i) fs[i].wait();
58+
}
59+
2860
ListenAndServOp::ListenAndServOp(const std::string &type,
2961
const framework::VariableNameMap &inputs,
3062
const framework::VariableNameMap &outputs,
@@ -62,7 +94,6 @@ void ListenAndServOp::RunImpl(const framework::Scope &scope,
6294

6395
framework::Executor executor(dev_place);
6496

65-
// FIXME(Yancey1989): initialize rpc server with lazy mode.
6697
rpc_service_->SetScope(&recv_scope);
6798
rpc_service_->SetDevCtx(&dev_ctx);
6899
// TODO(qiao) set proper fields for table lookup and update

paddle/fluid/operators/listen_and_serv_op.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,6 @@ constexpr char kOptimizeBlock[] = "OptimizeBlock";
3030

3131
void RunServer(std::shared_ptr<detail::AsyncGRPCServer> service);
3232

33-
static void CreateTensorFromMessageType(framework::Variable *var,
34-
sendrecv::VarType var_type) {
35-
if (var_type == sendrecv::VarType::LOD_TENSOR) {
36-
var->GetMutable<framework::LoDTensor>();
37-
} else if (var_type == sendrecv::VarType::SELECTED_ROWS) {
38-
var->GetMutable<framework::SelectedRows>();
39-
} else {
40-
PADDLE_THROW(
41-
"VariableMessage type %d is not in "
42-
"[LoDTensor, SelectedRows]",
43-
var_type);
44-
}
45-
}
46-
47-
static void ParallelExecuteBlocks(const std::vector<size_t> &parallel_blkids,
48-
framework::Executor *executor,
49-
framework::ProgramDesc *program,
50-
framework::Scope *scope) {
51-
std::vector<std::future<void>> fs;
52-
for (size_t idx : parallel_blkids) {
53-
fs.push_back(framework::Async([&executor, &program, &scope, idx]() {
54-
int run_block = idx; // thread local
55-
try {
56-
executor->Run(*program, scope, run_block, false, false);
57-
} catch (std::exception &e) {
58-
LOG(ERROR) << "run sub program error " << e.what();
59-
}
60-
}));
61-
}
62-
for (size_t i = 0; i < fs.size(); ++i) fs[i].wait();
63-
}
64-
6533
class ListenAndServOp : public framework::OperatorBase {
6634
public:
6735
ListenAndServOp(const std::string &type,

0 commit comments

Comments
 (0)