| 367 | } |
| 368 | |
| 369 | void ComputingGraphImpl::ComputingSequence::do_wait(bool explicit_user_wait) { |
| 370 | if (m_wait_finished) |
| 371 | return; |
| 372 | |
| 373 | check_not_finalized(); |
| 374 | |
| 375 | for (auto i : m_owner_graph->m_subgraphs) { |
| 376 | if (i->m_current_comp_seq) { |
| 377 | auto seq = static_cast<ComputingSequence*>(i->m_current_comp_seq); |
| 378 | seq->do_wait(explicit_user_wait); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | bool sync_device = m_owner_graph->options().comp_seq_sync_device; |
| 383 | |
| 384 | if (sync_device) { |
| 385 | for (auto cn : m_used_comp_node) { |
| 386 | m_event_end.at(cn)->host_wait(); |
| 387 | } |
| 388 | } |
| 389 | m_wait_finished = true; |
| 390 | #if MGB_NEED_MEGDNN_ASYNC_ERROR |
| 391 | // FIXME: It CAN NOT work well if more than one ComputingSequnces has been |
| 392 | // executed on the same compnode and got AsyncError concurrently, because |
| 393 | // only the first async error on each comp_node would be recorded. |
| 394 | if (sync_device) { |
| 395 | for (auto&& cn : m_used_comp_node) { |
| 396 | auto error = cn.check_async_error(); |
| 397 | if (error) { |
| 398 | static_cast<const OperatorNodeExcExtraInfo*>(error->extra_info()) |
| 399 | ->opr() |
| 400 | ->owner_graph() |
| 401 | ->record_async_error(std::move(error)); |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | #endif |
| 406 | m_owner_graph->event().signal_inplace<event::CompSeqExecFinished>( |
| 407 | explicit_user_wait, true, m_owner_graph, this); |
| 408 | |
| 409 | if (m_async_exc) { |
| 410 | auto tmp_async_exc = std::move(m_async_exc); |
| 411 | mgb_throw_raw(*tmp_async_exc); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | void ComputingGraphImpl::ComputingSequence::cleanup() { |
| 416 | #if !__DEPLOY_ON_XP_SP2__ |
no test coverage detected