Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
da556ed6
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
da556ed6
编写于
6月 22, 2018
作者:
C
chengduo
提交者:
GitHub
6月 22, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enhance ParallelExecutor stable (#11637)
上级
073af623
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
84 deletion
+25
-84
paddle/fluid/framework/details/broadcast_op_handle.cc
paddle/fluid/framework/details/broadcast_op_handle.cc
+15
-42
paddle/fluid/framework/details/op_handle_base.cc
paddle/fluid/framework/details/op_handle_base.cc
+9
-27
paddle/fluid/framework/details/op_handle_base.h
paddle/fluid/framework/details/op_handle_base.h
+0
-4
paddle/fluid/framework/details/reduce_op_handle.cc
paddle/fluid/framework/details/reduce_op_handle.cc
+1
-3
paddle/fluid/platform/device_context.h
paddle/fluid/platform/device_context.h
+0
-8
未找到文件。
paddle/fluid/framework/details/broadcast_op_handle.cc
浏览文件 @
da556ed6
...
@@ -103,50 +103,23 @@ void BroadcastOpHandle::RunImpl() {
...
@@ -103,50 +103,23 @@ void BroadcastOpHandle::RunImpl() {
});
});
}
}
// FIXME(zcd): a temporary fix for some language model that has sparse
this
->
RunAndRecordEvent
([
&
]
{
// parameter.
{
bool
use_mutex
=
true
;
platform
::
NCCLGroupGuard
guard
;
if
(
in_var
->
IsType
<
paddle
::
framework
::
SelectedRows
>
())
{
for
(
auto
&
call
:
broadcast_calls
)
{
use_mutex
=
false
;
call
();
}
if
(
use_mutex
)
{
this
->
RunAndRecordEvent
([
&
]
{
{
platform
::
NCCLGroupGuard
guard
;
for
(
auto
&
call
:
broadcast_calls
)
{
call
();
}
}
if
(
!
out_handle
->
IsTheSameVar
(
*
in_var_handle
))
{
auto
out_var
=
var_scopes
.
at
(
in_var_handle
->
scope_idx_
)
->
FindVar
(
out_var_handles
[
0
]
->
name_
);
paddle
::
framework
::
TensorCopy
(
in_tensor
,
in_var_handle
->
place_
,
*
(
dev_ctxes_
.
at
(
in_var_handle
->
place_
)),
&
VariableVisitor
::
GetMutableTensor
(
out_var
));
}
});
}
else
{
this
->
RunAndRecordEventNoMutex
([
&
]
{
{
platform
::
NCCLGroupGuard
guard
;
for
(
auto
&
call
:
broadcast_calls
)
{
call
();
}
}
if
(
!
out_handle
->
IsTheSameVar
(
*
in_var_handle
))
{
auto
out_var
=
var_scopes
.
at
(
in_var_handle
->
scope_idx_
)
->
FindVar
(
out_var_handles
[
0
]
->
name_
);
paddle
::
framework
::
TensorCopy
(
in_tensor
,
in_var_handle
->
place_
,
*
(
dev_ctxes_
.
at
(
in_var_handle
->
place_
)),
&
VariableVisitor
::
GetMutableTensor
(
out_var
));
}
}
});
}
}
if
(
!
out_handle
->
IsTheSameVar
(
*
in_var_handle
))
{
auto
out_var
=
var_scopes
.
at
(
in_var_handle
->
scope_idx_
)
->
FindVar
(
out_var_handles
[
0
]
->
name_
);
paddle
::
framework
::
TensorCopy
(
in_tensor
,
in_var_handle
->
place_
,
*
(
dev_ctxes_
.
at
(
in_var_handle
->
place_
)),
&
VariableVisitor
::
GetMutableTensor
(
out_var
));
}
});
#else
#else
PADDLE_THROW
(
"CUDA is not enabled."
);
PADDLE_THROW
(
"CUDA is not enabled."
);
#endif
#endif
...
...
paddle/fluid/framework/details/op_handle_base.cc
浏览文件 @
da556ed6
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#include "paddle/fluid/framework/details/op_handle_base.h"
#include "paddle/fluid/framework/details/op_handle_base.h"
#include <map>
namespace
paddle
{
namespace
paddle
{
namespace
framework
{
namespace
framework
{
...
@@ -122,35 +122,17 @@ void OpHandleBase::RunAndRecordEvent(const std::function<void()> &callback) {
...
@@ -122,35 +122,17 @@ void OpHandleBase::RunAndRecordEvent(const std::function<void()> &callback) {
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
if
(
!
events_
.
empty
())
{
// Use event
if
(
!
events_
.
empty
())
{
// Use event
std
::
function
<
void
()
>
method
=
callback
;
std
::
function
<
void
()
>
method
=
callback
;
// NOTE(zcd): device context must be ordered here because RecordEvent
// will use a mutex to ensure the safe of multi-threads.
std
::
map
<
platform
::
DeviceContext
*
,
platform
::
Place
>
ordered_ctxes
;
for
(
auto
&
p
:
dev_ctxes_
)
{
for
(
auto
&
p
:
dev_ctxes_
)
{
method
=
[
method
,
p
,
this
]()
{
ordered_ctxes
.
emplace
(
p
.
second
,
p
.
first
);
static_cast
<
platform
::
CUDADeviceContext
*>
(
p
.
second
)
->
RecordEvent
(
events_
.
at
(
boost
::
get
<
platform
::
CUDAPlace
>
(
p
.
first
).
device
),
method
);
};
}
}
method
();
for
(
auto
&
p
:
ordered_ctxes
)
{
}
else
{
#endif
callback
();
#ifdef PADDLE_WITH_CUDA
}
#endif
}
void
OpHandleBase
::
RunAndRecordEventNoMutex
(
const
std
::
function
<
void
()
>
&
callback
)
{
#ifdef PADDLE_WITH_CUDA
if
(
!
events_
.
empty
())
{
// Use event
std
::
function
<
void
()
>
method
=
callback
;
for
(
auto
&
p
:
dev_ctxes_
)
{
method
=
[
method
,
p
,
this
]()
{
method
=
[
method
,
p
,
this
]()
{
static_cast
<
platform
::
CUDADeviceContext
*>
(
p
.
second
)
static_cast
<
platform
::
CUDADeviceContext
*>
(
p
.
first
)
->
RecordEvent
(
->
RecordEventNoMutex
(
events_
.
at
(
boost
::
get
<
platform
::
CUDAPlace
>
(
p
.
second
).
device
),
events_
.
at
(
boost
::
get
<
platform
::
CUDAPlace
>
(
p
.
first
).
device
),
method
);
method
);
};
};
}
}
method
();
method
();
...
...
paddle/fluid/framework/details/op_handle_base.h
浏览文件 @
da556ed6
...
@@ -85,10 +85,6 @@ class OpHandleBase {
...
@@ -85,10 +85,6 @@ class OpHandleBase {
protected:
protected:
void
RunAndRecordEvent
(
const
std
::
function
<
void
()
>
&
callback
);
void
RunAndRecordEvent
(
const
std
::
function
<
void
()
>
&
callback
);
// FIXME(zcd): A temporary fix for some language model that has sparse
// parameter.
void
RunAndRecordEventNoMutex
(
const
std
::
function
<
void
()
>
&
callback
);
void
RunAndRecordEvent
(
platform
::
Place
p
,
void
RunAndRecordEvent
(
platform
::
Place
p
,
const
std
::
function
<
void
()
>
&
callback
);
const
std
::
function
<
void
()
>
&
callback
);
...
...
paddle/fluid/framework/details/reduce_op_handle.cc
浏览文件 @
da556ed6
...
@@ -80,9 +80,7 @@ void ReduceOpHandle::RunImpl() {
...
@@ -80,9 +80,7 @@ void ReduceOpHandle::RunImpl() {
}
}
if
(
pre_in_var
->
IsType
<
framework
::
SelectedRows
>
())
{
if
(
pre_in_var
->
IsType
<
framework
::
SelectedRows
>
())
{
// FIXME(zcd): A temporary fix for some language model that has sparse
this
->
RunAndRecordEvent
([
&
]
{
// parameter.
this
->
RunAndRecordEventNoMutex
([
&
]
{
std
::
vector
<
const
SelectedRows
*>
in_selected_rows
=
std
::
vector
<
const
SelectedRows
*>
in_selected_rows
=
GetInputValues
<
SelectedRows
>
(
in_var_handles
,
var_scopes
);
GetInputValues
<
SelectedRows
>
(
in_var_handles
,
var_scopes
);
GatherSelectedRows
(
in_selected_rows
,
in_places
,
dev_ctxes_
,
t_out_p
,
GatherSelectedRows
(
in_selected_rows
,
in_places
,
dev_ctxes_
,
t_out_p
,
...
...
paddle/fluid/platform/device_context.h
浏览文件 @
da556ed6
...
@@ -106,14 +106,6 @@ class CUDADeviceContext : public DeviceContext {
...
@@ -106,14 +106,6 @@ class CUDADeviceContext : public DeviceContext {
PADDLE_ENFORCE
(
cudaEventRecord
(
ev
,
stream_
));
PADDLE_ENFORCE
(
cudaEventRecord
(
ev
,
stream_
));
}
}
// FIXME(zcd): A temporary fix for some language model that has sparse
// parameter.
template
<
typename
Callback
>
void
RecordEventNoMutex
(
cudaEvent_t
ev
,
Callback
callback
)
{
callback
();
PADDLE_ENFORCE
(
cudaEventRecord
(
ev
,
stream_
));
}
private:
private:
CUDAPlace
place_
;
CUDAPlace
place_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录