GPU Offload in Rust: Portable, Safe, and Fast
High-performance GPU programming has traditionally forced a compromise between execution efficiency and memory safety. While Rust guarantees compile-time memory safety for host CPUs via its strict ownership model, applying these constraints to massively parallel GPU execution environments has previously mandated either vendor-locked Domain-Specific Languages (DSLs) or escaping to explicit unsafe…
High-performance GPU programming often involves a trade-off between execution efficiency and memory safety. Traditionally, Rust has provided compile-time memory safety for host CPUs using its strict ownership model. However, applying these constraints to massively parallel GPU execution environments required either vendor-specific Domain-Specific Languages (DSLs) or using explicit unsafe raw pointers.
This paper introduces a zero-overhead, multi-vendor GPU compilation framework integrated directly into the Rust compiler (rustc) and LLVM backends. By utilizing Rust's robust type system, ownership system, and strict aliasing guarantees (noalias), the framework efficiently manages and optimizes data transfers via LLVM's Offload infrastructure.
The authors address the challenge of cross-vendor ABI lowering mismatches between Host and Device targets and present a two-pass compilation pipeline capable of safely handling both manual and compiler-generated memory movements. Testing the framework on RAJAPerf shows that the rustc-based solution can produce competitive LLVM IR for GPU kernels, matching native, hand-optimized CUDA and HIP C++ baselines in kernel performance.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.