How Does Rust Code Run on a GPU? Tracing cuda-oxide and PTX A developer traced how a Rust vector-addition kernel compiled with NVIDIA's cuda-oxide toolchain becomes PTX, examining how thread indexing and array accesses are lowered for the GPU. The kernel uses thread::index_1d() and DisjointSlice to assign one output element per thread with bounds checks enabled, built against cuda-rust commit a0cc6cc0 on an RTX 5060 Ti targeting sm_120a. CUDA Rust is described as an early-stage research project with APIs still under development. I used cuda-oxide to run a vector addition kernel written in Rust on a GPU. Pass in two arrays and get back their element-wise sums. The calculation is simple, but I wanted to understand what form that Rust function takes before it reaches the GPU. Among the files generated during the build was some code called PTX. This time, I will read it to see how Rust's thread indexing and array accesses are represented. cuda-oxide is part of NVIDIA's CUDA Rust project. It provides a compiler and related tools for writing kernels for NVIDIA GPUs in Rust. See the official CUDA Rust repository https://github.com/NVIDIA/cuda-rust . The official book introduces it this way: cuda-oxide is a Rust-to-CUDA compiler that lets you write SIMT GPU kernels in safe ish , idiomatic Rust. Source: The cuda-oxide Book https://nvidia.github.io/cuda-rust/cuda-oxide/ . In other words, you can write the actual function that runs on the GPU in idiomatic Rust and compile it. SIMT stands for Single Instruction, Multiple Threads. It is the programming model used in this example, where many threads execute the same kernel. As of October 2026, CUDA Rust describes itself as an early-stage research project, with its features and APIs still under development. Here, I will focus on a small vector addition example and look at what the Rust code becomes. See the project status https://github.com/NVIDIA/cuda-rust . As someone who writes Rust, I find this a very intriguing project. Here is the kernel we will inspect. A kernel is a function that serves as an entry point for execution on the GPU. I verified the code and output on November 1, 2026, under the following conditions. I built the vecadd example from cuda-rust commit a0cc6cc0bc18722ec5cdfbea136c118a7c051977 in a source tree separate from my ongoing changes. | Item | Verified environment or setting | |---|---| | Host | Linux, x86-64 | | GPU | NVIDIA GeForce RTX 5060 Ti Compute Capability 12.0 | | NVIDIA driver | 595.99.02 | | Rust toolchain | nightly-2026-08-28, rustc 1.100.0-nightly e457a7b0d | | LLVM | Version 23.1.0 bundled with the toolchain | | Build | Release, target sm 120a, ordinary PTX output with bounds checks enabled | use cuda device::{DisjointSlice, cuda module, kernel, thread}; cuda module mod kernels { use super:: ; kernel pub fn vecadd a: & f32 , b: & f32 , mut c: DisjointSlice