This is an archive of the discontinued LLVM Phabricator instance.

[libomptarget] Check for library with CUDA Driver API
ClosedPublic

Authored by Hahnfeld on Jan 29 2018, 6:42 AM.

Details

Summary

That's what we really need to link the CUDA plugin against,
not the CUDA runtime API in CUDA_LIBRARIES! While the latter
comes with the CUDA SDK, the Driver API is installed with
the kernel driver and there is at most one per system. As
fallback we can use the stubs library distributed with the
CUDA SDK for linking.

Diff Detail

Repository
rL LLVM

Event Timeline

Hahnfeld created this revision.Jan 29 2018, 6:42 AM
tra added a comment.Jan 29 2018, 12:58 PM

You may want to consider linking with <CUDA>/lib64/stubs/libcuda.so. This way you don't really care whether nvidia's driver is installed on the system you compile on and all you need for compilation is a CUDA installation. At runtime dynamic linker will pick the real libcuda.so from wherever it's installed.

Hahnfeld planned changes to this revision.Jan 29 2018, 1:23 PM
In D42643#991096, @tra wrote:

You may want to consider linking with <CUDA>/lib64/stubs/libcuda.so. This way you don't really care whether nvidia's driver is installed on the system you compile on and all you need for compilation is a CUDA installation. At runtime dynamic linker will pick the real libcuda.so from wherever it's installed.

That's great, thanks for the pointer! I'll update this patch when I find time.

grokos added inline comments.Jan 29 2018, 2:25 PM
libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
118 ↗(On Diff #131793)

So LIBOMPTARGET_DEP_CUDA_LIBRARIES is no longer a dependency we care about. It can be removed.

124 ↗(On Diff #131793)

Remove.

Hahnfeld updated this revision to Diff 131957.Jan 30 2018, 6:07 AM
Hahnfeld marked 2 inline comments as done.
Hahnfeld edited the summary of this revision. (Show Details)

Use stubs library for linking and remove LIBOMPTARGET_DEP_CUDA_LIBRARIES.

grokos accepted this revision.Jan 30 2018, 6:38 AM

Looks good!

This revision is now accepted and ready to land.Jan 30 2018, 6:38 AM
This revision was automatically updated to reflect the committed changes.