| 354 | } |
| 355 | |
| 356 | void AtlasCompNode::EventImpl::do_device_wait_by(Impl* cn_impl) { |
| 357 | if (cn_impl->dyn_typeinfo() == AtlasCompNodeImpl::typeinfo()) { |
| 358 | auto imp = static_cast<AtlasCompNodeImpl*>(cn_impl); |
| 359 | imp->m_env.atlas_env().activate(); |
| 360 | auto stream = imp->m_env.atlas_env().stream; |
| 361 | MGB_ATLAS_CHECK(aclrtStreamWaitEvent(stream, m_atlas_event)); |
| 362 | if (m_used_for_sync) { |
| 363 | MGB_ATLAS_CHECK(aclrtResetEvent( |
| 364 | m_atlas_event, m_comp_node_impl->m_env.atlas_env().stream)); |
| 365 | } |
| 366 | return; |
| 367 | } |
| 368 | if (cn_impl->env().property().type == DeviceType::CPU) { |
| 369 | auto waiter = [this]() { |
| 370 | m_comp_node_impl->m_env.atlas_env().activate(); |
| 371 | MGB_ATLAS_CHECK(aclrtSynchronizeEvent(m_atlas_event)); |
| 372 | if (m_used_for_sync) { |
| 373 | MGB_ATLAS_CHECK(aclrtResetEvent( |
| 374 | m_atlas_event, m_comp_node_impl->m_env.atlas_env().stream)); |
| 375 | } |
| 376 | }; |
| 377 | cn_impl->add_callback(std::move(waiter)); |
| 378 | return; |
| 379 | } |
| 380 | mgb_throw(MegBrainError, "unimplemented event device_wait_by config"); |
| 381 | } |
| 382 | |
| 383 | /* ===================== AtlasCompNode static methods ===================== */ |
| 384 |
nothing calls this directly
no test coverage detected