[CMake] Problems with the cuda_link_separable_compilation_objects defined in FindCUDA.cmake module

Omar Valerio omar.valerio at gmail.com
Thu Feb 26 12:35:02 EST 2015


Hello list,

Normally I use dynamic compilation in all my CMake projects with CUDA. But
recently I found about CUFFT callbacks, and in order to use them I'm forced
to compile against the cufft_static library, which means that I have to use
the separate compilation functionality.

After several attempts, I have got something that resembles close to what I
want to do. However the cuda_link_separable_compilation_objects macro is
somehow stripping the flags I want to pass to nvcc.

I uploaded a test code in Github (https://github.com/ovalerio/thrust_fft.git),
together with compilation instructions for the command line, and the CMake
project file that I'm unable to get right. Interesting bits look as follows:

set(CUDA_SEPARABLE_COMPILATION ON)
cuda_compile(DEVICE_OBJS ${PROJECT_SRC} OPTIONS ${NVCC_OPTS})
cuda_compute_separable_compilation_object_file_name(LINK_OBJS thrust_fft
${DEVICE_OBJS})
cuda_link_separable_compilation_objects(${LINK_OBJS} thrust_fft
${NVCC_OPTS} ${DEVICE_OBJS}
    ${CUDA_LIBRARIES}
    ${CUFFT_STATIC_LIBRARY}
    ${CULIBOS_LIBRARY}
)

This lines correspond to the following command line instructions:

 /usr/local/cuda-6.5/bin/nvcc src/thrust_fft_example.cu -dc -o
thrust_fft_example.o -ccbin /usr/bin/gcc-4.6 -m64 -Xcompiler
,\"-g\",\"-L/usr/local/cuda-6.5/lib64\",\"-g\"
-gencode=arch=compute_35,code=sm_35 -DNVCC -I/usr/local/cuda-6.5/include

/usr/local/cuda-6.5/bin/nvcc -gencode=arch=compute_35,code=sm_35 -m64
-ccbin "/usr/bin/gcc-4.6" -dlink thrust_fft_example.o -o
thrust_fft_example_link.o

/usr/bin/c++   -g -L/usr/local/cuda-6.5/lib64   thrust_fft_example.o
thrust_fft_example_link.o  -o thrust_fft -rdynamic
/usr/local/cuda-6.5/lib64/libcudart.so
/usr/local/cuda-6.5/lib64/libcufft_static.a
/usr/local/cuda-6.5/lib64/libculibos.a -Wl,-rpath,/usr/local/cuda-6.5/lib64:

>From close inspection what is happening is that the second line from above,
should instead read as:

/usr/local/cuda-6.5/bin/nvcc -gencode=arch=compute_35,code=sm_35 -m64
-ccbin "/usr/bin/gcc-4.6" -dlink thrust_fft_example.o -o
thrust_fft_example_link.o
*-lcudart -lcufft_static*
Notice that I have strip all the custom path names added by CMake.

Big kudos to the CMake community and the module maintainers that make our
work easier.

Hopefully some of you can help me to figure this out. =)

Cheers!
--
Omar V.M.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150226/a1b543b2/attachment.html>


More information about the CMake mailing list