[Openmp-commits] [openmp] 86fb2db - [OpenMP] libomp cleanup: check presence of hwloc objects CORE, PACKAGE
via Openmp-commits
openmp-commits at lists.llvm.org
Fri Jul 17 15:16:02 PDT 2020
Author: AndreyChurbanov
Date: 2020-07-18T01:15:37+03:00
New Revision: 86fb2db49b33aa4759d351b30ea1f6ebbe252c60
URL: https://github.com/llvm/llvm-project/commit/86fb2db49b33aa4759d351b30ea1f6ebbe252c60
DIFF: https://github.com/llvm/llvm-project/commit/86fb2db49b33aa4759d351b30ea1f6ebbe252c60.diff
LOG: [OpenMP] libomp cleanup: check presence of hwloc objects CORE, PACKAGE
hwloc documentation guarantees the only object that is always present
in the topology is PU. We can check the presence of other objects
in the topology, just in case.
Differential Revision: https://reviews.llvm.org/D84065
Added:
Modified:
openmp/runtime/src/kmp_affinity.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp
index 47e70477ced6..f78288710349 100644
--- a/openmp/runtime/src/kmp_affinity.cpp
+++ b/openmp/runtime/src/kmp_affinity.cpp
@@ -577,11 +577,17 @@ static int __kmp_affinity_create_hwloc_map(AddrUnsPair **address2os,
// Hack to try and infer the machine topology using only the data
// available from cpuid on the current thread, and __kmp_xproc.
KMP_ASSERT(__kmp_affinity_type == affinity_none);
-
- nCoresPerPkg = __kmp_hwloc_get_nobjs_under_obj(
- hwloc_get_obj_by_type(tp, HWLOC_OBJ_PACKAGE, 0), HWLOC_OBJ_CORE);
- __kmp_nThreadsPerCore = __kmp_hwloc_get_nobjs_under_obj(
- hwloc_get_obj_by_type(tp, HWLOC_OBJ_CORE, 0), HWLOC_OBJ_PU);
+ // hwloc only guarantees existance of PU object, so check PACKAGE and CORE
+ hwloc_obj_t o = hwloc_get_obj_by_type(tp, HWLOC_OBJ_PACKAGE, 0);
+ if (o != NULL)
+ nCoresPerPkg = __kmp_hwloc_get_nobjs_under_obj(o, HWLOC_OBJ_CORE);
+ else
+ nCoresPerPkg = 1; // no PACKAGE found
+ o = hwloc_get_obj_by_type(tp, HWLOC_OBJ_CORE, 0);
+ if (o != NULL)
+ __kmp_nThreadsPerCore = __kmp_hwloc_get_nobjs_under_obj(o, HWLOC_OBJ_PU);
+ else
+ __kmp_nThreadsPerCore = 1; // no CORE found
__kmp_ncores = __kmp_xproc / __kmp_nThreadsPerCore;
nPackages = (__kmp_xproc + nCoresPerPkg - 1) / nCoresPerPkg;
if (__kmp_affinity_verbose) {
More information about the Openmp-commits
mailing list