Skip to content

Commit d144dba

Browse files
committed
simplify code
1 parent 9c2d7df commit d144dba

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

paddle/fluid/operators/detail/grpc_server.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ class AsyncGRPCServer final {
5959

6060
void SetProgram(framework::ProgramDesc *program) { program_ = program; }
6161

62-
void SetPrefetchBlkdId(int blkid) { prefetch_blk_id_ = blkid; }
63-
6462
void SetExecutor(framework::Executor *executor) { executor_ = executor; }
6563

6664
void SetPrefetchPreparedCtx(framework::ExecutorPrepareContext *prepared) {
@@ -114,7 +112,6 @@ class AsyncGRPCServer final {
114112
std::unique_ptr<std::thread> t_get_;
115113
std::unique_ptr<std::thread> t_prefetch_;
116114

117-
int prefetch_blk_id_;
118115
framework::ExecutorPrepareContext *prefetch_ctx_;
119116
framework::ProgramDesc *program_;
120117
framework::Executor *executor_;

paddle/fluid/operators/listen_and_serv_op.cc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,6 @@ void ListenAndServOp::Stop() {
7070
server_thread_->join();
7171
}
7272

73-
void ListenAndServOp::PreparePrefetchCtx(
74-
framework::Executor *executor, framework::BlockDesc *prefetch_block,
75-
framework::ProgramDesc *program) const {
76-
VLOG(3) << "prefetch block id is " << prefetch_block->ID();
77-
rpc_service_->SetExecutor(executor);
78-
auto prefetch_prepared = executor->Prepare(*program, prefetch_block->ID());
79-
rpc_service_->SetPrefetchBlkdId(prefetch_block->ID());
80-
rpc_service_->SetPrefetchPreparedCtx(prefetch_prepared.get());
81-
prefetch_prepared.release();
82-
}
83-
8473
void ListenAndServOp::RunSyncUpdate(
8574
framework::Executor *executor, framework::ProgramDesc *program,
8675
framework::Scope *recv_scope, framework::BlockDesc *prefetch_block) const {
@@ -198,7 +187,14 @@ void ListenAndServOp::RunImpl(const framework::Scope &scope,
198187
rpc_service_->SetScope(&recv_scope);
199188
rpc_service_->SetDevCtx(&dev_ctx);
200189
rpc_service_->SetProgram(program);
201-
PreparePrefetchCtx(&executor, prefetch_block, program);
190+
rpc_service_->SetExecutor(&executor);
191+
192+
// prepare for prefetch
193+
VLOG(3) << "prefetch block id is " << prefetch_block->ID();
194+
auto prefetch_prepared = executor.Prepare(*program, prefetch_block->ID());
195+
rpc_service_->SetPrefetchPreparedCtx(prefetch_prepared.get());
196+
prefetch_prepared.release();
197+
202198
// start the server listening after all member initialized.
203199
server_thread_.reset(new std::thread(RunServer, rpc_service_));
204200
VLOG(3) << "wait server thread to become ready...";

paddle/fluid/operators/listen_and_serv_op.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ class ListenAndServOp : public framework::OperatorBase {
4141

4242
int GetSelectedPort() const;
4343

44-
void PreparePrefetchCtx(framework::Executor* executor,
45-
framework::BlockDesc* prefetch_block,
46-
framework::ProgramDesc* program) const;
47-
4844
void RunSyncUpdate(framework::Executor* executor,
4945
framework::ProgramDesc* program,
5046
framework::Scope* recv_scope,

0 commit comments

Comments
 (0)