Menu

How Does Rust Code Run on a GPU? Tracing cuda-oxide and PTX
📰

How Does Rust Code Run on a GPU? Tracing cuda-oxide and PTX

DEV Community: rust·Masahiro Morino·14 days ago
#thm8NQA8
#devtorust#devto#dev#rust#cuda
Reading 0:00
15s threshold

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.

What is cuda-oxide?

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 .

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 .

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.