Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
e4b404e8
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看板
提交
e4b404e8
编写于
3月 31, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
3月 31, 2020
浏览文件
操作
浏览文件
下载
差异文件
!32 auto-enable-dynamic-mem-pool
Merge pull request !32 from JoyLvliang/master
上级
6fb4d9a3
b3a30648
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
33 deletion
+17
-33
mindspore/ccsrc/device/ascend/ascend_kernel_runtime.cc
mindspore/ccsrc/device/ascend/ascend_kernel_runtime.cc
+14
-30
mindspore/ccsrc/device/ascend/ascend_memory_allocator.cc
mindspore/ccsrc/device/ascend/ascend_memory_allocator.cc
+1
-1
mindspore/ccsrc/device/ascend/ascend_memory_allocator.h
mindspore/ccsrc/device/ascend/ascend_memory_allocator.h
+1
-1
mindspore/ccsrc/session/session_basic.cc
mindspore/ccsrc/session/session_basic.cc
+1
-1
未找到文件。
mindspore/ccsrc/device/ascend/ascend_kernel_runtime.cc
浏览文件 @
e4b404e8
...
...
@@ -239,22 +239,11 @@ DeviceAddressPtr AscendKernelRuntime::CreateDeviceAddress(void *device_ptr, size
return
std
::
make_shared
<
AscendDeviceAddress
>
(
device_ptr
,
device_size
,
format
,
type_id
);
}
void
AscendKernelRuntime
::
MallocOpMemory
(
const
DeviceAddressPtr
address
,
size_t
size
,
int
flag
)
{
MS_EXCEPTION_IF_NULL
(
MsContext
::
GetInstance
());
if
(
MsContext
::
GetInstance
()
->
enable_dynamic_mem_pool
())
{
auto
device_ptr
=
AscendMemoryAllocator
::
GetInstance
().
AllocTensorMem
(
size
);
MS_EXCEPTION_IF_NULL
(
device_ptr
);
address
->
ptr_
=
device_ptr
;
address
->
mem_dynamic_alloc_
=
true
;
return
;
}
if
(
flag
==
kStaticMem
)
{
address
->
ptr_
=
MallocStaticMem
(
size
,
false
);
}
else
if
(
flag
==
kDynamicMem
)
{
address
->
ptr_
=
MallocDynamicMem
(
size
,
false
);
}
else
{
MS_LOG
(
EXCEPTION
)
<<
"Unknown memory type!"
;
}
void
AscendKernelRuntime
::
MallocOpMemory
(
const
DeviceAddressPtr
address
,
size_t
size
,
int
)
{
auto
device_ptr
=
AscendMemoryAllocator
::
GetInstance
().
AllocTensorMem
(
size
);
MS_EXCEPTION_IF_NULL
(
device_ptr
);
address
->
ptr_
=
device_ptr
;
address
->
mem_dynamic_alloc_
=
true
;
}
bool
AscendKernelRuntime
::
GenTask
(
const
session
::
KernelGraph
*
graph
)
{
...
...
@@ -488,23 +477,18 @@ bool AscendKernelRuntime::DestroyHccl() {
bool
AscendKernelRuntime
::
MallocDeviceMemory
()
{
device_mem_size_
=
ASCEND_MEM_SIZE_BYTE
;
MS_EXCEPTION_IF_NULL
(
MsContext
::
GetInstance
());
if
(
MsContext
::
GetInstance
()
->
enable_dynamic_mem_pool
())
{
static_mem_offset_
=
FloatToSize
(
device_mem_size_
*
GRAPH_INIT_DAVINCI_MEM_RATIO
);
device_mem_pool_size_
=
FloatToSize
(
device_mem_size_
*
(
1
-
GRAPH_INIT_DAVINCI_MEM_RATIO
));
auto
ret
=
rtMalloc
(
reinterpret_cast
<
void
**>
(
&
device_mem_pool_base_
),
device_mem_pool_size_
,
RT_MEMORY_HBM
);
if
(
ret
!=
RT_ERROR_NONE
)
{
MS_EXCEPTION
(
DeviceProcessError
)
<<
"rtMalloc mem size["
<<
device_mem_pool_size_
<<
"] fail, ret["
<<
ret
<<
"]"
;
}
AscendMemoryAllocator
::
GetInstance
().
set_device_mem_pool_base
(
device_mem_pool_base_
);
AscendMemoryAllocator
::
GetInstance
().
set_device_mem_pool_size
(
device_mem_pool_size_
);
}
else
{
static_mem_offset_
=
device_mem_size_
;
static_mem_offset_
=
FloatToSize
(
device_mem_size_
*
GRAPH_INIT_ASCEND_MEM_RATIO
);
auto
ret
=
rtMalloc
(
reinterpret_cast
<
void
**>
(
&
device_mem_base_
),
static_mem_offset_
,
RT_MEMORY_HBM
);
if
(
ret
!=
RT_ERROR_NONE
)
{
MS_EXCEPTION
(
DeviceProcessError
)
<<
"rtMalloc mem size["
<<
static_mem_offset_
<<
"] fail, ret["
<<
ret
<<
"]"
;
}
auto
ret
=
rtMalloc
(
reinterpret_cast
<
void
**>
(
&
device_mem_base_
),
device_mem_size_
,
RT_MEMORY_HBM
);
device_mem_pool_size_
=
FloatToSize
(
device_mem_size_
*
(
1
-
GRAPH_INIT_ASCEND_MEM_RATIO
));
ret
=
rtMalloc
(
reinterpret_cast
<
void
**>
(
&
device_mem_pool_base_
),
device_mem_pool_size_
,
RT_MEMORY_HBM
);
if
(
ret
!=
RT_ERROR_NONE
)
{
MS_EXCEPTION
(
DeviceProcessError
)
<<
"rtMalloc mem size["
<<
device_mem_size_
<<
"] fail, ret["
<<
ret
<<
"]"
;
MS_EXCEPTION
(
DeviceProcessError
)
<<
"rtMalloc mem size["
<<
device_mem_
pool_
size_
<<
"] fail, ret["
<<
ret
<<
"]"
;
}
AscendMemoryAllocator
::
GetInstance
().
set_device_mem_pool_base
(
device_mem_pool_base_
);
AscendMemoryAllocator
::
GetInstance
().
set_device_mem_pool_size
(
device_mem_pool_size_
);
return
true
;
}
...
...
mindspore/ccsrc/device/ascend/ascend_memory_allocator.cc
浏览文件 @
e4b404e8
...
...
@@ -26,7 +26,7 @@ const uint64_t MEM_SIZE_BYTE = (MEM_SIZE << 30);
AscendMemoryAllocator
::
AscendMemoryAllocator
()
{
hasMalloc_
=
false
;
free_mem_size_
=
FloatToSize
(
MEM_SIZE_BYTE
*
(
1
-
GRAPH_INIT_
DAVINCI
_MEM_RATIO
));
free_mem_size_
=
FloatToSize
(
MEM_SIZE_BYTE
*
(
1
-
GRAPH_INIT_
ASCEND
_MEM_RATIO
));
total_mem_size_
=
free_mem_size_
;
}
...
...
mindspore/ccsrc/device/ascend/ascend_memory_allocator.h
浏览文件 @
e4b404e8
...
...
@@ -24,7 +24,7 @@ namespace mindspore {
namespace
device
{
namespace
ascend
{
// The fraction of total ascend memory used to compute the graph.
static
const
float
GRAPH_INIT_
DAVINCI
_MEM_RATIO
=
0.8
;
static
const
float
GRAPH_INIT_
ASCEND
_MEM_RATIO
=
0.8
;
class
AscendMemoryAllocator
:
public
DynamicMemPoolBestFit
{
public:
...
...
mindspore/ccsrc/session/session_basic.cc
浏览文件 @
e4b404e8
...
...
@@ -497,7 +497,7 @@ void SessionBasic::LoadInputData(const std::shared_ptr<KernelGraph> &kernel_grap
auto
device_address
=
AnfAlgo
::
GetMutableOutputAddr
(
pk_node
,
0
);
bool
need_sync
=
false
;
if
(
ms_context
->
enable_pynative_infer
())
{
if
(
tensor
->
device_address
().
get
()
==
nullptr
)
{
if
(
tensor
->
device_address
().
get
()
==
nullptr
||
tensor
->
device_address
()
!=
device_address
)
{
need_sync
=
true
;
}
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录