Rust GPU Kernels Built on LLVM Offload Come Close to Hand-Tuned CUDA and HIP

A University of Toronto and Lawrence Livermore paper shows safe Rust kernels compiled through rustc and LLVM's Offload layer running competitively with C++ baselines on Nvidia and AMD GPUs. The feature is still experimental.
Rust GPU Kernels Built on LLVM Offload Come Close to Hand-Tuned CUDA and HIP
Rust GPU Kernels Built on LLVM Offload Come Close to Hand-Tuned CUDA and HIP

Writing GPU kernels in Rust has usually meant giving something up: either a vendor-specific toolchain or a pile of unsafe raw pointers. A new paper argues that trade-off is shrinking. In “GPU Offload in Rust: Portable, Safe, and Fast,” posted to arXiv on Aug. 13, Manuel S. Drehwald, Marcelo Domínguez, Kevin Sala, Alán Aspuru-Guzik and Johannes Doerfert describe a multi-vendor GPU compilation framework built into rustc and LLVM that, they report, achieves “a solid kernel performance against native, hand-optimized CUDA and HIP C++ baselines.”

Phoronix summed up the benchmark results as generally competitive, “winning some, losing others,” with the authors pointing to code generation and IR differences as the places to close the remaining gaps.

How it works

The work rides on LLVM’s Offload project, the same runtime OpenMP uses to send Fortran and C++ code to GPUs. The authors lean on Rust’s ownership rules and strict aliasing guarantees to manage and optimize data transfers between host and device, and their front end lets most kernels avoid raw pointers.

The Rust compiler development guide describes the build as single-source but multi-pass. The host code is compiled first to record every kernel instance it needs in a manifest. Those kernels are then compiled for the device target, such as nvptx64 or amdgcn, with Intel planned. A final host pass emits calls into the offload runtime and links in the device artifacts. The runtime is told about type layouts, and the type system decides whether an argument only needs to go to the device or come back as well.

The test setup

The team measured the framework against RAJA-based versions of the same benchmarks from the RAJA Performance Suite, on an AMD MI250X, an Nvidia H100 and an Nvidia RTX A2000, using a Rust compiler built on LLVM 23.1.0-rc1. They looked at kernel times, memory transfer sizes, total runtime, fast-math effects and register usage.

One finding matters for anyone tempted by the easy path. The framework offers both an explicit interface, where developers control data movement, and a convenient one that moves data automatically on every kernel launch. When the same data is reused across kernels, the paper says, repeated automatic transfers can make the convenient version “over 400× slower” than the explicit one.

The feature is still experimental. The dev guide lists rough edges, including required cfg annotations on device code and kernels that recompile on every build, and says the team is prioritizing features and runtime performance for now. The long-term goal is a “rusty” GPU interface that is safe and convenient by default, with unsafe escape hatches for developers who need finer control.

Subscribe for Updates

DevNews Newsletter

The DevNews Email Newsletter is essential for software developers, web developers, programmers, and tech decision-makers. Perfect for professionals driving innovation and building the future of tech.

By signing up for our newsletter you agree to receive content related to ientry.com / webpronews.com and our affiliate partners. For additional information refer to our terms of service.

Notice an error?

Help us improve our content by reporting any issues you find.

Get the WebProNews newsletter delivered to your inbox

Get the free daily newsletter read by decision makers

Subscribe
Advertise with Us

Ready to get started?

Get our media kit

Advertise with Us