-
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
Make alpaka follow CMAKE_CUDA_RUNTIME_LIBRARY
#2342
Make alpaka follow CMAKE_CUDA_RUNTIME_LIBRARY
#2342
Conversation
@@ -543,11 +543,19 @@ if(alpaka_ACC_GPU_CUDA_ENABLE) | |||
endif() | |||
|
|||
# Link the CUDA Runtime library | |||
target_link_libraries(alpaka INTERFACE CUDA::cudart) | |||
if(CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "Shared") |
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.
By default CMAKE_CUDA_RUNTIME_LIBRARY
is not set so this if condation will be false and we link static.
In all old alpaka versions we linked always against cudart
.
@fwyzard was the change of the default behavior of alpaka intended?
I run into issue with our main code PIConGPU when compiling with clang as CUDA compiler.
If there is no strong reason for the change of the default behaviour I could open a PR with
if(NOT DEFINED CMAKE_CUDA_RUNTIME_LIBRARY)
set(CMAKE_CUDA_RUNTIME_LIBRARY "Shared")
endif()
Which will keep the default behaviour of alpaka but still provide the possibility of static linking.
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.
No, I did not mean to change the default behaviour.
However, the default behaviour before #2329 and this PR was kind of tricky.
If configured with alpaka_DISABLE_VENDOR_RNG=OFF
:
- the CUDA binaries (e.g.
axpyTest
) are linked with bothlibcudart.so
and-lcudart_static
; I think the shared library took precedence because it was coming first on the command line; - the CUDA host-only applications (e.g.
hostOnlyAPITest
) were linked withlibcudart.so
.
If configured with alpaka_DISABLE_VENDOR_RNG=ON
:
- the CUDA binaries (e.g.
axpyTest
) were linked withcudart_static
; - the CUDA host-only applications (e.g.
hostOnlyAPITest
) were not linked with either library, and in fact failed to link.
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.
If the default should be "shared" (I agree it should be), let me invert the logic of the checks:
if(CMAKE_CUDA_RUNTIME_LIBRARY STREQUAL "Static")
target_link_libraries(alpaka INTERFACE CUDA::cudart_static)
else()
target_link_libraries(alpaka INTERFACE CUDA::cudart)
endif()
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.
See #2348 .
CMake uses
CMAKE_CUDA_RUNTIME_LIBRARY
to link the static (libcudart_static.a
) or shared (libcudart.so
) CUDA runtime library.This PR makes alpaka follow the same variable, and applies it also to the cuRAND libraries.