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

Method on_first_exec

src/core/impl/graph/cg_impl_seq.cpp:466–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464}
465
466void ComputingGraphImpl::ComputingSequence::on_first_exec() {
467 mgb_assert(m_first_exec);
468 for (auto i : *m_opr_seq) {
469 for (auto j : i->output())
470 m_used_comp_node.insert(j->comp_node());
471 }
472
473 // we maintain a recorder because events may depend on whether recorder
474 // is enabled
475 auto recorder = check_enable_comp_node_seq_recorder();
476 auto&& options = m_owner_graph->options();
477 //! The recorder in comp_node is thread_local, so the create thread should
478 //! the same as the execute thread, so set the Synchronize mode
479 if (m_enable_comp_node_seq_recorder) {
480 m_exec_env.set_async_level(0);
481 } else {
482 m_exec_env.set_async_level(options.async_exec_level);
483 }
484 if (options.async_exec_level) {
485 for (auto i : m_used_comp_node)
486 m_exec_env.add_comp_node(i);
487 }
488
489 // create events for timing and sync
490 for (auto&& i : m_used_comp_node) {
491 size_t flag = 0;
492 if (!m_have_parent_graph) {
493 flag = CompNode::Event::NEED_TIMER;
494 m_event_start[i] = i.create_event(flag);
495 }
496 m_event_end[i] = i.create_event(flag);
497 }
498 m_first_exec = false;
499}
500
501AsyncExecutable& ComputingGraphImpl::ComputingSequence::execute() {
502 check_not_finalized();

Callers

nothing calls this directly

Calls 6

set_async_levelMethod · 0.80
add_comp_nodeMethod · 0.80
outputMethod · 0.45
insertMethod · 0.45
comp_nodeMethod · 0.45
create_eventMethod · 0.45

Tested by

no test coverage detected