Similar crate than bindgen in philosophy.
It will help create automatic bindgen to cuda kernels source files and make them easier to use
directly from Rust.
PTX inclusion
Let’s say you have a file
src/cuda.cu
__global__ void cuda_hello(){
printf("Hello World from GPU!\n");
}
You can add bindgen_cuda as a build dependency:
cargo add --build bindgen_cuda
And then create this build.rs
fn main() {
let builder = bindgen_cuda::Builder::default();
let bindings = builder.build_ptx().unwrap();
bindings.write("src/lib.rs");
}
This will create a src file containing the following code:
Bindgen Cuda
Similar crate than bindgen in philosophy. It will help create automatic bindgen to cuda kernels source files and make them easier to use directly from Rust.
PTX inclusion
Let’s say you have a file
src/cuda.cu
You can add
bindgen_cuda
as a build dependency:And then create this
build.rs
This will create a src file containing the following code:
You can then use the PTX directly in your rust code with a library like cudarc.
Raw cuda calls
Alternatively you can build a static library that you can link against in build.rs in order to call cuda directly with the c code.
src/cuda.cu
Then write the
build.rs
:Which you can then interface through FFI in
src/lib.rs
: