Skip to content

Commit 0732fcc

Browse files
committed
Fix hwloc topology traversal code unable to handle situation where L2 cache is common for the packages
Currently cores within package that share the same L2 cache are grouped together. The current logic behind this assumes that the L2 cache is always at deeper (or the same) level than the package itself. In case when L2 cache is common for all packages (and the packages are at deeper level than L2 cache) the whole of the further topology discovery fails to find any computational units resulting in following assertion: Assertion failure at kmp_affinity.cpp(715): nActiveThreads == __kmp_avail_proc. OMP: Error #13: Assertion failure at kmp_affinity.cpp(715). This patch adds a bit of a logic that prevents such situation from occurring. Differential Revision: https://reviews.llvm.org/D61796 llvm-svn: 360890
1 parent 73643b5 commit 0732fcc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

openmp/runtime/src/kmp_affinity.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ static int __kmp_hwloc_process_obj_core_pu(AddrUnsPair *addrPair,
530530
static int __kmp_hwloc_check_numa() {
531531
hwloc_topology_t &tp = __kmp_hwloc_topology;
532532
hwloc_obj_t hT, hC, hL, hN, hS; // hwloc objects (pointers to)
533-
int depth;
533+
int depth, l2cache_depth, package_depth;
534534

535535
// Get some PU
536536
hT = hwloc_get_obj_by_type(tp, HWLOC_OBJ_PU, 0);
@@ -548,8 +548,10 @@ static int __kmp_hwloc_check_numa() {
548548
}
549549
}
550550

551+
package_depth = hwloc_get_type_depth(tp, HWLOC_OBJ_PACKAGE);
552+
l2cache_depth = hwloc_get_cache_type_depth(tp, 2, HWLOC_OBJ_CACHE_UNIFIED);
551553
// check tile, get object by depth because of multiple caches possible
552-
depth = hwloc_get_cache_type_depth(tp, 2, HWLOC_OBJ_CACHE_UNIFIED);
554+
depth = (l2cache_depth < package_depth) ? package_depth : l2cache_depth;
553555
hL = hwloc_get_ancestor_obj_by_depth(tp, depth, hT);
554556
hC = NULL; // not used, but reset it here just in case
555557
if (hL != NULL &&

0 commit comments

Comments
 (0)