提交 d3a14377 编写于 作者: Q Qiao Longfei

add fake rpc to send

上级 43378ad6
...@@ -191,15 +191,17 @@ void Communicator::RecvThread() { ...@@ -191,15 +191,17 @@ void Communicator::RecvThread() {
void Communicator::Send(const std::string &var_name, void Communicator::Send(const std::string &var_name,
const framework::Scope &scope) { const framework::Scope &scope) {
VLOG(3) << "communicator send " << var_name; if (!FLAGS_communicator_fake_rpc) {
// push var into send queue by var_name VLOG(3) << "communicator send " << var_name;
auto *grad_var = scope.FindVar(var_name); // push var into send queue by var_name
PADDLE_ENFORCE(grad_var->IsInitialized(), "grad var should be inited"); auto *grad_var = scope.FindVar(var_name);
auto tmp_grad_var = std::make_shared<Variable>(); PADDLE_ENFORCE(grad_var->IsInitialized(), "grad var should be inited");
framework::CopyVariable(*grad_var, tmp_grad_var.get()); auto tmp_grad_var = std::make_shared<Variable>();
auto &queue = send_varname_to_queue_.at(var_name); framework::CopyVariable(*grad_var, tmp_grad_var.get());
VLOG(3) << "send " << var_name << " queue size " << queue->Size(); auto &queue = send_varname_to_queue_.at(var_name);
queue->Push(tmp_grad_var); VLOG(3) << "send " << var_name << " queue size " << queue->Size();
queue->Push(tmp_grad_var);
}
} }
Communicator *Communicator::GetInstance() { return communicator_.get(); } Communicator *Communicator::GetInstance() { return communicator_.get(); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册