Code to make working with CUDA, via the CUDARC lib, easier.
This library compiles CUDA GPU kernels and CUDA host-side FFI (e.g. for cuFFT). It contains functions that run
in your application or library's build.rs file, in preparation for running CUDA kernels using FFI or Cudarc .
Primarily, it compiles of CUDA files (e.g. kernels and supporting code) to PTX during application build,
using the nvcc compiler that comes with CUDA. nvcc must be installed on your system, e.g. via the Cuda toolkit.
Note: You must set the environment var LD_LIBARARY_PATH (Linux) or PATH (Windows) to your CUDA bin
directory, e.g. C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin. You may also need the build tools
containing cl.exe or similar in the path, e.g.: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64
To use, create a build.rs file like this. It will automatically compile a PTX file. You should
package this PTX with your program, either as a file, or included in the binary.
//! We use this to automatically compile CUDA C++ code when building.
use ;
Or if your application has CUDA feature-gated, you may wish to use this pattern.
//! We use this to automatically compile CUDA C++ code when building.
use ;
If you are compilng host FFI code, e.g. to use cuFFT:
build_host;
Include this in Cargo.toml:
[]
# For compiling kernels to PTX.
= "0.1.8"