Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
15dd5e1a
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
403
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
15dd5e1a
编写于
11月 04, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mgb/core): fix memory management release cambricon var issue
GitOrigin-RevId: abf881978c8fd85b3cfa823fea13045ff06fb88e
上级
38ea5f1b
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
37 addition
and
18 deletion
+37
-18
CMakeLists.txt
CMakeLists.txt
+2
-0
src/core/impl/comp_node/comp_node.cpp
src/core/impl/comp_node/comp_node.cpp
+5
-5
src/core/impl/comp_node_env.cpp
src/core/impl/comp_node_env.cpp
+3
-0
src/core/impl/exception.cpp
src/core/impl/exception.cpp
+1
-0
src/core/impl/graph/var_node_mem_mgr.cpp
src/core/impl/graph/var_node_mem_mgr.cpp
+16
-8
src/core/impl/graph/var_node_mem_mgr.h
src/core/impl/graph/var_node_mem_mgr.h
+1
-1
src/core/include/megbrain/comp_node_env.h
src/core/include/megbrain/comp_node_env.h
+6
-3
src/core/test/comp_node.cpp
src/core/test/comp_node.cpp
+3
-0
src/megbrain_build_config.h.in
src/megbrain_build_config.h.in
+0
-1
未找到文件。
CMakeLists.txt
浏览文件 @
15dd5e1a
...
...
@@ -513,6 +513,7 @@ if(MGE_WITH_ATLAS)
set
(
MGB_ATLAS
${
MGE_WITH_ATLAS
}
)
endif
()
find_program
(
CCACHE_BIN ccache
)
if
(
CCACHE_BIN
)
set
(
CMAKE_CXX_COMPILER_LAUNCHER
${
CCACHE_BIN
}
)
...
...
@@ -688,6 +689,7 @@ if(MGE_ARCH STREQUAL "aarch64")
set
(
MEGDNN_AARCH64 1
)
set
(
MEGDNN_64_BIT 1
)
set
(
MARCH
"-march=armv8-a"
)
set
(
MGB_AARCH64 1
)
if
(
MGE_ARMV8_2_FEATURE_FP16
)
message
(
STATUS
"Enable fp16 feature support in armv8.2"
)
if
(
NOT
${
MGE_DISABLE_FLOAT16
}
)
...
...
src/core/impl/comp_node/comp_node.cpp
浏览文件 @
15dd5e1a
...
...
@@ -177,11 +177,11 @@ CompNode::Locator CompNode::Locator::parse(const std::string &id) {
dev_type
=
DeviceType
::
CAMBRICON
;
ptr
+=
9
;
}
else
if
(
ptr
[
0
]
==
'm'
)
{
if
(
strncmp
(
ptr
,
"multithread"
,
11
))
{
err
();
}
dev_type
=
DeviceType
::
MULTITHREAD
;
ptr
+=
11
;
if
(
strncmp
(
ptr
,
"multithread"
,
11
))
{
err
();
}
dev_type
=
DeviceType
::
MULTITHREAD
;
ptr
+=
11
;
}
else
{
if
(
ptr
[
1
]
!=
'p'
||
ptr
[
2
]
!=
'u'
)
{
err
();
...
...
src/core/impl/comp_node_env.cpp
浏览文件 @
15dd5e1a
...
...
@@ -35,6 +35,7 @@
#include "megcore_atlas.h"
#endif
using
namespace
mgb
;
/* =================== MegDNNHandle =================== */
...
...
@@ -101,6 +102,7 @@ MegDNNHandle::MegDNNHandle(const CompNodeEnv& env) {
}
#endif
if
(
env
.
property
().
type
==
CompNode
::
DeviceType
::
CPU
)
{
megcoreCreateDeviceHandle
(
&
m_dev_hdl
,
megcorePlatformCPU
);
megcoreCreateComputingHandleWithCPUDispatcher
(
&
m_comp_hdl
,
m_dev_hdl
,
...
...
@@ -254,6 +256,7 @@ void CompNodeEnv::init_atlas(CompNode comp_node, const AtlasEnv& env) {
#endif
#if MGB_ROCM
void
mgb
::
_on_hip_error
(
const
char
*
expr
,
hipError_t
err
,
const
char
*
file
,
...
...
src/core/impl/exception.cpp
浏览文件 @
15dd5e1a
...
...
@@ -77,6 +77,7 @@ AtlasError::AtlasError(const std::string &msg):
}
ROCmError
::
ROCmError
(
const
std
::
string
&
msg
)
:
SystemError
(
msg
)
{
...
...
src/core/impl/graph/var_node_mem_mgr.cpp
浏览文件 @
15dd5e1a
...
...
@@ -125,7 +125,7 @@ StaticDeviceMemoryManager::make_default_impl() {
#endif // MGB_THREAD_SAFE
/* ==================== AsyncVarReleaser ==================== */
#if MGB_CUDA || MGB_ATLAS
#if MGB_CUDA || MGB_ATLAS
|| MGB_CAMBRICON
class
VarNodeMemManager
::
AsyncVarReleaser
{
struct
WaiterParam
{
CompNode
cn
;
...
...
@@ -245,18 +245,18 @@ bool VarNodeMemManager::ImpureMemPlanManager::check_need_realloc() {
}
/* ==================== VarNodeMemManager ==================== */
VarNodeMemManager
::
VarNodeMemManager
(
ComputingGraphImpl
*
graph
)
:
m_owner_graph
(
graph
),
m_seq_mem_opt
(
graph
)
#if MGB_CUDA || MGB_ATLAS
,
m_asyn_var_releaser
(
new
AsyncVarReleaser
)
VarNodeMemManager
::
VarNodeMemManager
(
ComputingGraphImpl
*
graph
)
:
m_owner_graph
(
graph
),
m_seq_mem_opt
(
graph
)
#if MGB_CUDA || MGB_ATLAS
|| MGB_CAMBRICON
,
m_asyn_var_releaser
(
new
AsyncVarReleaser
)
#endif
{
auto
on_comp_seq_finish
=
[
this
](
const
event
::
CompSeqExecFinished
&
ev
)
{
MGB_MARK_USED_VAR
(
ev
);
// async release is only used for sync between multiple comp nodes, and
// does not wait for device to finish
#if MGB_CUDA || MGB_ATLAS
#if MGB_CUDA || MGB_ATLAS
|| MGB_CAMBRICON
m_asyn_var_releaser
->
wait_release_finish
();
#endif
m_cpu_async_release_barrier
.
wait_zero
();
...
...
@@ -297,7 +297,8 @@ VarNodeMemManager::VarNodeMemManager(ComputingGraphImpl *graph):
graph
->
event
().
register_receiver_permanent
<
event
::
CompSeqExecError
>
(
on_comp_seq_error
);
#if MGB_ENABLE_VAR_DEV_MEM_DEFRAGMENTER && (MGB_CUDA || MGB_ATLAS)
#if MGB_ENABLE_VAR_DEV_MEM_DEFRAGMENTER && \
(MGB_CUDA || MGB_ATLAS || MGB_CAMBRICON )
auto
on_mem_defrag_start
=
[
this
](
const
event
::
BeforeMemDefrag
&
)
{
m_asyn_var_releaser
->
wait_release_finish
();
};
...
...
@@ -1448,6 +1449,13 @@ void VarNodeMemManager::decr_var_mem_refcnt(
m_asyn_var_releaser
->
add
(
dispatch_cn
,
var
);
break
;
}
#endif
#if MGB_CAMBRICON
case
DT
::
CAMBRICON
:
{
m_asyn_var_releaser
->
add
(
dispatch_cn
,
var
);
break
;
}
#endif
default:
mgb_throw
(
MegBrainError
,
...
...
src/core/impl/graph/var_node_mem_mgr.h
浏览文件 @
15dd5e1a
...
...
@@ -446,7 +446,7 @@ class VarNodeMemManager {
SyncableCounter
m_cpu_async_release_barrier
;
#if MGB_CUDA || MGB_ATLAS
#if MGB_CUDA || MGB_ATLAS
|| MGB_CAMBRICON
//! release dynamic var on after compnode event finishes
class
AsyncVarReleaser
;
std
::
unique_ptr
<
AsyncVarReleaser
>
m_asyn_var_releaser
;
...
...
src/core/include/megbrain/comp_node_env.h
浏览文件 @
15dd5e1a
...
...
@@ -90,6 +90,7 @@
#endif // MGB_ATLAS
#if MGB_ROCM
#include "hcc_detail/hcc_defs_prologue.h"
#include "megcore_rocm.h"
...
...
@@ -194,6 +195,7 @@ namespace mgb {
const
char
*
file
,
const
char
*
func
,
int
line
);
#endif
#if MGB_CUDA
[[
noreturn
]]
void
_on_cuda_error
(
const
char
*
expr
,
cudaError_t
err
,
const
char
*
file
,
const
char
*
func
,
int
line
);
...
...
@@ -325,6 +327,7 @@ public:
}
#endif
}
/*!
...
...
@@ -426,6 +429,8 @@ public:
void
init_atlas
(
CompNode
comp_node
,
const
AtlasEnv
&
env
);
#endif
#if MGB_ROCM
struct
ROCmEnv
{
int
device
=
-
1
;
...
...
@@ -485,9 +490,7 @@ public:
};
static
InitStatus
init_status
;
static
void
init
()
{
init_status
.
init
();
}
static
void
init
()
{
init_status
.
init
();
}
void
activate
()
const
{
init
();
...
...
src/core/test/comp_node.cpp
浏览文件 @
15dd5e1a
...
...
@@ -62,6 +62,7 @@ TEST(TestCompNode, Parse) {
ASSERT_EQ
(
L
::
parse
(
"multithread:default:2"
),
make_lc
(
D
::
MULTITHREAD
,
L
::
DEVICE_MULTITHREAD_DEFAULT
,
2
));
ASSERT_THROW
(
L
::
parse
(
"apu"
),
MegBrainError
);
ASSERT_THROW
(
L
::
parse
(
"fpgbx"
),
MegBrainError
);
ASSERT_THROW
(
L
::
parse
(
"cab0"
),
MegBrainError
);
...
...
@@ -149,6 +150,7 @@ TEST(TestCompNode, Load) {
auto
atlas1
=
CompNode
::
load
(
"atlas1"
);
ASSERT_NE
(
atlas0
,
atlas1
);
#endif
}
TEST
(
TestCompNode
,
FreeAfterFinalize
)
{
...
...
@@ -762,6 +764,7 @@ TEST(TestCompNodeAtlas, D2DCopy) {
}
#endif
namespace
{
class
CompNodeDepedentObjectInst
final
:
public
CompNodeDepedentObject
{
int
*
m_dst
,
*
m_timer
;
...
...
src/megbrain_build_config.h.in
浏览文件 @
15dd5e1a
...
...
@@ -33,7 +33,6 @@
#cmakedefine01 MGB_ENABLE_OPR_MM
#cmakedefine01 MGB_ENABLE_FBS_SERIALIZATION
#cmakedefine01 MGB_IS_DEV
// DNN related flags
// Platform macro's
#cmakedefine01 MEGDNN_WITH_CUDA
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录