Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
5496a7ab
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5496a7ab
编写于
3月 04, 2022
作者:
T
Thunderbrook
提交者:
GitHub
3月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Dump cpu xingneng (#40068)
* dump cpu * code format
上级
1ca379bf
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
29 deletion
+47
-29
paddle/fluid/framework/fleet/heter_ps/hashtable_inl.h
paddle/fluid/framework/fleet/heter_ps/hashtable_inl.h
+47
-29
未找到文件。
paddle/fluid/framework/fleet/heter_ps/hashtable_inl.h
浏览文件 @
5496a7ab
...
...
@@ -186,45 +186,63 @@ void HashTable<KeyType, ValType>::insert(const KeyType* d_keys, size_t len,
template
<
typename
KeyType
,
typename
ValType
>
void
HashTable
<
KeyType
,
ValType
>::
dump_to_cpu
(
int
devid
,
cudaStream_t
stream
)
{
container_
->
prefetch
(
cudaCpuDeviceId
,
stream
);
std
::
vector
<
std
::
thread
>
threads
;
size_t
num
=
container_
->
size
();
KeyType
unuse_key
=
std
::
numeric_limits
<
KeyType
>::
max
();
thrust
::
pair
<
KeyType
,
ValType
>*
kv
=
container_
->
data
();
for
(
size_t
i
=
0
;
i
<
num
;
++
i
)
{
if
(
kv
[
i
].
first
==
unuse_key
)
{
continue
;
}
ValType
&
gpu_val
=
kv
[
i
].
second
;
int
thread_num
=
8
;
int
len_per_thread
=
num
/
thread_num
;
int
remain
=
num
%
thread_num
;
int
begin
=
0
;
auto
dump_func
=
[
unuse_key
,
kv
](
int
left
,
int
right
)
{
for
(
int
i
=
left
;
i
<
right
;
i
++
)
{
if
(
kv
[
i
].
first
==
unuse_key
)
{
continue
;
}
ValType
&
gpu_val
=
kv
[
i
].
second
;
#ifdef PADDLE_WITH_PSLIB
auto
*
downpour_value
=
(
paddle
::
ps
::
DownpourFixedFeatureValue
*
)(
gpu_val
.
cpu_ptr
);
int
downpour_value_size
=
downpour_value
->
size
();
if
(
gpu_val
.
mf_size
>
0
&&
downpour_value_size
==
7
)
{
downpour_value
->
resize
(
gpu_val
.
mf_size
+
downpour_value_size
);
}
float
*
cpu_val
=
downpour_value
->
data
();
// cpu_val[0] = 0;
cpu_val
[
1
]
=
gpu_val
.
delta_score
;
cpu_val
[
2
]
=
gpu_val
.
show
;
cpu_val
[
3
]
=
gpu_val
.
clk
;
cpu_val
[
4
]
=
gpu_val
.
lr
;
cpu_val
[
5
]
=
gpu_val
.
lr_g2sum
;
cpu_val
[
6
]
=
gpu_val
.
slot
;
if
(
gpu_val
.
mf_size
>
0
)
{
for
(
int
x
=
0
;
x
<
gpu_val
.
mf_size
;
x
++
)
{
cpu_val
[
x
+
7
]
=
gpu_val
.
mf
[
x
];
auto
*
downpour_value
=
(
paddle
::
ps
::
DownpourFixedFeatureValue
*
)(
gpu_val
.
cpu_ptr
);
int
downpour_value_size
=
downpour_value
->
size
();
if
(
gpu_val
.
mf_size
>
0
&&
downpour_value_size
==
7
)
{
downpour_value
->
resize
(
gpu_val
.
mf_size
+
downpour_value_size
);
}
float
*
cpu_val
=
downpour_value
->
data
();
// cpu_val[0] = 0;
cpu_val
[
1
]
=
gpu_val
.
delta_score
;
cpu_val
[
2
]
=
gpu_val
.
show
;
cpu_val
[
3
]
=
gpu_val
.
clk
;
cpu_val
[
4
]
=
gpu_val
.
lr
;
cpu_val
[
5
]
=
gpu_val
.
lr_g2sum
;
cpu_val
[
6
]
=
gpu_val
.
slot
;
if
(
gpu_val
.
mf_size
>
0
)
{
for
(
int
x
=
0
;
x
<
gpu_val
.
mf_size
;
x
++
)
{
cpu_val
[
x
+
7
]
=
gpu_val
.
mf
[
x
];
}
}
}
#endif
#ifdef PADDLE_WITH_PSCORE
auto
*
downpour_value
=
(
paddle
::
distributed
::
VALUE
*
)(
gpu_val
.
cpu_ptr
);
downpour_value
->
count_
=
gpu_val
.
show
;
for
(
int
x
=
0
;
x
<
gpu_val
.
mf_size
;
x
++
)
{
downpour_value
->
data_
[
x
]
=
gpu_val
.
mf
[
x
];
}
auto
*
downpour_value
=
(
paddle
::
distributed
::
VALUE
*
)(
gpu_val
.
cpu_ptr
);
downpour_value
->
count_
=
gpu_val
.
show
;
for
(
int
x
=
0
;
x
<
gpu_val
.
mf_size
;
x
++
)
{
downpour_value
->
data_
[
x
]
=
gpu_val
.
mf
[
x
];
}
#endif
}
};
for
(
int
i
=
0
;
i
<
thread_num
;
i
++
)
{
threads
.
push_back
(
std
::
thread
(
dump_func
,
begin
,
begin
+
len_per_thread
+
(
i
<
remain
?
1
:
0
)));
begin
+=
len_per_thread
+
(
i
<
remain
?
1
:
0
);
}
for
(
std
::
thread
&
t
:
threads
)
{
t
.
join
();
}
container_
->
prefetch
(
devid
,
stream
);
//
container_->prefetch(devid, stream);
}
template
<
typename
KeyType
,
typename
ValType
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录