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

Method execute

src/jit/impl/halide/halide_executable.cpp:79–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void HalideExecutable::execute(JITExecutor* fusion_opr) {
80 // load func_ptr for current comp node
81 auto comp_node = fusion_opr->comp_node();
82 std::atomic<FunctionHandle*>* func_ptr_ref;
83 {
84 MGB_LOCK_GUARD(m_mtx);
85 func_ptr_ref = &m_cn2func[comp_node];
86 }
87 auto func_ptr = func_ptr_ref->load();
88 if (!func_ptr) {
89 std::pair<std::mutex, FunctionHandle>* func_maker;
90 {
91 MGB_LOCK_GUARD(m_mtx);
92 func_maker = &m_feature_set2func[m_target_trait->features(comp_node)];
93 }
94
95 // compile the function
96 MGB_LOCK_GUARD(func_maker->first);
97 if (!(func_ptr = func_ptr_ref->load())) {
98 if (!func_maker->second.execute) {
99 func_maker->second = compile_and_load(comp_node);
100 mgb_assert(func_maker->second.execute);
101 }
102 func_ptr = &func_maker->second;
103 func_ptr_ref->store(func_ptr);
104 }
105 }
106
107 void* user_context = nullptr;
108 if (func_ptr->uctx_map) {
109 MGB_LOCK_GUARD(func_ptr->uctx_map->mtx);
110 auto&& ptr = func_ptr->uctx_map->cn2uctx[comp_node];
111 if (!ptr) {
112 ptr = m_target_trait->get_user_context(comp_node);
113 }
114 user_context = ptr;
115 }
116
117 invoke(user_context, *func_ptr, fusion_opr->input(), fusion_opr->output(0));
118}
119
120std::vector<Halide::Argument> HalideExecutable::halide_inputs() const {
121 std::vector<Argument> args;

Callers 1

invokeMethod · 0.45

Calls 8

invokeFunction · 0.85
featuresMethod · 0.80
get_user_contextMethod · 0.80
comp_nodeMethod · 0.45
loadMethod · 0.45
storeMethod · 0.45
inputMethod · 0.45
outputMethod · 0.45

Tested by

no test coverage detected