Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
92002ebe
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看板
提交
92002ebe
编写于
6月 24, 2019
作者:
H
Hong Ming
浏览文件
操作
浏览文件
下载
差异文件
fix segmentfault occurs on some devices(MTK and docker)
上级
7fde8419
24cdd8d8
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
31 addition
and
31 deletion
+31
-31
paddle/fluid/lite/core/cpu_info.cc
paddle/fluid/lite/core/cpu_info.cc
+31
-31
未找到文件。
paddle/fluid/lite/core/cpu_info.cc
浏览文件 @
92002ebe
...
@@ -106,13 +106,17 @@ size_t get_mem_size() {
...
@@ -106,13 +106,17 @@ size_t get_mem_size() {
}
}
void
get_cpu_arch
(
std
::
vector
<
ARMArch
>*
archs
,
const
int
cpu_num
)
{
void
get_cpu_arch
(
std
::
vector
<
ARMArch
>*
archs
,
const
int
cpu_num
)
{
archs
->
clear
();
archs
->
resize
(
cpu_num
);
for
(
int
i
=
0
;
i
<
cpu_num
;
++
i
)
{
archs
->
at
(
i
)
=
kARMArch_UNKOWN
;
}
#ifdef LITE_WITH_LINUX
#ifdef LITE_WITH_LINUX
//! get CPU ARCH
//! get CPU ARCH
FILE
*
fp
=
fopen
(
"/proc/cpuinfo"
,
"rb"
);
FILE
*
fp
=
fopen
(
"/proc/cpuinfo"
,
"rb"
);
if
(
!
fp
)
{
if
(
!
fp
)
{
return
;
return
;
}
}
int
cpu_idx
=
0
;
char
line
[
1024
];
char
line
[
1024
];
while
(
!
feof
(
fp
))
{
while
(
!
feof
(
fp
))
{
char
*
s
=
fgets
(
line
,
1024
,
fp
);
char
*
s
=
fgets
(
line
,
1024
,
fp
);
...
@@ -120,77 +124,73 @@ void get_cpu_arch(std::vector<ARMArch>* archs, const int cpu_num) {
...
@@ -120,77 +124,73 @@ void get_cpu_arch(std::vector<ARMArch>* archs, const int cpu_num) {
break
;
break
;
}
}
if
(
strstr
(
line
,
"part"
)
!=
NULL
)
{
if
(
strstr
(
line
,
"part"
)
!=
NULL
)
{
ARMArch
arch_type
=
kARMArch_UNKOWN
;
int
arch_id
=
0
;
int
arch_id
=
0
;
sscanf
(
s
,
"CPU part
\t
: %x"
,
&
arch_id
);
sscanf
(
s
,
"CPU part
\t
: %x"
,
&
arch_id
);
switch
(
arch_id
)
{
switch
(
arch_id
)
{
case
0xd03
:
case
0xd03
:
arch
s
->
push_back
(
kA53
)
;
arch
_type
=
kA53
;
break
;
break
;
case
0xd05
:
case
0xd05
:
arch
s
->
push_back
(
kA55
)
;
arch
_type
=
kA55
;
break
;
break
;
case
0xd07
:
case
0xd07
:
arch
s
->
push_back
(
kA57
)
;
arch
_type
=
kA57
;
break
;
break
;
case
0xd08
:
case
0xd08
:
arch
s
->
push_back
(
kA72
)
;
arch
_type
=
kA72
;
break
;
break
;
case
0xd09
:
case
0xd09
:
arch
s
->
push_back
(
kA73
)
;
arch
_type
=
kA73
;
break
;
break
;
case
0xd0a
:
case
0xd0a
:
arch
s
->
push_back
(
kA75
)
;
arch
_type
=
kA75
;
break
;
break
;
case
0xd40
:
case
0xd40
:
arch
s
->
push_back
(
kA76
)
;
arch
_type
=
kA76
;
break
;
break
;
case
0x804
:
case
0x804
:
// 855
// 855
arch
s
->
push_back
(
kA76
)
;
arch
_type
=
kA76
;
break
;
break
;
case
0x805
:
case
0x805
:
// 855
// 855
arch
s
->
push_back
(
kA55
)
;
arch
_type
=
kA55
;
break
;
break
;
case
0x802
:
case
0x802
:
// 845
// 845
arch
s
->
push_back
(
kA75
)
;
arch
_type
=
kA75
;
break
;
break
;
case
0x803
:
case
0x803
:
// 845
// 845
arch
s
->
push_back
(
kA55
)
;
arch
_type
=
kA55
;
break
;
break
;
case
0x801
:
case
0x801
:
// 835
// 835
arch
s
->
push_back
(
kA73
)
;
arch
_type
=
kA73
;
break
;
break
;
case
0x800
:
case
0x800
:
// 835
// 835
arch
s
->
push_back
(
kA73
)
;
arch
_type
=
kA73
;
break
;
break
;
case
0x205
:
case
0x205
:
// 820
// 820
arch
s
->
push_back
(
kA72
)
;
arch
_type
=
kA72
;
break
;
break
;
default:
default:
LOG
(
ERROR
)
<<
"Unknow cpu arch: "
<<
arch_id
;
LOG
(
ERROR
)
<<
"Unknow cpu arch: "
<<
arch_id
;
archs
->
push_back
(
kARMArch_UNKOWN
);
}
}
archs
->
at
(
cpu_idx
)
=
arch_type
;
cpu_idx
++
;
}
}
}
}
fclose
(
fp
);
fclose
(
fp
);
if
(
archs
->
size
()
<
cpu_num
)
{
for
(;
cpu_idx
>
0
&&
cpu_idx
<
cpu_num
;
++
cpu_idx
)
{
for
(
int
i
=
archs
->
size
();
i
<
cpu_num
;
++
i
)
{
archs
->
at
(
cpu_idx
)
=
archs
->
at
(
cpu_idx
-
1
);
archs
->
push_back
(
archs
->
at
(
i
-
1
));
}
}
}
#elif defined(TARGET_IOS)
#elif defined(TARGET_IOS)
for
(
int
i
=
0
;
i
<
cpu_num
;
++
i
)
{
for
(
int
i
=
0
;
i
<
cpu_num
;
++
i
)
{
archs
->
push_back
(
APPLE
);
archs
->
at
(
i
)
=
APPLE
;
}
#else
for
(
int
i
=
0
;
i
<
cpu_num
;
++
i
)
{
archs
->
push_back
(
kARMArch_UNKOWN
);
}
}
#endif
#endif
}
}
...
@@ -829,9 +829,9 @@ int DeviceInfo::Setup() {
...
@@ -829,9 +829,9 @@ int DeviceInfo::Setup() {
mem_size_
=
get_mem_size
();
mem_size_
=
get_mem_size
();
get_cpu_arch
(
&
archs_
,
core_num_
);
get_cpu_arch
(
&
archs_
,
core_num_
);
// set defalut CPU info
// set defalut CPU info
SetCacheInfo
(
0
,
DEFAULT_L1_CACHE_SIZE
);
SetCacheInfo
(
0
,
1
,
DEFAULT_L1_CACHE_SIZE
);
SetCacheInfo
(
1
,
DEFAULT_L2_CACHE_SIZE
);
SetCacheInfo
(
1
,
1
,
DEFAULT_L2_CACHE_SIZE
);
SetCacheInfo
(
2
,
DEFAULT_L3_CACHE_SIZE
);
SetCacheInfo
(
2
,
1
,
DEFAULT_L3_CACHE_SIZE
);
#ifdef LITE_WITH_LINUX
#ifdef LITE_WITH_LINUX
// get max&min freq
// get max&min freq
max_freqs_
.
resize
(
core_num_
);
max_freqs_
.
resize
(
core_num_
);
...
@@ -936,9 +936,9 @@ void DeviceInfo::SetRunMode(PowerMode mode, int thread_num) {
...
@@ -936,9 +936,9 @@ void DeviceInfo::SetRunMode(PowerMode mode, int thread_num) {
}
}
void
DeviceInfo
::
SetCache
(
int
l1size
,
int
l2size
,
int
l3size
)
{
void
DeviceInfo
::
SetCache
(
int
l1size
,
int
l2size
,
int
l3size
)
{
SetCacheInfo
(
0
,
l1size
);
SetCacheInfo
(
0
,
1
,
l1size
);
SetCacheInfo
(
1
,
l2size
);
SetCacheInfo
(
1
,
1
,
l2size
);
SetCacheInfo
(
2
,
l3size
);
SetCacheInfo
(
2
,
1
,
l3size
);
workspace_
.
Resize
({
2
*
(
l1size
+
l2size
)});
workspace_
.
Resize
({
2
*
(
l1size
+
l2size
)});
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录