gpgpu: cuda | cuda_tests
Package Summary
This package pulls in NVIDIA's CUDA toolkit, drivers and SDK.
- Author: Ken Tossell/ktossell@umd.edu
- License: BSD
- Repository: umd-ros-pkg
- Source: git git://ram.umd.edu/ros/gpgpu.git
Contents
Tutorial
To add CUDA support to a package, you must edit its manifest:
<package> [...] <depend package="cuda"/> <depend package="roscpp"/> [...] </package>
Also modify its CMakeLists.txt file:
[...] rosbuild_init() # Run the CUDA-linking routines rosbuild_include(cuda cuda) [...] # Build the kernel and the kernel-aware host code CUDA_ADD_LIBRARY(kernel src/kernel.cu) # Build the ROS node and the matrix-adding code that's CUDA-unaware rosbuild_add_executable(program src/program.cpp) # Link the CUDA code and CUDA libraries into the ROS node target_link_libraries(program kernel shrutil_x86_64 cutil_x86_64)
kernel.cu contains the CUDA kernels and CUDA-aware (nvcc-compiled) host code. The plain C++ code in program.cpp calls code in kernel.cu which runs the kernel. The host-code entry point in kernel.cu should be declared in a header shared with program.cpp.
See cuda_tests for an example of a CUDA-aware ROS node.