About CUDA kernels written in Rust #27
Gui-Yom
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey, it does not look like there are other places where we can discuss about CUDA so I'm posting here.
I just wanted to share https://github.com/Gui-Yom/turbo-metrics, a tool to accelerate video metrics computation using CUDA (I'm the author).
I've been closely following recent (not so recent anymore) by @kjetilkjeka on the nvptx backend in rustc (more specifically the LLVM bitcode linker) and it allows one to link different kernels crates into a single ptx file using no other tool than cargo. Linking LLVM bitcode is also really useful because we can use the CUDA libdevice for optimized math functions and link to any other compiled llvm bitcode as an escape hatch.
The project I'm sharing showcases that, it mixes host and device side crates in the same cargo workspace and uses build scripts to make host crates depend on device crates. Everything can be built in one cargo command. Device side crates are standard
#[no_std]
crates.Example device side kernel :
Example host side build script :
Host side ptx loading :
There are many downsides to this approach :
nvptx64-nvidia-cuda
target) requires the crates are checked out locally, no crates.io dependency is possible at the boundary. This also means no crates.io publishing.Anyway, I just wanted to share my approach at building full Rust CUDA applications, maybe some people here will be interested. Also, I would love to help in development in any way I can.
Beta Was this translation helpful? Give feedback.
All reactions