Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
ab6bc60d
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ab6bc60d
编写于
5月 21, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
5月 21, 2020
浏览文件
操作
浏览文件
下载
差异文件
!1314 Using context variable instead of environment variable in profiling
Merge pull request !1314 from caifubi/using-context-instead-of-env
上级
332e4de1
eb079de2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
50 deletion
+47
-50
mindspore/ccsrc/device/ascend/profiling/profiling_manager.cc
mindspore/ccsrc/device/ascend/profiling/profiling_manager.cc
+43
-48
mindspore/ccsrc/device/ascend/profiling/profiling_manager.h
mindspore/ccsrc/device/ascend/profiling/profiling_manager.h
+4
-2
未找到文件。
mindspore/ccsrc/device/ascend/profiling/profiling_manager.cc
浏览文件 @
ab6bc60d
...
...
@@ -114,9 +114,6 @@ bool ProfilingManager::StartupProfiling(uint32_t device_id) {
return
true
;
}
device_id_
=
device_id
;
// exp: export PROFILING_MODE=true
// export PROFILING_OPTIONS=training_trace
const
char
*
prof_options_str
=
std
::
getenv
(
"PROFILING_OPTIONS"
);
// register Framework to profiling
int
result
=
Msprof
::
Engine
::
RegisterEngine
(
"Framework"
,
engine_0_
.
get
());
if
(
result
!=
0
)
{
...
...
@@ -124,53 +121,51 @@ bool ProfilingManager::StartupProfiling(uint32_t device_id) {
return
false
;
}
if
(
prof_options_str
!=
nullptr
)
{
const
string
prof_options_str_tmp
=
prof_options_str
;
vector
<
string
>
opts
=
Split
(
prof_options_str_tmp
,
':'
);
if
(
!
opts
.
empty
())
{
// current one docker only use one device`
Json
p_device
;
// JOBID
auto
job_id
=
GetJobId
();
p_device
[
"jobID"
]
=
std
::
to_string
(
job_id
);
// device_id
p_device
[
"deviceID"
]
=
std
::
to_string
(
device_id
);
// features:'training_trace', 'task_trace' etc
Json
features
;
for
(
vector
<
string
>::
size_type
i
=
0
;
i
<
opts
.
size
();
i
++
)
{
Json
f
;
f
[
"name"
]
=
opts
[
i
];
features
[
i
]
=
f
;
}
p_device
[
"features"
]
=
features
;
// only one device, but sProfMgrStartUp API require for device list
Json
devices
;
devices
[
0
]
=
p_device
;
Json
startCfg
;
startCfg
[
"startCfg"
]
=
devices
;
// convert json to string
std
::
stringstream
ss
;
ss
<<
startCfg
;
std
::
string
cfg
=
ss
.
str
();
MS_LOG
(
INFO
)
<<
"profiling config "
<<
cfg
;
// call profiling startup API
ProfMgrCfg
prof_cfg
=
{
cfg
};
prof_handle_
=
ProfMgrStartUp
(
&
prof_cfg
);
if
(
prof_handle_
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"Startup profiling failed."
;
return
false
;
}
}
auto
context
=
MsContext
::
GetInstance
();
MS_EXCEPTION_IF_NULL
(
context
);
const
string
prof_options_str
=
context
->
profiling_options
();
vector
<
string
>
opts
=
Split
(
prof_options_str
,
':'
);
if
(
opts
.
empty
())
{
MS_LOG
(
WARNING
)
<<
"Profiling is enabled, but profiling option is not set!"
;
return
true
;
}
// current one docker only use one device`
Json
p_device
;
// JOBID
auto
job_id
=
GetJobId
();
p_device
[
"jobID"
]
=
std
::
to_string
(
job_id
);
// device_id
p_device
[
"deviceID"
]
=
std
::
to_string
(
device_id
);
// features:'training_trace', 'task_trace' etc
Json
features
;
for
(
vector
<
string
>::
size_type
i
=
0
;
i
<
opts
.
size
();
i
++
)
{
Json
f
;
f
[
"name"
]
=
opts
[
i
];
features
[
i
]
=
f
;
}
p_device
[
"features"
]
=
features
;
// only one device, but sProfMgrStartUp API require for device list
Json
devices
;
devices
[
0
]
=
p_device
;
Json
startCfg
;
startCfg
[
"startCfg"
]
=
devices
;
// convert json to string
std
::
stringstream
ss
;
ss
<<
startCfg
;
std
::
string
cfg
=
ss
.
str
();
MS_LOG
(
INFO
)
<<
"profiling config "
<<
cfg
;
// call profiling startup API
ProfMgrCfg
prof_cfg
=
{
cfg
};
prof_handle_
=
ProfMgrStartUp
(
&
prof_cfg
);
if
(
prof_handle_
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"Startup profiling failed."
;
return
false
;
}
return
true
;
}
...
...
mindspore/ccsrc/device/ascend/profiling/profiling_manager.h
浏览文件 @
ab6bc60d
...
...
@@ -20,6 +20,7 @@
#include <cstring>
#include <string>
#include <memory>
#include "utils/context/ms_context.h"
using
std
::
map
;
using
std
::
string
;
...
...
@@ -41,8 +42,9 @@ class ProfilingManager {
bool
StopProfiling
()
const
;
inline
bool
IsProfiling
()
const
{
const
char
*
is_profiling
=
std
::
getenv
(
"PROFILING_MODE"
);
return
(
is_profiling
!=
nullptr
&&
(
strcmp
(
"true"
,
is_profiling
)
==
0
));
auto
context
=
MsContext
::
GetInstance
();
MS_EXCEPTION_IF_NULL
(
context
);
return
context
->
enable_profiling
();
}
protected:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录