Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
ad5a2b3e
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ad5a2b3e
编写于
3月 11, 2019
作者:
Q
Qiao Longfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add some debug flags for communicator
上级
eb6af305
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
16 addition
and
6 deletion
+16
-6
paddle/fluid/operators/distributed/communicator.cc
paddle/fluid/operators/distributed/communicator.cc
+16
-6
未找到文件。
paddle/fluid/operators/distributed/communicator.cc
浏览文件 @
ad5a2b3e
...
@@ -30,7 +30,11 @@ DEFINE_bool(communicator_independent_recv_thread, true,
...
@@ -30,7 +30,11 @@ DEFINE_bool(communicator_independent_recv_thread, true,
DEFINE_int32
(
communicator_send_queue_size
,
20
,
DEFINE_int32
(
communicator_send_queue_size
,
20
,
"queue size to recv gradient before send"
);
"queue size to recv gradient before send"
);
DEFINE_int32
(
communicator_recv_wait_ms
,
200
,
"wait time between each recv"
);
DEFINE_int32
(
communicator_recv_wait_ms
,
200
,
"wait time between each recv"
);
DEFINE_int32
(
communicator_thread_pool_size
,
5
,
"wait time between each recv"
);
DEFINE_int32
(
communicator_thread_pool_size
,
5
,
"thread num to do send or recv"
);
DEFINE_int32
(
communicator_max_merge_var_num
,
20
,
"max var num to merge and send"
);
DEFINE_bool
(
communicator_fake_rpc
,
false
,
"fake mode does not really send any thing"
);
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
@@ -92,6 +96,9 @@ Communicator::Communicator(const RpcCtxMap &send_varname_to_ctx,
...
@@ -92,6 +96,9 @@ Communicator::Communicator(const RpcCtxMap &send_varname_to_ctx,
VLOG
(
0
)
<<
"communicator_recv_wait_ms: "
<<
FLAGS_communicator_recv_wait_ms
;
VLOG
(
0
)
<<
"communicator_recv_wait_ms: "
<<
FLAGS_communicator_recv_wait_ms
;
VLOG
(
0
)
<<
"communicator_thread_pool_size: "
VLOG
(
0
)
<<
"communicator_thread_pool_size: "
<<
FLAGS_communicator_thread_pool_size
;
<<
FLAGS_communicator_thread_pool_size
;
VLOG
(
0
)
<<
"communicator_max_merge_var_num"
<<
FLAGS_communicator_max_merge_var_num
;
VLOG
(
0
)
<<
"communicator_fake_rpc: "
<<
FLAGS_communicator_fake_rpc
;
send_scope_
.
reset
(
new
Scope
());
send_scope_
.
reset
(
new
Scope
());
for
(
auto
&
iter
:
send_varname_to_ctx_
)
{
for
(
auto
&
iter
:
send_varname_to_ctx_
)
{
send_varname_to_queue_
[
iter
.
first
]
=
send_varname_to_queue_
[
iter
.
first
]
=
...
@@ -123,17 +130,18 @@ void Communicator::SendThread() {
...
@@ -123,17 +130,18 @@ void Communicator::SendThread() {
auto
send_task
=
[
this
,
&
var_name
,
&
var_queue
]
{
auto
send_task
=
[
this
,
&
var_name
,
&
var_queue
]
{
VLOG
(
3
)
<<
"merge var "
<<
var_name
<<
" and send"
;
VLOG
(
3
)
<<
"merge var "
<<
var_name
<<
" and send"
;
std
::
vector
<
std
::
shared_ptr
<
Variable
>>
vars
;
std
::
vector
<
std
::
shared_ptr
<
Variable
>>
vars
;
// TODO(qiao): need to be configurable
const
size_t
max_merge_var_num
=
20
;
size_t
merged_var_num
=
0
;
size_t
merged_var_num
=
0
;
while
(
var_queue
->
Size
()
>
0
&&
merged_var_num
<
max_merge_var_num
)
{
while
(
var_queue
->
Size
()
>
0
&&
merged_var_num
<
FLAGS_communicator_max_merge_var_num
)
{
vars
.
push_back
(
var_queue
->
Pop
());
vars
.
push_back
(
var_queue
->
Pop
());
merged_var_num
++
;
merged_var_num
++
;
}
}
MergeVars
(
var_name
,
vars
,
send_scope_
.
get
());
MergeVars
(
var_name
,
vars
,
send_scope_
.
get
());
auto
send_functor
=
distributed
::
ParameterSend
<
float
>
();
auto
send_functor
=
distributed
::
ParameterSend
<
float
>
();
auto
&
ctx
=
send_varname_to_ctx_
.
at
(
var_name
);
auto
&
ctx
=
send_varname_to_ctx_
.
at
(
var_name
);
if
(
!
FLAGS_communicator_fake_rpc
)
{
send_functor
(
ctx
,
*
send_scope_
,
true
);
send_functor
(
ctx
,
*
send_scope_
,
true
);
}
};
};
task_futures
.
emplace_back
(
task_futures
.
emplace_back
(
send_threadpool_
->
enqueue
(
std
::
move
(
send_task
)));
send_threadpool_
->
enqueue
(
std
::
move
(
send_task
)));
...
@@ -160,7 +168,9 @@ void Communicator::RecvAll() {
...
@@ -160,7 +168,9 @@ void Communicator::RecvAll() {
auto
&
var_name
=
iter
.
first
;
auto
&
var_name
=
iter
.
first
;
VLOG
(
3
)
<<
"recv var "
<<
var_name
;
VLOG
(
3
)
<<
"recv var "
<<
var_name
;
auto
recv_functor
=
distributed
::
ParameterRecv
<
float
>
();
auto
recv_functor
=
distributed
::
ParameterRecv
<
float
>
();
if
(
!
FLAGS_communicator_fake_rpc
)
{
recv_functor
(
iter
.
second
,
*
recv_scope_
);
recv_functor
(
iter
.
second
,
*
recv_scope_
);
}
};
};
task_futures
.
emplace_back
(
recv_threadpool_
->
enqueue
(
std
::
move
(
recv_task
)));
task_futures
.
emplace_back
(
recv_threadpool_
->
enqueue
(
std
::
move
(
recv_task
)));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录