Skip to content

Commit

Permalink
Fix OpenMP linking for FBGEMM builds (#1751)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #1751

Reviewed By: shintaro-iwasaki

Differential Revision: D45580668

Pulled By: q10

fbshipit-source-id: 82c47daf0314fa48c7d97a3d9f99cf5c16141b05
  • Loading branch information
q10 authored and facebook-github-bot committed May 4, 2023
1 parent f50e294 commit 9f913e0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/fbgemm_gpu_build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ run_fbgemm_gpu_postbuild_checks () {
print_glibc_info "${library}"

echo "[CHECK] Listing out undefined symbols in the library: ${library}"
print_exec nm -gDCu "${library}" | sort
print_exec "nm -gDCu ${library} | sort"

echo "[CHECK] Listing out external shared libraries required by the library: ${library}"
print_exec ldd "${library}"
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/setup_env.bash
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ install_cxx_compiler () {

# https://stackoverflow.com/questions/4991707/how-to-find-my-current-compilers-standard-like-if-it-is-c90-etc
echo "[INFO] Printing the default version of the C standard used by the compiler ..."
print_exec conda run -n "${env_name}" cc -dM -E - | grep __STDC_VERSION__
print_exec "conda run -n ${env_name} cc -dM -E - | grep __STDC_VERSION__"

# https://stackoverflow.com/questions/2324658/how-to-determine-the-version-of-the-c-standard-used-by-the-compiler
echo "[INFO] Printing the default version of the C++ standard used by the compiler ..."
print_exec conda run -n "${env_name}" c++ -dM -E -x c++ - | grep __cplusplus
print_exec "conda run -n ${env_name} c++ -dM -E -x c++ - | grep __cplusplus"

echo "[INSTALL] Successfully installed C/C++ compilers"
}
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/utils_base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export PLATFORM_NAME_LC="$KERN_NAME_LC-$MACHINE_NAME_LC"
print_exec () {
echo "+ $*"
echo ""
if "$@"; then
if eval "$*"; then
local retcode=0
else
local retcode=$?
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/utils_system.bash
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ print_glibc_info () {

if [ -f "${library_path}" ]; then
echo "[CHECK] Listing out the GLIBC versions referenced by: ${library_path}"
objdump -TC "${library_path}" | grep GLIBC_ | sed 's/.*GLIBC_\([.0-9]*\).*/GLIBC_\1/g' | sort -Vu | cat
print_exec "objdump -TC ${library_path} | grep GLIBC_ | sed 's/.*GLIBC_\([.0-9]*\).*/GLIBC_\1/g' | sort -Vu | cat"
echo ""

echo "[CHECK] Listing out the GLIBCXX versions referenced by: ${library_path}"
objdump -TC "${library_path}" | grep GLIBCXX_ | sed 's/.*GLIBCXX_\([.0-9]*\).*/GLIBCXX_\1/g' | sort -Vu | cat
print_exec "objdump -TC ${library_path} | grep GLIBCXX_ | sed 's/.*GLIBCXX_\([.0-9]*\).*/GLIBCXX_\1/g' | sort -Vu | cat"
echo ""

else
Expand Down
22 changes: 17 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,19 +329,31 @@ target_include_directories(fbgemm BEFORE
PUBLIC $<BUILD_INTERFACE:${FBGEMM_SOURCE_DIR}>
PUBLIC $<BUILD_INTERFACE:${FBGEMM_SOURCE_DIR}/include>)

target_link_libraries(fbgemm $<BUILD_INTERFACE:asmjit>
target_link_libraries(fbgemm
$<BUILD_INTERFACE:asmjit>
$<BUILD_INTERFACE:cpuinfo>)
add_dependencies(fbgemm asmjit cpuinfo)
add_dependencies(fbgemm
asmjit
cpuinfo)

install(TARGETS fbgemm EXPORT fbgemmLibraryConfig
if(OpenMP_FOUND)
target_link_libraries(fbgemm OpenMP::OpenMP_CXX)
endif()

install(
TARGETS fbgemm
EXPORT fbgemmLibraryConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) #For windows

install(FILES ${FBGEMM_PUBLIC_HEADERS}
install(
FILES ${FBGEMM_PUBLIC_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/fbgemm")

install(EXPORT fbgemmLibraryConfig DESTINATION share/cmake/fbgemm
install(
EXPORT fbgemmLibraryConfig
DESTINATION share/cmake/fbgemm
FILE fbgemmLibraryConfig.cmake)

if(MSVC)
Expand Down
2 changes: 1 addition & 1 deletion fbgemm_gpu/docs/InstallationInstructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ reasons:
were not linked (see [1618](https://github.com/pytorch/FBGEMM/issues/1618) for example).
In the former case, this may be resolved by re-installing the relevant packages
or manually updating `LD_LIBRARY_PATH`.
and/or manually updating `LD_LIBRARY_PATH`.
In the latter case, this is a serious building and packaging issue that should
be reported to the FBGEMM developers.

0 comments on commit 9f913e0

Please sign in to comment.