Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
708c90ed
Mace
项目概览
Xiaomi
/
Mace
通知
106
Star
40
Fork
27
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
708c90ed
编写于
4月 28, 2018
作者:
李
李寅
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'valgrind' into 'master'
Enable valgrind memory leak check in bazel run See merge request !440
上级
cd275bf7
64f60d9a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
97 addition
and
12 deletion
+97
-12
tools/bazel_adb_run.py
tools/bazel_adb_run.py
+44
-11
tools/sh_commands.py
tools/sh_commands.py
+53
-1
未找到文件。
tools/bazel_adb_run.py
浏览文件 @
708c90ed
...
@@ -83,6 +83,21 @@ def parse_args():
...
@@ -83,6 +83,21 @@ def parse_args():
type
=
bool
,
type
=
bool
,
default
=
False
,
default
=
False
,
help
=
"Whether to run the target"
)
help
=
"Whether to run the target"
)
parser
.
add_argument
(
"--valgrind"
,
type
=
bool
,
default
=
False
,
help
=
"Whether to use valgrind to check memory error."
)
parser
.
add_argument
(
"--valgrind_path"
,
type
=
str
,
default
=
"/data/local/valgrind"
,
help
=
"Valgrind install path."
)
parser
.
add_argument
(
"--valgrind_args"
,
type
=
str
,
default
=
""
,
help
=
"Valgrind command args."
)
parser
.
add_argument
(
"--args"
,
type
=
str
,
default
=
""
,
help
=
"Command args"
)
parser
.
add_argument
(
"--args"
,
type
=
str
,
default
=
""
,
help
=
"Command args"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--stdout_processor"
,
"--stdout_processor"
,
...
@@ -114,9 +129,14 @@ def main(unused_args):
...
@@ -114,9 +129,14 @@ def main(unused_args):
sh_commands
.
gen_compiled_opencl_source
()
sh_commands
.
gen_compiled_opencl_source
()
sh_commands
.
gen_mace_version
()
sh_commands
.
gen_mace_version
()
strip
=
"always"
debug
=
False
if
FLAGS
.
valgrind
:
strip
=
"never"
debug
=
True
for
target_abi
in
target_abis
:
for
target_abi
in
target_abis
:
sh_commands
.
bazel_build
(
target
,
abi
=
target_abi
,
sh_commands
.
bazel_build
(
target
,
strip
=
strip
,
abi
=
target_abi
,
disable_no_tuning_warning
=
True
)
disable_no_tuning_warning
=
True
,
debug
=
debug
)
if
FLAGS
.
run_target
:
if
FLAGS
.
run_target
:
for
serialno
in
target_devices
:
for
serialno
in
target_devices
:
if
target_abi
not
in
set
(
if
target_abi
not
in
set
(
...
@@ -124,15 +144,28 @@ def main(unused_args):
...
@@ -124,15 +144,28 @@ def main(unused_args):
print
(
"Skip device %s which does not support ABI %s"
%
print
(
"Skip device %s which does not support ABI %s"
%
(
serialno
,
target_abi
))
(
serialno
,
target_abi
))
continue
continue
stdouts
=
sh_commands
.
adb_run
(
if
FLAGS
.
valgrind
:
serialno
,
stdouts
=
sh_commands
.
adb_run_valgrind
(
host_bin_path
,
serialno
,
bin_name
,
host_bin_path
,
args
=
FLAGS
.
args
,
bin_name
,
opencl_profiling
=
1
,
valgrind_path
=
FLAGS
.
valgrind_path
,
vlog_level
=
0
,
valgrind_args
=
FLAGS
.
valgrind_args
,
device_bin_path
=
"/data/local/tmp/mace"
,
args
=
FLAGS
.
args
,
out_of_range_check
=
1
)
opencl_profiling
=
1
,
vlog_level
=
0
,
device_bin_path
=
"/data/local/tmp/mace"
,
out_of_range_check
=
1
)
else
:
stdouts
=
sh_commands
.
adb_run
(
serialno
,
host_bin_path
,
bin_name
,
args
=
FLAGS
.
args
,
opencl_profiling
=
1
,
vlog_level
=
0
,
device_bin_path
=
"/data/local/tmp/mace"
,
out_of_range_check
=
1
)
device_properties
=
sh_commands
.
adb_getprop_by_serialno
(
device_properties
=
sh_commands
.
adb_getprop_by_serialno
(
serialno
)
serialno
)
globals
()[
FLAGS
.
stdout_processor
](
stdouts
,
device_properties
,
globals
()[
FLAGS
.
stdout_processor
](
stdouts
,
device_properties
,
...
...
tools/sh_commands.py
浏览文件 @
708c90ed
...
@@ -215,6 +215,55 @@ def adb_run(serialno,
...
@@ -215,6 +215,55 @@ def adb_run(serialno,
return
""
.
join
(
stdout_buff
)
return
""
.
join
(
stdout_buff
)
def
adb_run_valgrind
(
serialno
,
host_bin_path
,
bin_name
,
valgrind_path
=
"/data/local/valgrind"
,
valgrind_args
=
""
,
args
=
""
,
opencl_profiling
=
1
,
vlog_level
=
0
,
device_bin_path
=
"/data/local/tmp/mace"
,
out_of_range_check
=
1
):
valgrind_lib
=
valgrind_path
+
"/lib/valgrind"
valgrind_bin
=
valgrind_path
+
"/bin/valgrind"
host_bin_full_path
=
"%s/%s"
%
(
host_bin_path
,
bin_name
)
device_bin_full_path
=
"%s/%s"
%
(
device_bin_path
,
bin_name
)
props
=
adb_getprop_by_serialno
(
serialno
)
print
(
"====================================================================="
)
print
(
"Trying to lock device %s"
%
serialno
)
with
device_lock
(
serialno
):
print
(
"Run on device: %s, %s, %s"
%
(
serialno
,
props
[
"ro.board.platform"
],
props
[
"ro.product.model"
]))
result
=
sh
.
adb
(
"-s"
,
serialno
,
"shell"
,
"ls %s"
%
valgrind_path
)
if
result
.
startswith
(
"ls:"
):
print
(
"Please install valgrind to %s manually."
%
valgrind_path
)
return
result
sh
.
adb
(
"-s"
,
serialno
,
"shell"
,
"rm -rf %s"
%
device_bin_path
)
sh
.
adb
(
"-s"
,
serialno
,
"shell"
,
"mkdir -p %s"
%
device_bin_path
)
adb_push
(
host_bin_full_path
,
device_bin_full_path
,
serialno
)
print
(
"Run %s"
%
device_bin_full_path
)
stdout_buff
=
[]
process_output
=
make_output_processor
(
stdout_buff
)
p
=
sh
.
adb
(
"-s"
,
serialno
,
"shell"
,
"MACE_OUT_OF_RANGE_CHECK=%d MACE_OPENCL_PROFILING=%d "
"MACE_CPP_MIN_VLOG_LEVEL=%d VALGRIND_LIB=%s %s %s %s %s "
%
(
out_of_range_check
,
opencl_profiling
,
vlog_level
,
valgrind_lib
,
valgrind_bin
,
valgrind_args
,
device_bin_full_path
,
args
),
_out
=
process_output
,
_bg
=
True
,
_err_to_out
=
True
)
p
.
wait
()
return
""
.
join
(
stdout_buff
)
################################
################################
# bazel commands
# bazel commands
################################
################################
...
@@ -224,7 +273,8 @@ def bazel_build(target,
...
@@ -224,7 +273,8 @@ def bazel_build(target,
model_tag
=
""
,
model_tag
=
""
,
production_mode
=
False
,
production_mode
=
False
,
hexagon_mode
=
False
,
hexagon_mode
=
False
,
disable_no_tuning_warning
=
False
):
disable_no_tuning_warning
=
False
,
debug
=
False
):
print
(
"* Build %s with ABI %s"
%
(
target
,
abi
))
print
(
"* Build %s with ABI %s"
%
(
target
,
abi
))
stdout_buff
=
[]
stdout_buff
=
[]
process_output
=
make_output_processor
(
stdout_buff
)
process_output
=
make_output_processor
(
stdout_buff
)
...
@@ -278,6 +328,8 @@ def bazel_build(target,
...
@@ -278,6 +328,8 @@ def bazel_build(target,
"hexagon=%s"
%
str
(
hexagon_mode
).
lower
())
"hexagon=%s"
%
str
(
hexagon_mode
).
lower
())
if
disable_no_tuning_warning
:
if
disable_no_tuning_warning
:
bazel_args
+=
(
"--copt=-DMACE_DISABLE_NO_TUNING_WARNING"
,)
bazel_args
+=
(
"--copt=-DMACE_DISABLE_NO_TUNING_WARNING"
,)
if
debug
:
bazel_args
+=
(
"--copt=-g"
,)
p
=
sh
.
bazel
(
p
=
sh
.
bazel
(
_out
=
process_output
,
_out
=
process_output
,
_bg
=
True
,
_bg
=
True
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录