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

Method set_runtime_thread_affinity

lite/src/mge/network_impl.cpp:186–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186void NetworkImplDft::set_runtime_thread_affinity(
187 const ThreadAffinityCallback& thread_affinity_callback) {
188 LITE_ASSERT(
189 m_user_config->device_type == LiteDeviceType::LITE_CPU,
190 "multi threads mode is only avaliable in CPU.");
191 mgb::CompNode::Locator loc;
192 m_load_config.comp_node_mapper(loc);
193 auto cn = mgb::CompNode::load(loc);
194 if (m_nr_threads > 1) {
195 mgb::CompNodeEnv::from_comp_node(cn).cpu_env().set_affinity(
196 thread_affinity_callback);
197 } else {
198 mgb::CompNodeEnv::from_comp_node(cn).cpu_env().dispatch(
199 [thread_affinity_callback](void) { thread_affinity_callback(0); });
200 }
201}
202
203void NetworkImplDft::set_device_id(int device_id) {
204 m_compnode_locator.device = device_id;

Callers

nothing calls this directly

Calls 3

loadFunction · 0.50
set_affinityMethod · 0.45
dispatchMethod · 0.45

Tested by

no test coverage detected