-
Notifications
You must be signed in to change notification settings - Fork 78
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
Revamp how libomp.so is found #853
base: develop
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,13 +116,41 @@ if( BUILD_CLIENTS_BENCHMARKS OR BUILD_CLIENTS_TESTS) | |
|
||
# if it fails to find OpenMP compile and link flags in strange configurations it can just use non-parallel reference computation | ||
# if there is no omp.h to find the client compilation will fail and this should be obvious, used to be REQUIRED | ||
find_package(OpenMP) | ||
if( CMAKE_CXX_COMPILER MATCHES ".*/hipcc$" ) | ||
find_package(OpenMP) | ||
if (TARGET OpenMP::OpenMP_CXX) | ||
set( LIBOMP_FOUND OpenMP::OpenMP_CXX) | ||
get_filename_component(LIBOMP_PATH "${OpenMP_omp_LIBRARY}" PATH) | ||
endif() | ||
# Support for using gnu as cmake compiler. | ||
else() | ||
# libomp.so may be in a target subdirectory directory. | ||
execute_process( | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
COMMAND bash -c "${HIP_CLANG_ROOT}/bin/amdclang --version | grep -oP '(?<=Target: ).+'" | ||
OUTPUT_VARIABLE LLVM_TARGET_TRIPLE | ||
) | ||
find_library(LIBOMP_FOUND omp PATHS ${HIP_CLANG_ROOT}/lib PATH_SUFFIXES ${LLVM_TARGET_TRIPLE} NO_DEFAULT_PATH) | ||
if (LIBOMP_FOUND) | ||
get_filename_component(LIBOMP_PATH "${LIBOMP_FOUND}" PATH) | ||
endif() | ||
endif() | ||
|
||
if (TARGET OpenMP::OpenMP_CXX) | ||
set( COMMON_LINK_LIBS "OpenMP::OpenMP_CXX") | ||
Comment on lines
-121
to
-122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So aren't we missing the OpenMP::OpenMP_CXX link request on CUDA backend? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, I can move |
||
if(LIBOMP_FOUND) | ||
# LIBOMP_FOUND will contain full path to libomp.so | ||
set( COMMON_LINK_LIBS ${LIBOMP_FOUND}) | ||
if(HIP_PLATFORM STREQUAL amd AND NOT WIN32) | ||
list( APPEND COMMON_LINK_LIBS "-Wl,-rpath=${LIBOMP_PATH}") | ||
endif() | ||
# If cmake cannot find the proper libomp.so, use HIP_CLANG_ROOT as fallback. | ||
else() | ||
if(HIP_PLATFORM STREQUAL amd) | ||
# Add library search paths. | ||
list( APPEND COMMON_LINK_LIBS "-L\"${HIP_CLANG_ROOT}/lib/${LLVM_TARGET_TRIPLE}\"") | ||
list( APPEND COMMON_LINK_LIBS "-L\"${HIP_CLANG_ROOT}/lib\"") | ||
if (NOT WIN32) | ||
if(NOT WIN32) | ||
# Add rpath. | ||
list( APPEND COMMON_LINK_LIBS "-Wl,-rpath=${HIP_CLANG_ROOT}/lib/${LLVM_TARGET_TRIPLE}") | ||
list( APPEND COMMON_LINK_LIBS "-Wl,-rpath=${HIP_CLANG_ROOT}/lib -lomp") | ||
else() | ||
list( APPEND COMMON_LINK_LIBS "libomp") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar question we shouldn't require NON hipcc to find_package(OpenMP) so can this just be moved two lines above? Sorry I meant other than hipcc we still want find_package to set cmake target etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the cmake compiler is hipcc
find_package
finds the correct ROCm libomp.so. Otherwise, gcc will get libgomp.so from gcc installation. I would rather get thelibomp
from ROCm to be consistent. With your current configuration cmake addslibgomp.so
with-L/rpaths -lomp
to the ROCm library. So I am fairly certain libgomp is ignored.