Skip to content
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

nvcc link failure with Kokkos_ENABLE_LIBDL and glibc >= 2.34 #4824

Closed
jedbrown opened this issue Feb 25, 2022 · 10 comments
Closed

nvcc link failure with Kokkos_ENABLE_LIBDL and glibc >= 2.34 #4824

jedbrown opened this issue Feb 25, 2022 · 10 comments
Assignees
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) InDevelop Enhancement, fix, etc. has been merged into the develop branch;

Comments

@jedbrown
Copy link

Glibc 2.34 integrated libdl into libc. The residual /usr/bin/libdl.a is a text stub

$ cat /usr/lib/libpthread.a
!<arch>

gcc knows how to handle this just fine, but nvcc does not.

$ echo 'int main() {return 0;}' > a.c
$ gcc a.c /usr/lib/libdl.a
$ nvcc a.c /usr/lib/libdl.a
nvlink fatal   : Could not open input file '/usr/lib/libdl.a'
$ nvcc a.c -ldl
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Fri_Dec_17_18:16:03_PST_2021
Cuda compilation tools, release 11.6, V11.6.55
Build cuda_11.6.r11.6/compiler.30794723_0

This results in link failures unless configuring -DKokkos_ENABLE_LIBDL=OFF. Maybe this can be turned off by default or use -ldl instead of CMake's explicit /usr/lib/libdl.a.

@ajpowelsnl ajpowelsnl added the Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) label Feb 28, 2022
@crtrott
Copy link
Member

crtrott commented Feb 28, 2022

Does this problem go away with the latest cmake? This looks like something cmake should fix, but we can try and add a workaround.

@crtrott
Copy link
Member

crtrott commented Feb 28, 2022

Note turning LIBDL off the way you did will disable the ability to load profiling tools during runtime.

@jedbrown
Copy link
Author

This has been with cmake-3.22.2

@jedbrown
Copy link
Author

We disabled LIBDL in PETSc as a workaround. I don't know if it's relevant to our users. https://gitlab.com/petsc/petsc/-/merge_requests/4890

@crtrott
Copy link
Member

crtrott commented Feb 28, 2022

Generally the profiling tools are pretty relevant for downstream users, because it allows proper kernel names like KokkosKernels::gemv etc. to show up inside of the major third party profiling tools like Tau, VTune and Nsight Compute. But its probably an acceptable short term solution for you. We are looking into how to put a workaround in on our side.

@jedbrown
Copy link
Author

Perhaps just check if the symbols are available despite not explicitly linking libdl?

@crtrott
Copy link
Member

crtrott commented Mar 14, 2022

What about this?

diff --git a/cmake/kokkos_tpls.cmake b/cmake/kokkos_tpls.cmake
index 54c6b520b..4dfdb6457 100644
--- a/cmake/kokkos_tpls.cmake
+++ b/cmake/kokkos_tpls.cmake
@@ -77,7 +77,7 @@ ENDIF()
 KOKKOS_IMPORT_TPL(HWLOC)
 KOKKOS_IMPORT_TPL(LIBNUMA)
 KOKKOS_IMPORT_TPL(LIBRT)
-KOKKOS_IMPORT_TPL(LIBDL)
+#KOKKOS_IMPORT_TPL(LIBDL)
 KOKKOS_IMPORT_TPL(MEMKIND)
 IF (NOT WIN32)
   KOKKOS_IMPORT_TPL(THREADS INTERFACE)
diff --git a/core/src/CMakeLists.txt b/core/src/CMakeLists.txt
index 88cca93f3..9c5db5994 100644
--- a/core/src/CMakeLists.txt
+++ b/core/src/CMakeLists.txt
@@ -95,7 +95,7 @@ IF (NOT KOKKOS_ENABLE_COMPILE_AS_CMAKE_LANGUAGE)
   KOKKOS_LINK_TPL(kokkoscore PUBLIC CUDA)
 ENDIF()
 KOKKOS_LINK_TPL(kokkoscore PUBLIC HPX)
-KOKKOS_LINK_TPL(kokkoscore PUBLIC LIBDL)
+#KOKKOS_LINK_TPL(kokkoscore PUBLIC LIBDL)
 KOKKOS_LINK_TPL(kokkoscore PUBLIC LIBRT)
 # On *nix-like systems (Linux, macOS) we need pthread for C++ std::thread
 IF (NOT WIN32)
@@ -111,6 +111,8 @@ IF (KOKKOS_ENABLE_IMPL_DESUL_ATOMICS AND
     (KOKKOS_ENABLE_OPENMPTARGET OR (CMAKE_CXX_COMPILER_ID STREQUAL XLClang)))
   target_link_libraries(kokkoscore PUBLIC atomic)
 ENDIF()
-
+IF (KOKKOS_ENABLE_LIBDL)
+  target_link_libraries(kokkoscore PUBLIC ${CMAKE_DL_LIBS})
+ENDIF()

 KOKKOS_LINK_TPL(kokkoscore PUBLIC LIBQUADMATH)

@dalg24
Copy link
Member

dalg24 commented Mar 14, 2022

The potential issue with your suggestion is we lose the find_path call to locate the dlfcn.h header and it is not added to the list of include directories.

@ajpowelsnl
Copy link
Contributor

Discuss and assign on Wednesday

@ajpowelsnl
Copy link
Contributor

Thx @masterleinad

@PhilMiller PhilMiller added the InDevelop Enhancement, fix, etc. has been merged into the develop branch; label Jul 12, 2022
petscbot pushed a commit to petsc/petsc that referenced this issue May 16, 2023
Profiling is useful for us and downstream users and we should turn it on when possible

The Kokkos issue raised at kokkos/kokkos#4824 seems to have been fixed
by kokkos/kokkos#5179

This MR effectively reverts !4890
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) InDevelop Enhancement, fix, etc. has been merged into the develop branch;
Projects
None yet
Development

No branches or pull requests

7 participants