未验证 提交 a9c8bdad 编写于 作者: Z Zeng Jinle 提交者: GitHub

refine pe codes, test=develop (#20479)

上级 76b32187
...@@ -188,26 +188,16 @@ bool OpHandleBase::NeedWait(VarHandleBase *in_var) { ...@@ -188,26 +188,16 @@ bool OpHandleBase::NeedWait(VarHandleBase *in_var) {
} }
void OpHandleBase::RunAndRecordEvent(const std::function<void()> &callback) { void OpHandleBase::RunAndRecordEvent(const std::function<void()> &callback) {
callback();
#ifdef PADDLE_WITH_CUDA #ifdef PADDLE_WITH_CUDA
if (!events_.empty()) { // Use event if (!events_.empty()) { // Use event
std::function<void()> method = callback;
for (auto &p : dev_ctxes_) { for (auto &p : dev_ctxes_) {
method = [method, p, this]() { auto dev_id = boost::get<platform::CUDAPlace>(p.first).device;
VLOG(10) << "cudadevicecontext:" auto *cuda_dev_ctx = static_cast<platform::CUDADeviceContext *>(p.second);
<< static_cast<platform::CUDADeviceContext *>(p.second) VLOG(10) << "cudadevicecontext:" << cuda_dev_ctx << ", dev_id:" << dev_id;
<< ", dev_id:" PADDLE_ENFORCE_CUDA_SUCCESS(
<< boost::get<platform::CUDAPlace>(p.first).device; cudaEventRecord(events_.at(dev_id), cuda_dev_ctx->stream()));
static_cast<platform::CUDADeviceContext *>(p.second)->RecordEvent(
events_.at(boost::get<platform::CUDAPlace>(p.first).device),
method);
};
} }
method();
} else {
#endif
callback();
#ifdef PADDLE_WITH_CUDA
} }
#endif #endif
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册