Skip to content

[OpenMP][OMPD] libompd must not link libomp #83119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion openmp/libompd/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ cmake_minimum_required(VERSION 3.20.0)

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

target_link_libraries(ompd omp) # ensure generated import library is created first
# libompd must not link against libomp, there is no code dependency.
add_dependencies(ompd omp) # ensure generated import library is created first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put a comment here to say, OMPD should never directly link to omp?


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

Expand Down
2 changes: 2 additions & 0 deletions openmp/libompd/src/omp-icv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include "omp.h"
#include "ompd-private.h"
#include "TargetValue.h"
#define OMPD_SKIP_HWLOC 1
#include "kmp.h"
#undef OMPD_SKIP_HWLOC
#include <cstring>

/* The ICVs ompd-final-var and ompd-implicit-var below are for backward
Expand Down
5 changes: 3 additions & 2 deletions openmp/runtime/src/kmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class kmp_stats_list;
#define KMP_USE_HIER_SCHED KMP_AFFINITY_SUPPORTED
#endif

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

#if KMP_USE_HWLOC
#if KMP_USE_HWLOC && !defined(OMPD_SKIP_HWLOC)
extern hwloc_topology_t __kmp_hwloc_topology;
extern int __kmp_hwloc_error;
#endif
Expand Down