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

refine pe codes, test=develop (#20479)

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