cuda-oxide: Rust-to-CUDA Compiler for Safe GPU Kernels
Try the cuda-oxide v0.1.0 alpha to compile Rust kernels to PTX and experiment with async GPU execution.
Install cuda-oxide v0.1.0 and run the provided vecadd example to validate the compiler.
Summary
cuda-oxide is an experimental Rust‑to‑CUDA compiler that compiles pure Rust code directly to PTX without DSLs or foreign bindings. The v0.1.0 release is an early alpha, expected to contain bugs and API breakage as the project evolves. The compiler uses #[cuda_module] and #[kernel] attributes to embed kernels into the host binary and provides async GPU programming via DeviceOperation graphs, allowing developers to await results with .await. Low‑level APIs such as load_kernel_module and cuda_launch! are also available for custom launch code.
The example code demonstrates a vecadd kernel that adds two f32 slices and writes the result to a DisjointSlice. It shows how to create a CudaContext, allocate DeviceBuffers, launch the kernel with LaunchConfig, and retrieve the result. Building and running the example requires installing prerequisites and running cargo oxide run vecadd.
This tool aims to bring Rust’s safety and ownership model to GPU programming, enabling developers to write GPU kernels in idiomatic Rust while maintaining safety guarantees.
Key changes
- cuda-oxide compiles pure Rust to PTX without DSLs or foreign bindings.
- v0.1.0 is an early alpha with expected bugs and API breakage.
- Uses #[cuda_module] and #[kernel] attributes to embed kernels into host binary.
- Provides async GPU programming via DeviceOperation graphs and await.
- Offers low‑level load_kernel_module and cuda_launch! APIs for custom launch code.
- Example shows a vecadd kernel compiled and executed with CudaContext and DeviceBuffer.