FindCUDA.cmake has moved
to: https://gforge.sci.utah.edu/gf/project/findcuda/scmsvn/
automatically redirecting to new web page.
FindCUDA.cmake
For more information about
CMake and Cuda:
SVN revision r813 contains
major changes to FindCUDA.cmake. Please see details below. To use the
old script, check out a prior revision from the svn server.
NOTE: The source code is hosted at a new svn server: https://code.sci.utah.edu/svn/findcuda/trunk
This web page contains information about an unofficial version
of the
FindCuda.cmake script I developed for my own CUDA programs. Many individuals have adopted the
script and suggested improvements, and tested the script on various
platforms and configurations. I appreciate all of the feedback and bug
fixes I have received since the initial release.
This webpage is updated infrequently- the svn log contains details
about bug fixes and updates.
Please send any comments or questions to my email. If you use the
NVIDIA forums, I might not see you question for some time.
Abe Stephens
Scientific Computing and Imaging Institute, University of Utah.
James Bigler
NVIDIA Research.
Features:
- Works on all CUDA platforms, tested with CUDA 2.1 beta. Will
generate visual studio project files.
- Parses an nvcc generated dependency file into CMake format.
Targets will be regenerated when dependencies change.
- Displays kernel register usage during compilation.
- Support for compilation to executable, shared libary, or PTX.
Source Code:
We released a major revision to the script in December 2008 at
approximately the same time as the CUDA 2.1 beta. There are many
differences in the new version of the script and it has been tested
extensively on Linux, Mac, and WinXP/Vista.
It is necessary to make several
changes to a project's CMakeLists.txt files in order to use the new
version.
List of partial changes:
- The capitalization of the script's filename is changed to
FindCUDA.cmake.
- The script may be included using FIND_PACKAGE (see example code).
- Switched to standard CMake package variable names: (e.g. CUDA_INCLUDE_DIRS instead of
CUDA_INCLUDE, CUDA_LIBRARIES
instead of CUDA_TARGET_LINK).
- Selection of Device or Release mode via boolean option CUDA_BUILD_EMULATION instead
of a text string.
- Paths added to INCLUDE_DIRECTORIES are passed to nvcc.
- Added option to host compilation mode boolean option.
- Added CUDA_COMPILE_PTX macro for compilation to .ptx.
- Added a macro generated target to clean all generated
dependencies.
- Locates the cuFFT and cuBLAS libraries as well (both in Device
and Emulation mode).
Major bug fixes:
- Fixed problem in Emulation mode which caused targets to
continuously be rebuilt.
- Fixed problems associated with incomplete compilation in visual
studio.
- Updated default paths for toolkit and SDK on several platforms.
Notes:
- Set the cmake cache variable CUDA_BUILD_CUBIN
to enable or disable generation and parsing of .cubin files for kernels
in Device mode. When enabled the number of registers, memory usage,
etc. will be printed to the console for each kernel. This information
can be entered in the Cuda
occupancy calculator.
- The script will output the actual command lines used in verbose
mode (e.g. make VERBOSE=1).
- The example code is intended to demonstrate cmake script usage
only, the .cu files don't do anything illustrative.
The code is available in an svn repository:
https://code.sci.utah.edu/svn/CMake-cuda
Either checkout the example project:
Usage:
The script will search for your cuda toolkit and SDK installation using
several standard paths and the
environment variables which are created by the installer.
The following example includes the script and shows how to add code in
an executable. The CUDA_ADD_* commands have the same
semantics as the standard ADD_* commands.
SET(CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/CMake/cuda" ${CMAKE_MODULE_PATH})
FIND_PACKAGE(CUDA)
CUDA_ADD_EXECUTABLE(test
test_bin.cu
main.cc
)
|
See additional usage in the example project.
License
For more information,
please see: http://software.sci.utah.edu
The MIT License
Copyright (c) 2007-2008
Scientific Computing and Imaging Institute, University of Utah
License for the specific language governing rights and
limitations under
Permission is hereby granted, free of charge, to any person
obtaining a
copy of this software and associated documentation files (the
"Software"),
to deal in the Software without restriction, including without
limitation
the rights to use, copy, modify, merge, publish, distribute,
sublicense,
and/or sell copies of the Software, and to permit persons to
whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER
DEALINGS IN THE SOFTWARE.