Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_77200941
mindspore
提交
2f2cae3c
M
mindspore
项目概览
2301_77200941
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2f2cae3c
编写于
6月 15, 2020
作者:
Z
ZPaC
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix code review warning in gpu_stream_assign.cc
上级
703c1b26
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
10 deletion
+19
-10
mindspore/ccsrc/device/gpu/gpu_stream_assign.cc
mindspore/ccsrc/device/gpu/gpu_stream_assign.cc
+14
-10
mindspore/ccsrc/utils/utils.h
mindspore/ccsrc/utils/utils.h
+5
-0
未找到文件。
mindspore/ccsrc/device/gpu/gpu_stream_assign.cc
浏览文件 @
2f2cae3c
...
...
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "device/gpu/gpu_stream_assign.h"
#include <set>
#include <string>
#include <memory>
...
...
@@ -21,7 +22,6 @@
#include "device/gpu/gpu_common.h"
#include "device/gpu/kernel_info_setter.h"
#include "device/gpu/gpu_device_manager.h"
#include "device/gpu/gpu_stream_assign.h"
namespace
mindspore
{
namespace
device
{
...
...
@@ -36,18 +36,19 @@ void AssignGpuStream(const std::shared_ptr<session::KernelGraph> &kernel_graph)
allreduce_kernels
.
emplace_back
(
kernel_node
);
}
else
{
DeviceStream
compute_stream
=
GPUDeviceManager
::
GetInstance
().
default_stream
();
AnfAlgo
::
SetNodeAttr
(
"stream_id"
,
MakeValue
(
reinterpret_cast
<
uintptr_t
>
(
compute_stream
)),
kernel_node
);
MS_EXCEPTION_IF_NULL
(
compute_stream
);
AnfAlgo
::
SetNodeAttr
(
kAttrStreamId
,
MakeValue
(
reinterpret_cast
<
uintptr_t
>
(
compute_stream
)),
kernel_node
);
}
}
if
(
allreduce_kernels
.
size
()
>
1
)
{
// Assign multiple streams only when there'
s Recv node for AllReduce
.
// Assign multiple streams only when there'
re multiple AllReduce nodes
.
std
::
vector
<
SendRecvPair
>
send_recv_pairs
;
if
(
FindAllReduceStreamSwitchPos
(
kernel_graph
,
&
send_recv_pairs
))
{
DeviceStream
comm_stream
=
nullptr
;
GPUDeviceManager
::
GetInstance
().
CreateStream
(
&
comm_stream
);
std
::
transform
(
allreduce_kernels
.
begin
(),
allreduce_kernels
.
end
(),
allreduce_kernels
.
begin
(),
[
&
](
CNodePtr
allreduce_kernel
)
{
AnfAlgo
::
SetNodeAttr
(
"stream_id"
,
MakeValue
(
reinterpret_cast
<
uintptr_t
>
(
comm_stream
)),
allreduce_kernel
);
AnfAlgo
::
SetNodeAttr
(
kAttrStreamId
,
MakeValue
(
reinterpret_cast
<
uintptr_t
>
(
comm_stream
)),
allreduce_kernel
);
return
allreduce_kernel
;
});
InsertStreamSwitchNode
(
kernel_graph
,
send_recv_pairs
);
...
...
@@ -161,25 +162,28 @@ bool GenSendRecvCNodesForAllReduce(const std::shared_ptr<session::KernelGraph> &
cudaEvent_t
event
=
nullptr
;
CHECK_CUDA_RET_WITH_EXCEPT
(
cudaEventCreate
(
&
event
,
cudaEventDisableTiming
),
"Creating cuda event failed."
);
AnfAlgo
::
SetNodeAttr
(
"record_event"
,
MakeValue
(
reinterpret_cast
<
uintptr_t
>
(
event
)),
*
send_node
);
AnfAlgo
::
SetNodeAttr
(
"wait_event"
,
MakeValue
(
reinterpret_cast
<
uintptr_t
>
(
event
)),
*
recv_node
);
AnfAlgo
::
SetNodeAttr
(
kAttrRecordEvent
,
MakeValue
(
reinterpret_cast
<
uintptr_t
>
(
event
)),
*
send_node
);
AnfAlgo
::
SetNodeAttr
(
kAttrWaitEvent
,
MakeValue
(
reinterpret_cast
<
uintptr_t
>
(
event
)),
*
recv_node
);
uintptr_t
send_stream
=
AnfAlgo
::
GetNodeAttr
<
uintptr_t
>
(
mock_send_node
,
"stream_id"
);
AnfAlgo
::
SetNodeAttr
(
"record_event_stream"
,
MakeValue
(
send_stream
),
*
send_node
);
uintptr_t
recv_stream
=
AnfAlgo
::
GetNodeAttr
<
uintptr_t
>
(
mock_recv_node
,
"stream_id"
);
AnfAlgo
::
SetNodeAttr
(
"wait_event_stream"
,
MakeValue
(
recv_stream
),
*
recv_node
);
uintptr_t
send_stream
=
AnfAlgo
::
GetNodeAttr
<
uintptr_t
>
(
mock_send_node
,
kAttrStreamId
);
AnfAlgo
::
SetNodeAttr
(
kAttrRecordEventStream
,
MakeValue
(
send_stream
),
*
send_node
);
uintptr_t
recv_stream
=
AnfAlgo
::
GetNodeAttr
<
uintptr_t
>
(
mock_recv_node
,
kAttrStreamId
);
AnfAlgo
::
SetNodeAttr
(
kAttrWaitEventStream
,
MakeValue
(
recv_stream
),
*
recv_node
);
return
true
;
}
CNodePtr
CreateStreamSwitchNode
(
const
std
::
shared_ptr
<
session
::
KernelGraph
>
&
kernel_graph
,
const
std
::
string
&
name
)
{
auto
op
=
std
::
make_shared
<
Primitive
>
(
name
);
MS_EXCEPTION_IF_NULL
(
op
);
auto
apply
=
std
::
make_shared
<
ValueNode
>
(
op
);
MS_EXCEPTION_IF_NULL
(
apply
);
std
::
vector
<
AnfNodePtr
>
input_list
=
{
apply
};
CNodePtr
node
=
kernel_graph
->
NewCNode
(
input_list
);
MS_EXCEPTION_IF_NULL
(
node
);
kernel
::
KernelBuildInfo
::
KernelBuildInfoBuilder
selected_kernel_builder
;
AnfAlgo
::
SetSelectKernelBuildInfo
(
selected_kernel_builder
.
Build
(),
node
.
get
());
auto
abstract_none
=
std
::
make_shared
<
abstract
::
AbstractNone
>
();
MS_EXCEPTION_IF_NULL
(
abstract_none
);
node
->
set_abstract
(
abstract_none
);
SetKernelInfo
(
node
);
return
node
;
...
...
mindspore/ccsrc/utils/utils.h
浏览文件 @
2f2cae3c
...
...
@@ -202,6 +202,11 @@ constexpr auto kAttrLabelSwitchList = "label_switch_list";
constexpr
auto
kAttrNewAxisMask
=
"new_axis_mask"
;
constexpr
auto
kAttrShrinkAxisMask
=
"shrink_axis_mask"
;
constexpr
auto
kAttrDatadumpOriginalNames
=
"_datadump_original_names"
;
constexpr
auto
kAttrStreamId
=
"stream_id"
;
constexpr
auto
kAttrRecordEvent
=
"record_event"
;
constexpr
auto
kAttrWaitEvent
=
"wait_event"
;
constexpr
auto
kAttrRecordEventStream
=
"record_event_stream"
;
constexpr
auto
kAttrWaitEventStream
=
"wait_event_stream"
;
// attr value
constexpr
auto
kValueTargetSwitch
=
"target_switch"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录