LLNL / CHAI

Copy-hiding array abstraction to automatically migrate data between memory spaces
BSD 3-Clause "New" or "Revised" License
106 stars 22 forks source link

Linking against cuda_runtime rather than cudart #214

Open amklinv-nnl opened 2 years ago

amklinv-nnl commented 2 years ago

Hello,

I'm having trouble linking my project to chai because chai wants to pull in cuda_runtime:

set_target_properties(chai PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "/home/amklinv/spack/opt/spack/linux-ubuntu20.04-skylake/gcc-11.2.0/umpire-6.0.0-vzkbb7g3yc57jqa5xwodjynhrx5z2azs/include;${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "umpire;cuda_runtime;RAJA;cuda"
)

On my system with cuda 11.4.4, cuda_runtime.so is not available.

libOpenCL.so             libcudadevrt.a                libcuinj64.so                libcusparse.so             libnppicc.so.11           libnppim.so              libnppitc_static.a       libnvptxcompiler_static.a
libOpenCL.so.1           libcudart.so                  libcuinj64.so.11.4           libcusparse.so.11          libnppicc.so.11.4.0.110   libnppim.so.11           libnpps.so               libnvrtc-builtins.so
libOpenCL.so.1.0         libcudart.so.11.0             libcuinj64.so.11.4.120       libcusparse.so.11.6.0.120  libnppicc_static.a        libnppim.so.11.4.0.110   libnpps.so.11            libnvrtc-builtins.so.11.4
libOpenCL.so.1.0.0       libcudart.so.11.4.148         libculibos.a                 libcusparse_static.a       libnppidei.so             libnppim_static.a        libnpps.so.11.4.0.110    libnvrtc-builtins.so.11.4.152
libaccinj64.so           libcudart_static.a            libcurand.so                 liblapack_static.a         libnppidei.so.11          libnppist.so             libnpps_static.a         libnvrtc.so
libaccinj64.so.11.4      libcufft.so                   libcurand.so.10              libmetis_static.a          libnppidei.so.11.4.0.110  libnppist.so.11          libnvToolsExt.so         libnvrtc.so.11.2
libaccinj64.so.11.4.120  libcufft.so.10                libcurand.so.10.2.5.120      libnppc.so                 libnppidei_static.a       libnppist.so.11.4.0.110  libnvToolsExt.so.1       libnvrtc.so.11.4.152
libcublas.so             libcufft.so.10.5.2.100        libcurand_static.a           libnppc.so.11              libnppif.so               libnppist_static.a       libnvToolsExt.so.1.0.0   stubs
libcublas.so.11          libcufft_static.a             libcusolver.so               libnppc.so.11.4.0.110      libnppif.so.11            libnppisu.so             libnvblas.so
libcublas.so.11.6.5.2    libcufft_static_nocallback.a  libcusolver.so.11            libnppc_static.a           libnppif.so.11.4.0.110    libnppisu.so.11          libnvblas.so.11
libcublasLt.so           libcufftw.so                  libcusolver.so.11.2.0.120    libnppial.so               libnppif_static.a         libnppisu.so.11.4.0.110  libnvblas.so.11.6.5.2
libcublasLt.so.11        libcufftw.so.10               libcusolverMg.so             libnppial.so.11            libnppig.so               libnppisu_static.a       libnvjpeg.so
libcublasLt.so.11.6.5.2  libcufftw.so.10.5.2.100       libcusolverMg.so.11          libnppial.so.11.4.0.110    libnppig.so.11            libnppitc.so             libnvjpeg.so.11
libcublasLt_static.a     libcufftw_static.a            libcusolverMg.so.11.2.0.120  libnppial_static.a         libnppig.so.11.4.0.110    libnppitc.so.11          libnvjpeg.so.11.5.2.120
libcublas_static.a       libcufilt.a                   libcusolver_static.a         libnppicc.so               libnppig_static.a         libnppitc.so.11.4.0.110  libnvjpeg_static.a

I don't know if this is something that got renamed in cuda, but raja correctly links against cudart_static.

davidbeckingsale commented 2 years ago

Hey @amklinv-nnl - cuda_runtime is a special library provided by BLT (our CMake utilities). In RAJA we are "exporting" these special targets so they are found in downstream, but that logic is missing from CHAI. I will create a branch with a fix.

In the meantime, assuming you are compiling with nvcc, you could just strip that entry from the INTERFACE_LINK_LIBRARIES list and it should work, something like:

get_target_property(chai_inteface_libs chai INTERFACE_LINK_LIBRARIES)
list(REMOVE_ITEM chai_interface_libs cuda)
set_target_properties(chai PROPERTIES INTERFACE_LINK_LIBRARIES chai_interface_libs)