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

Method to_physical

src/core/impl/comp_node/comp_node.cpp:248–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248CompNode::Locator CompNode::Locator::to_physical() const {
249 mgb_assert(stream >= 0);
250 DeviceType type_physical;
251 int device_physical;
252 int stream_physical;
253
254 type_physical = resolve_device_type(type);
255 device_physical = device;
256 stream_physical = stream;
257
258 if ((MGB_HAVE_THREAD) ||
259 CompNode::contain_flag(type_physical, Flag::SUPPORT_NO_THREAD)) {
260#if MGB_THREAD_SAFE
261 MGB_LOCK_GUARD(g_device_map_mtx);
262#endif
263 auto&& cur_dmap = g_device_map[type_physical];
264 auto iter = cur_dmap.find(device);
265 if (iter != cur_dmap.end())
266 device_physical = iter->second;
267
268 if (device_physical == -1)
269 device_physical = 0;
270 } else {
271 // we map all logical locators to cpu0:1023 except cpu:default,
272 // when thread is disabled.
273 type_physical = DeviceType::CPU;
274 device_physical = DEVICE_CPU_DEFAULT;
275 stream_physical = 0;
276
277 if (device != DEVICE_CPU_DEFAULT) {
278 device_physical = 0;
279 stream_physical = 1023;
280 }
281 }
282 return {type_physical, device_physical, {stream_physical}};
283}
284
285std::string CompNode::Locator::to_string() const {
286 if (device == DEVICE_CPU_DEFAULT) {

Callers 4

init_commonFunction · 0.80
TESTFunction · 0.80
loadMethod · 0.80

Calls 3

resolve_device_typeFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by 1

TESTFunction · 0.64