Skip to content

Commit 7c2c635

Browse files
committed
[OpenMP][OMPD] libompd must not link libomp
Fixes a regression introduced in 91ccd82. The code for libompd includes kmp.h for enum kmp_sched. The dependency to hwloc is not necessary. Avoid the dependency by skipping the definitions in kmp.h using types from hwloc.h.
1 parent 70e61f5 commit 7c2c635

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

openmp/libompd/src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ cmake_minimum_required(VERSION 3.20.0)
1313

1414
add_library (ompd SHARED TargetValue.cpp omp-debug.cpp omp-state.cpp omp-icv.cpp)
1515

16-
target_link_libraries(ompd omp) # ensure generated import library is created first
16+
# libompd must not link against libomp, there is no code dependency.
17+
add_dependencies(ompd omp) # ensure generated import library is created first
1718

1819
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
1920

openmp/libompd/src/omp-icv.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include "omp.h"
1919
#include "ompd-private.h"
2020
#include "TargetValue.h"
21+
#define OMPD_SKIP_HWLOC 1
2122
#include "kmp.h"
23+
#undef OMPD_SKIP_HWLOC
2224
#include <cstring>
2325

2426
/* The ICVs ompd-final-var and ompd-implicit-var below are for backward

openmp/runtime/src/kmp.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ class kmp_stats_list;
103103
#define KMP_USE_HIER_SCHED KMP_AFFINITY_SUPPORTED
104104
#endif
105105

106-
#if KMP_USE_HWLOC && KMP_AFFINITY_SUPPORTED
106+
// OMPD_SKIP_HWLOC used in libompd/omp-icv.cpp to avoid OMPD depending on hwloc
107+
#if KMP_USE_HWLOC && KMP_AFFINITY_SUPPORTED && !defined(OMPD_SKIP_HWLOC)
107108
#include "hwloc.h"
108109
#ifndef HWLOC_OBJ_NUMANODE
109110
#define HWLOC_OBJ_NUMANODE HWLOC_OBJ_NODE
@@ -689,7 +690,7 @@ typedef BOOL (*kmp_SetThreadGroupAffinity_t)(HANDLE, const GROUP_AFFINITY *,
689690
extern kmp_SetThreadGroupAffinity_t __kmp_SetThreadGroupAffinity;
690691
#endif /* KMP_OS_WINDOWS */
691692

692-
#if KMP_USE_HWLOC
693+
#if KMP_USE_HWLOC && !defined(OMPD_SKIP_HWLOC)
693694
extern hwloc_topology_t __kmp_hwloc_topology;
694695
extern int __kmp_hwloc_error;
695696
#endif

0 commit comments

Comments
 (0)