Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
990c9099
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,发现更多精彩内容 >>
提交
990c9099
编写于
1月 11, 2018
作者:
L
Liangliang He
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add memory usage logging
上级
4f6af627
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
106 addition
and
0 deletion
+106
-0
mace/core/BUILD
mace/core/BUILD
+2
-0
mace/core/net.cc
mace/core/net.cc
+2
-0
mace/core/runtime/opencl/opencl_development.cc
mace/core/runtime/opencl/opencl_development.cc
+1
-0
mace/core/runtime/opencl/opencl_production.cc
mace/core/runtime/opencl/opencl_production.cc
+1
-0
mace/utils/BUILD
mace/utils/BUILD
+1
-0
mace/utils/memory_logging.h
mace/utils/memory_logging.h
+98
-0
tools/bazel-adb-run.sh
tools/bazel-adb-run.sh
+1
-0
未找到文件。
mace/core/BUILD
浏览文件 @
990c9099
...
...
@@ -97,6 +97,7 @@ cc_library(
deps
=
[
":opencl_headers"
,
"//mace/codegen:generated_opencl_dev"
,
"//mace/utils:logging"
,
"//mace/utils:utils_hdrs"
,
],
)
...
...
@@ -108,5 +109,6 @@ cc_library(
deps
=
[
":opencl_headers"
,
"//mace/codegen:generated_opencl_prod"
,
"//mace/utils:logging"
,
],
)
mace/core/net.cc
浏览文件 @
990c9099
...
...
@@ -5,6 +5,7 @@
#include "mace/core/net.h"
#include "mace/core/workspace.h"
#include "mace/utils/utils.h"
#include "mace/utils/memory_logging.h"
namespace
mace
{
...
...
@@ -36,6 +37,7 @@ SimpleNet::SimpleNet(const std::shared_ptr<const OperatorRegistry> op_registry,
}
bool
SimpleNet
::
Run
(
RunMetadata
*
run_metadata
)
{
MACE_MEMORY_LOGGING_GUARD
();
VLOG
(
1
)
<<
"Running net "
<<
name_
;
for
(
auto
iter
=
operators_
.
begin
();
iter
!=
operators_
.
end
();
++
iter
)
{
bool
future_wait
=
(
device_type_
==
DeviceType
::
OPENCL
&&
...
...
mace/core/runtime/opencl/opencl_development.cc
浏览文件 @
990c9099
...
...
@@ -6,6 +6,7 @@
#include "mace/core/runtime/opencl/cl2_header.h"
#include "mace/utils/utils.h"
#include "mace/utils/logging.h"
namespace
mace
{
...
...
mace/core/runtime/opencl/opencl_production.cc
浏览文件 @
990c9099
...
...
@@ -4,6 +4,7 @@
#include <vector>
#include "mace/core/runtime/opencl/cl2_header.h"
#include "mace/utils/logging.h"
namespace
mace
{
...
...
mace/utils/BUILD
浏览文件 @
990c9099
...
...
@@ -16,6 +16,7 @@ cc_library(
],
hdrs
=
[
"logging.h"
,
"memory_logging.h"
,
],
linkopts
=
if_android
([
"-llog"
,
...
...
mace/utils/memory_logging.h
0 → 100644
浏览文件 @
990c9099
//
// Copyright (c) 2017 XiaoMi All rights reserved.
//
#ifndef MACE_UTILS_MEMORY_LOGGING_H_
#define MACE_UTILS_MEMORY_LOGGING_H_
#include <malloc.h>
#include "mace/utils/logging.h"
namespace
mace
{
class
MallinfoChangeLogger
{
public:
MallinfoChangeLogger
(
const
std
::
string
&
name
)
:
name_
(
name
)
{
prev_
=
mallinfo
();
}
~
MallinfoChangeLogger
()
{
struct
mallinfo
curr
=
mallinfo
();
LogMallinfoChange
(
name_
,
curr
,
prev_
);
}
private:
const
std
::
string
name_
;
struct
mallinfo
prev_
;
struct
mallinfo
LogMallinfoChange
(
const
std
::
string
&
name
,
const
struct
mallinfo
curr
,
const
struct
mallinfo
prev
)
{
if
(
prev
.
arena
!=
curr
.
arena
)
{
LOG
(
INFO
)
<<
"["
<<
name
<<
"] "
<<
"Non-mmapped space allocated (bytes): "
<<
curr
.
arena
<<
", diff: "
<<
((
int64_t
)
curr
.
arena
-
(
int64_t
)
prev
.
arena
);
}
if
(
prev
.
ordblks
!=
curr
.
ordblks
)
{
LOG
(
INFO
)
<<
"["
<<
name
<<
"] "
<<
"Number of free chunks: "
<<
curr
.
ordblks
<<
", diff: "
<<
((
int64_t
)
curr
.
ordblks
-
(
int64_t
)
prev
.
ordblks
);
}
if
(
prev
.
smblks
!=
curr
.
smblks
)
{
LOG
(
INFO
)
<<
"["
<<
name
<<
"] "
<<
"Number of free fastbin blocks: "
<<
curr
.
smblks
<<
", diff: "
<<
((
int64_t
)
curr
.
smblks
-
(
int64_t
)
prev
.
smblks
);
}
if
(
prev
.
hblks
!=
curr
.
hblks
)
{
LOG
(
INFO
)
<<
"["
<<
name
<<
"] "
<<
"Number of mmapped regions: "
<<
curr
.
hblks
<<
", diff: "
<<
((
int64_t
)
curr
.
hblks
-
(
int64_t
)
prev
.
hblks
);
}
if
(
prev
.
hblkhd
!=
curr
.
hblkhd
)
{
LOG
(
INFO
)
<<
"["
<<
name
<<
"] "
<<
"Space allocated in mmapped regions (bytes): "
<<
curr
.
hblkhd
<<
", diff: "
<<
((
int64_t
)
curr
.
hblkhd
-
(
int64_t
)
prev
.
hblkhd
);
}
if
(
prev
.
usmblks
!=
curr
.
usmblks
)
{
LOG
(
INFO
)
<<
"["
<<
name
<<
"] "
<<
"Maximum total allocated space (bytes): "
<<
curr
.
usmblks
<<
", diff: "
<<
((
int64_t
)
curr
.
usmblks
-
(
int64_t
)
prev
.
usmblks
);
}
if
(
prev
.
fsmblks
!=
curr
.
fsmblks
)
{
LOG
(
INFO
)
<<
"["
<<
name
<<
"] "
<<
"Space in freed fastbin blocks (bytes): "
<<
curr
.
fsmblks
<<
", diff: "
<<
((
int64_t
)
curr
.
fsmblks
-
(
int64_t
)
prev
.
fsmblks
);
}
if
(
prev
.
uordblks
!=
curr
.
uordblks
)
{
LOG
(
INFO
)
<<
"["
<<
name
<<
"] "
<<
"Total allocated space (bytes): "
<<
curr
.
uordblks
<<
", diff: "
<<
((
int64_t
)
curr
.
uordblks
-
(
int64_t
)
prev
.
uordblks
);
}
if
(
prev
.
fordblks
!=
curr
.
fordblks
)
{
LOG
(
INFO
)
<<
"["
<<
name
<<
"] "
<<
"Total free space (bytes): "
<<
curr
.
fordblks
<<
", diff: "
<<
((
int64_t
)
curr
.
fordblks
-
(
int64_t
)
prev
.
fordblks
);
}
if
(
prev
.
keepcost
!=
curr
.
keepcost
)
{
LOG
(
INFO
)
<<
"["
<<
name
<<
"] "
<<
"Top-most, releasable space (bytes): "
<<
curr
.
keepcost
<<
", diff: "
<<
((
int64_t
)
curr
.
keepcost
-
(
int64_t
)
prev
.
keepcost
);
}
return
curr
;
}
};
#ifdef MACE_ENABLE_MEMORY_LOGGING
#define MACE_MEMORY_LOGGING_GUARD() \
MallinfoChangeLogger mem_logger_##__line__(std::string(__FILE__) + ":" + \
std::string(__func__));
#else
#define MACE_MEMORY_LOGGING_GUARD()
#endif
}
// namespace mace
#endif // MACE_UTILS_MEMORY_LOGGING_H_
tools/bazel-adb-run.sh
浏览文件 @
990c9099
...
...
@@ -29,6 +29,7 @@ python mace/python/tools/encrypt_opencl_codegen.py \
--cl_kernel_dir
=
./mace/kernels/opencl/cl/
--output_path
=
${
CODEGEN_DIR
}
/opencl/opencl_encrypt_program.cc
echo
"Step 2: Generate version source"
mkdir
-p
${
CODEGEN_DIR
}
/version
bash mace/tools/git/gen_version_source.sh
${
CODEGEN_DIR
}
/version/version.cc
echo
"Step 3: Build target"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录