Due to legacy issues in user code, we can't currently call InpectNumaNodes at module initialization time, because non-GPU programs still include this plugin via various methods, so instead, it has to be init-on-reference.
| 76 | // at module initialization time, because non-GPU programs still include this |
| 77 | // plugin via various methods, so instead, it has to be init-on-reference. |
| 78 | void CudaPlatform::InspectNumaNodes() { |
| 79 | // To get NUMA node information, we need to create all executors, so we can |
| 80 | // examine their device descriptions to see their bus assignments. |
| 81 | static std::once_flag once; |
| 82 | std::call_once(once, [&] { |
| 83 | StreamExecutorConfig config; |
| 84 | for (int i = 0; i < VisibleDeviceCount(); i++) { |
| 85 | config.ordinal = i; |
| 86 | StreamExecutor* exec = GetExecutor(config).ValueOrDie(); |
| 87 | if (i == 0) { |
| 88 | // NUMA nodes may not start at 0, so set the minimum node based on the |
| 89 | // first executor we see. |
| 90 | min_numa_node_ = exec->GetDeviceDescription().numa_node(); |
| 91 | limit_numa_node_ = min_numa_node_ + 1; |
| 92 | } else { |
| 93 | min_numa_node_ = |
| 94 | std::min(min_numa_node_, exec->GetDeviceDescription().numa_node()); |
| 95 | limit_numa_node_ = std::max( |
| 96 | limit_numa_node_, exec->GetDeviceDescription().numa_node() + 1); |
| 97 | } |
| 98 | } |
| 99 | }); |
| 100 | } |
| 101 | |
| 102 | int CudaPlatform::BusCount() { |
| 103 | InspectNumaNodes(); |
nothing calls this directly
no test coverage detected