aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/kmp_affinity.cpp
diff options
context:
space:
mode:
authorPaul Osmialowski <pawel.osmialowski@arm.com>2019-05-16 13:16:24 +0000
committerPaul Osmialowski <pawel.osmialowski@arm.com>2019-05-16 13:16:24 +0000
commit9a0d0f00e90c4f9e0cbd281ab5578db28fafdfcb (patch)
tree4ff648af7974c22d23bcbe88361cbbb3a2e6abbd /runtime/src/kmp_affinity.cpp
parenta86b5e4738990f8eeaff4ad1ee05b1af42bc34ea (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@360890 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime/src/kmp_affinity.cpp')
-rw-r--r--runtime/src/kmp_affinity.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/src/kmp_affinity.cpp b/runtime/src/kmp_affinity.cpp
index 9d08254..b8d585c 100644
--- a/runtime/src/kmp_affinity.cpp
+++ b/runtime/src/kmp_affinity.cpp
@@ -530,7 +530,7 @@ static int __kmp_hwloc_process_obj_core_pu(AddrUnsPair *addrPair,
static int __kmp_hwloc_check_numa() {
hwloc_topology_t &tp = __kmp_hwloc_topology;
hwloc_obj_t hT, hC, hL, hN, hS; // hwloc objects (pointers to)
- int depth;
+ int depth, l2cache_depth, package_depth;
// Get some PU
hT = hwloc_get_obj_by_type(tp, HWLOC_OBJ_PU, 0);
@@ -548,8 +548,10 @@ static int __kmp_hwloc_check_numa() {
}
}
+ package_depth = hwloc_get_type_depth(tp, HWLOC_OBJ_PACKAGE);
+ l2cache_depth = hwloc_get_cache_type_depth(tp, 2, HWLOC_OBJ_CACHE_UNIFIED);
// check tile, get object by depth because of multiple caches possible
- depth = hwloc_get_cache_type_depth(tp, 2, HWLOC_OBJ_CACHE_UNIFIED);
+ depth = (l2cache_depth < package_depth) ? package_depth : l2cache_depth;
hL = hwloc_get_ancestor_obj_by_depth(tp, depth, hT);
hC = NULL; // not used, but reset it here just in case
if (hL != NULL &&