Remix.run Logo
GPU Offload in Rust: Portable, Safe, and Fast(arxiv.org)
107 points by linggen 4 hours ago | 17 comments
YuechenLi 2 minutes ago | parent | next [-]

So... why go through LLVM at all instead of having the MIR target PTX/HIP C directly then?

If they really wanted a vendor neutral solution for Rust GPU, that already exists: you write the CPU side code, including buffering, allocation, concurrency, etc through Vulkan binding and consume the compute kernel in SPIR-V from HLSL/GLSL/WGSL etc. As it stands, the way they use Rust here feels more like using it like TypeScript types/interfaces than anything else.

Again, the size of most operations that should be done on the GPU is known ahead of time before compilation, so it's very much possible to statically allocate memory at compile time instead of going through all this trouble to write what's essentially a Rust shaped DSL for GPU compute.

whateverboat 28 minutes ago | parent | prev | next [-]

> This module is under active development. Once upstream, it should allow Rust developers to run Rust code on GPUs. We aim to develop a rusty GPU programming interface, which is safe, convenient and sufficiently fast by default. This includes automatic data movement to and from the GPU, in a efficient way. We will (later) also offer more advanced, possibly unsafe, interfaces which allow a higher degree of control.

I really appreciate the work and the effort that went into this. However, such an approach has previously not really worked for C++ with LLVM offload. Why would it work for Rust?

boywitharupee 35 minutes ago | parent | prev | next [-]

is this mainly about making host binaries self-contained for heterogenous workloads?

also, seems like this is mostly targeted towards HPC audience?

Thomashuet 2 hours ago | parent | prev | next [-]

That's promising but did they publish any code? I can't find anything in the abstract.

supermatt 2 hours ago | parent [-]

It is a part of the rust codebase:

https://rustc-dev-guide.rust-lang.org/offload/internals.html https://github.com/rust-lang/rust/issues/131513

maxchisto an hour ago | parent | prev | next [-]

does anyone know Mojo well enough to comment how Rust + gpu-offload compares to it?

giancarlostoro an hour ago | parent [-]

Mojo is not fully open sourced yet, but it will eventually be, would be an interesting comparison though.

maxchisto an hour ago | parent [-]

Mojo's OSS status doesn't prevent us from evaluating its memory model, writing and benchmarking kernels in it, etc

giancarlostoro an hour ago | parent [-]

Sure, and I realized after I posted the std lib is opened up, not sure how much of it will reveal the underlying Mojo specifics though.

jasonjmcghee 2 hours ago | parent | prev | next [-]

> the rust-gpu project has to emulate pointers[8], which we consider a blocking issue for most HPC benchmarks.

Why is it a blocking issue?

I feel like this is very aligned with the goals of rust-gpu.

minraws an hour ago | parent [-]

Pointers are sort of needed for high performance memory management for HPC targets for existing design patterns, maybe we can think of better solutions down the line but it's hard for me to say anything I just use/abuse CUDA pointers as well.

adgjlsfhk1 an hour ago | parent [-]

Julia has pretty good design heritage for how to deal with this sort of thing. you build the right abstractions and everything works (the main key is making sure the compiler elides bounds checks)

Alephinitesimal an hour ago | parent | prev | next [-]

The NVIDIA+AMD support is the part I find really interesting. I know OpenMP and SYCL can already target multiple GPU vendors, but doing this while keeping Rust's safety model seems pretty compelling. I'm curious how portable the performance is in practice.

rfgplk 2 hours ago | parent | prev [-]

Fascinating how many people still overcomplicate offloading to GPUs.

MBCook an hour ago | parent | next [-]

How so? I don’t know anything about this area.

konradha 22 minutes ago | parent | prev [-]

What's the easy way here? Linking CUDA into your Rust binary?

binsquare 17 minutes ago | parent [-]

:)

This might be an relevant read: https://smolmachines.com/engineering/gpu-over-vsock