[Openmp-commits] [openmp] Fix: Add missing preprocessor guard for hwloc types on macOS (PR #156708)
Burhan Söğüt via Openmp-commits
openmp-commits at lists.llvm.org
Wed Sep 3 09:21:08 PDT 2025
https://github.com/bursow created https://github.com/llvm/llvm-project/pull/156708
Fix #156679
The issue stems from the __kmp_is_hwloc_membind_supported function in openmp/runtime/src/kmp_alloc.cpp. The function uses a type from the hwloc library (hwloc_membind_policy_t), but it was only guarded by #if KMP_USE_HWLOC. On macOS, KMP_AFFINITY_SUPPORTED is not defined, so the necessary header file (hwloc.h) isn't included, leading to an unknown type error.
The fix is to update the preprocessor guard to #if KMP_USE_HWLOC && KMP_AFFINITY_SUPPORTED, ensuring the function is only compiled when the hwloc type is available.
>From c9d9557d59cec1c053df5ee10190fe1436291dfe Mon Sep 17 00:00:00 2001
From: Burhan <segabur at hotmail.com>
Date: Wed, 3 Sep 2025 19:10:12 +0300
Subject: [PATCH] Fix: Add missing preprocessor guard for hwloc types on macOS
---
openmp/runtime/src/kmp_alloc.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/openmp/runtime/src/kmp_alloc.cpp b/openmp/runtime/src/kmp_alloc.cpp
index 051f88c5a0996..b608d1985878b 100644
--- a/openmp/runtime/src/kmp_alloc.cpp
+++ b/openmp/runtime/src/kmp_alloc.cpp
@@ -1545,7 +1545,7 @@ void __kmp_fini_memkind() {
#endif
}
-#if KMP_USE_HWLOC
+#if KMP_USE_HWLOC && KMP_AFFINITY_SUPPORTED
static bool __kmp_is_hwloc_membind_supported(hwloc_membind_policy_t policy) {
#if HWLOC_API_VERSION >= 0x00020300
const hwloc_topology_support *support;
@@ -1563,6 +1563,7 @@ static bool __kmp_is_hwloc_membind_supported(hwloc_membind_policy_t policy) {
return false;
#endif
}
+#endif
void *__kmp_hwloc_alloc_membind(hwloc_memattr_id_e attr, size_t size,
hwloc_membind_policy_t policy) {
More information about the Openmp-commits
mailing list