-
Notifications
You must be signed in to change notification settings - Fork 74
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
Use shared CUDA libraries by default #2348
Use shared CUDA libraries by default #2348
Conversation
This PR restores the behaviour we had before #2329, except that host-only applications like |
In particular, regular CUDA-based applications are still linked against both shared and static CUDA runtime libraries:
Would it make sense to use only the shared (or only the static) library ? |
For example adding diff --git a/cmake/alpakaCommon.cmake b/cmake/alpakaCommon.cmake
index 6661ad63031..28d7fd693bd 100644
--- a/cmake/alpakaCommon.cmake
+++ b/cmake/alpakaCommon.cmake
@@ -546,6 +546,7 @@ if(alpaka_ACC_GPU_CUDA_ENABLE)
if(CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "Static")
target_link_libraries(alpaka INTERFACE CUDA::cudart_static)
else()
+ set(CMAKE_CUDA_RUNTIME_LIBRARY "Shared")
target_link_libraries(alpaka INTERFACE CUDA::cudart)
endif()
to inform CMake that we want to link I really am not familiar with CMake best practices, so I will leave this PR as-is, unless told otherwise. |
should always be guarded and set only if not already set. It is allowed to set https://cmake.org/cmake/help/latest/variable/CMAKE_CUDA_RUNTIME_LIBRARY.html |
This PR is solving my issues I saw here |
Mhm, OK, but that will break all alpaka applications ? Actually, the alpaka build rules will actually ignore it and link |
All possible options are # Use the Shared CUDA Runtime library by default
if(NOT DEFINED CMAKE_CUDA_RUNTIME_LIBRARY)
set(CMAKE_CUDA_RUNTIME_LIBRARY "Shared")
endif()
# Link the CUDA Runtime library
if(CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "Static")
target_link_libraries(alpaka INTERFACE CUDA::cudart_static)
elseif(CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "Shared")
target_link_libraries(alpaka INTERFACE CUDA::cudart)
elseif(CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "None")
# Do not link any cudart library ?
else()
# ?
endif()
if(NOT alpaka_DISABLE_VENDOR_RNG)
# Use cuRAND random number generators
if(CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "Static")
target_link_libraries(alpaka INTERFACE CUDA::curand_static)
elseif(CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "Shared")
target_link_libraries(alpaka INTERFACE CUDA::curand)
else()
# ?
endif()
endif() But I don't know what we should do in the cases other than |
741495e
to
6362a76
Compare
OK, I think I covered all use cases in the latest update. |
6362a76
to
8308412
Compare
If
CMAKE_CUDA_RUNTIME_LIBRARY
is not set, set it to"Shared"
.This ensures that both the libraries implicitly linked by CMake match those explicitly linked by alpaka.
If
CMAKE_CUDA_RUNTIME_LIBRARY
is set toNone
, full CUDA applications are likely to build using thelibcudart.so
shared library, while host-only applications will likely fail to link.If
CMAKE_CUDA_RUNTIME_LIBRARY
is set toNone
, cuRAND is not supported.