[CMake] [New Module] FindCUDA

Luke Parkinson lparkinson at vpac.org
Thu Jan 7 01:40:12 EST 2010


Hello Everyone,

I apologise in advance if this is the wrong way to revive an old topic, but I wasn't sure how to reply to old threads in the mailing list and I'm new to this list.  I'm part of a team of developers looking at integrating CUDA into the Insight Toolkit (http://www.itk.org/). People subscribing to the mailing list over there might have heard from my colleague.  

Thanks to James Bigler and his FindCUDA.cmake module, we have been able to get CUDA and ITK to link into the executable, but we're having a similar problem to the previous post (included below just in case).  I have created several 'build environments' using this module with my own modifications that include the SDK (as an aside, can anyone point me in the direction of code that integrates C++ and CUDA without using cutil.h or cutil_inline.h?).  It works brilliantly with just the CUDA SDK, and the SDK plus our own C++ CUDA utility programs, but when we include the ITK in the configuration, building gives errors exactly like those above.  I've attached my modifications to the FindCUDA.cmake module (with a diff), and the 'CMakeLists.txt's we're using in the root and source directories.

We got the original FindCUDA.cmake from the svn repository, and based our code on the driver examples. When we add our own CUDA/C++ code (files omitted as code is still under development, permission is required), we get the same errors as mentioned previously, along the lines of 'warning: comparison between signed and unsigned integer expressions'.

Just including ITK (without our own code, using the provided driver code examples)
[Attached the corresponding files as ITKOnly_FindCUDA.cmake, ITKOnly_root_CMakeLists.txt, ITKOnly_src_CMakeLists.txt]
> make
[ 16%] Building NVCC (Device) object bin/./cuda_compile_generated_test_bin.cu.o
cc1: warning: command line option "-Wno-deprecated" is valid for C++/Java/ObjC++ but not for C
cc1: warning: command line option "-ftemplate-depth-50" is valid for C++/ObjC++ but not for C
cc1: warning: command line option "-Wno-deprecated" is valid for C++/Java/ObjC++ but not for C
cc1: warning: command line option "-ftemplate-depth-50" is valid for C++/ObjC++ but not for C
Scanning dependencies of target cuda_compile_example
[ 33%] Building CXX object bin/CMakeFiles/cuda_compile_example.dir/main.cc.o
Linking CXX executable cuda_compile_example
[ 33%] Built target cuda_compile_example
[ 50%] Building NVCC (Device) object bin/./test_lib_generated_test_lib.cu.o
cc1: warning: command line option "-Wno-deprecated" is valid for C++/Java/ObjC++ but not for C
cc1: warning: command line option "-ftemplate-depth-50" is valid for C++/ObjC++ but not for C
cc1: warning: command line option "-Wno-deprecated" is valid for C++/Java/ObjC++ but not for C
cc1: warning: command line option "-ftemplate-depth-50" is valid for C++/ObjC++ but not for C
Scanning dependencies of target test_lib
Linking CXX shared library libtest_lib.so
[ 50%] Built target test_lib
Scanning dependencies of target lib_example
[ 66%] Building CXX object bin/CMakeFiles/lib_example.dir/main_for_lib.cc.o
Linking CXX executable lib_example
[ 66%] Built target lib_example
[ 83%] Building NVCC (Device) object bin/./test_generated_test_bin.cu.o
cc1: warning: command line option "-Wno-deprecated" is valid for C++/Java/ObjC++ but not for C
cc1: warning: command line option "-ftemplate-depth-50" is valid for C++/ObjC++ but not for C
cc1: warning: command line option "-Wno-deprecated" is valid for C++/Java/ObjC++ but not for C
cc1: warning: command line option "-ftemplate-depth-50" is valid for C++/ObjC++ but not for C
Scanning dependencies of target test
[100%] Building CXX object bin/CMakeFiles/test.dir/main.cc.o
Linking CXX executable test
[100%] Built target test

Any ideas or suggestions would be helpful.  This isn't crippling (only warnings), but it is annoying and could lead to problems later on if it has to do with how the CMake module deals with C/C++ code.  I also noticed with that same module that there are a few variables that don't seem to do anything.  The example I found was CUDA_INCLUDE_DIRECTORIES (deprecated by CUDA_INCLUDE_DIRS?).  I assume that svn version was the most up-to-date, please let me know if I am wrong.

Thank you for your help,

Luke

PS - The old thread is included below for context:

On Wed, Aug 26, 2009 at 2:36 PM, Luis Ibanez<luis.ibanez at kitware.com> wrote:
> On Tue, Aug 25, 2009 at 2:11 PM, James Bigler<jamesbigler at gmail.com> wrote:
>> This is code that is up for inclusion into the CMake Modules directory.
>>
>> FindCUDA does several things.
>>
>> 1. It locates all the build tools found in the NVIDIA CUDA toolkit and SDK.
>> 2. It provides common options used to control CUDA code compilation.
>> 3. It provides macros that setup the build rules to convert CUDA files
>> into object code or PTX files.
>> 4. It maintains source level dependencies.  If you change a file that
>> a CUDA file depends on, it will cause the CUDA file to recompile.
>>
>> Attached is a zip file that contains the 4 files needed for use.  I
>> needed to use a zip file to get below the 40 KB email size limit that
>> didn't allow my email through before.
>>
>> 1. FindCUDA.cmake - main file that users call.
>> 2. run_nvcc.cmake - script used to invoke the nvcc compiler and other
>> helper commands (such as generating the dependency file).  This file
>> is configured per CUDA file, so that if you change one of the compiler
>> options it will regenerate this file causing the CUDA file to be
>> compiled anew.
>> 3. make2cmake - converts the makefile formatted dependency file that
>> nvcc produces into a form suitable for CMake to include.
>> 4. parse_cubin.cmake - parses a cubin file generated by nvcc and
>> reports statistics about the file.
>>
>> Comments are welcome.
>>
>> A version that also has some sample driver code (as well as the
>> FindCUDA scripts) can be found here:
>>
>> svn checkout https://code.sci.utah.edu/svn/findcuda/trunk FindCUDA
>>
>> Thanks,
>> James
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>
> -----------------------------------
>
>
> Hi James,
>
> This is great !
>
> Thanks for putting it together and sharing it.
>
>
> I tested it with the CUDA-ITK directory that we have
> in the NAMIC Sandbox at:
>
> http://svn.na-mic.org/NAMICSandBox/trunk/CUDA-ITK/
>
> where we used to have an older version of these files
> in the subdirectory:
>
> http://svn.na-mic.org/NAMICSandBox/trunk/CUDA-ITK/CMake/cuda/
>
>
> --
>
> Configuration with CMake went smoothly,
>
> but when building, I got the warning messages below
> (at the end of this email).
>
> It would seem that some of the ITK C++ compilation
> flags are passed to the cuda compiler, and get rejected.
>
>
> Does that ring any bell ?
>
>
>  Thanks
>
>
>     Luis
>
>
>
>
> -----------------------
> make
>
>
> ~/bin/NAMIC/NAMICSandbox/CUDA-ITK/Release
> [  7%] Building NVCC (Device) object Source/./Example1_generated_Example1.cu.o
> cc1: warning: command line option "-Wno-deprecated" is valid for
> C++/Java/ObjC++ but not for C
> cc1: warning: command line option "-ftemplate-depth-50" is valid for
> C++/ObjC++ but not for C
> cc1: warning: command line option "-Wno-deprecated" is valid for
> C++/Java/ObjC++ but not for C
> cc1: warning: command line option "-ftemplate-depth-50" is valid for
> C++/ObjC++ but not for C
> In file included from
> /home/ibanez/src/NAMIC/NAMICSandBox/CUDA-ITK/Source/Example1.cu:119:
> /tmp/tmpxft_00005d5f_00000000-1_Example1.cudafe1.stub.c: In function
> ‘void __device_stub__Z15VectorAddKernelPfS_S_i(float*, float*, float*,
> int)’:
> /tmp/tmpxft_00005d5f_00000000-1_Example1.cudafe1.stub.c:9: warning:
> dereferencing type-punned pointer will break strict-aliasing rules
> /home/ibanez/local/Cuda/cuda/bin/../include/common_functions.h: At global scope:
> /home/ibanez/local/Cuda/cuda/bin/../include/common_functions.h:70:
> warning: ‘clock_t __cuda_clock()’ defined but not used
> /home/ibanez/local/Cuda/cuda/bin/../include/common_functions.h:75:
> warning: ‘void* __cuda_memset(void*, int, size_t)’ defined but not
> used
> /home/ibanez/local/Cuda/cuda/bin/../include/common_functions.h:80:
> warning: ‘void* __cuda_memcpy(void*, const void*, size_t)’ defined but
> not used
> Scanning dependencies of target Example1
> Linking CXX executable ../bin/Example1

Yes, all C or CXX flags get passed to the host compiler by nvcc via
the -Xcompiler flag for more consistent builds.  By default
CUDA_HOST_COMPILATION_CPP is ON which should generate C++ host code
and invoke the C++ compiler instead of the C compiler.  I'm curious
why you are getting problems like this.

You can see the commands used to invoke nvcc by setting
CUDA_VERBOSE_BUILD to ON and running the build again.

James

-------------- next part --------------
A non-text attachment was scrubbed...
Name: CMakeFindCUDA_and_ITK.tar.gz
Type: application/x-gzip
Size: 1651 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100107/2d5bc46d/attachment-0001.bin>


More information about the CMake mailing list