MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / do_device_wait_by

Method do_device_wait_by

src/core/impl/comp_node/atlas/comp_node.cpp:356–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354}
355
356void 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

Callers

nothing calls this directly

Calls 3

activateMethod · 0.45
propertyMethod · 0.45
add_callbackMethod · 0.45

Tested by

no test coverage detected