13 comments

  • whateverboat12 hours ago
    &gt; 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.<p>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?
    • ux26647811 hours ago
      &gt; However, such an approach has previously not really worked for C++ with LLVM offload. Why would it work for Rust?<p>They&#x27;re very different languages, with different semantics. Without reading more than the synopsis of the paper, they&#x27;re 100% leveraging the substructural type system and will have a really tight requirement for you to use a certain kind of Rust code at the CPU&#x2F;GPU boundary.
      • erupti2 hours ago
        Unfortunately, the Rust description itself is inconsistent. It claims to be &quot;sufficiently fast by default&quot;, yet &quot;sufficiently fast&quot; depends entirely on the requirements of a specific user project. And then it also plans to provide options that do not guarantee memory safety when the default speed is insufficient. It is already common for Rust projects to sprinkle memory unsafe code around when performance is needed.
        • aw162110724 minutes ago
          &gt; It claims to be &quot;sufficiently fast by default&quot;, yet &quot;sufficiently fast&quot; depends entirely on the requirements of a specific user project.<p>I think that&#x27;s why the &quot;by default&quot; is there; the goal is to offer a safe&#x2F;convenient API that performs well enough that <i>by default</i> you don&#x27;t need to reach beyond said safe&#x2F;convenient API. And if you happen to be in a situation where the <i>default</i> performance of the safe&#x2F;convenient APIs is insufficient, more advanced APIs will be provided.<p>It&#x27;s a mirror of Rust&#x27;s general design goals, if anything.
    • aw162110712 hours ago
      &gt; However, such an approach has previously not really worked for C++ with LLVM offload. Why would it work for Rust?<p>I think that will depend on the exact reason(s) C++ with LLVM offload didn&#x27;t work out? If Rust differs from C++ in a way that addresses pain points&#x2F;failure modes&#x2F;etc. from the C++ attempt, for instance, then perhaps it isn&#x27;t unreasonable to think Rust could succeed where C++ didn&#x27;t (c.f., Mozilla&#x27;s pre-Rust attempts to parallelize Firefox&#x27;s CSS styling engine). Inversely, if Rust doesn&#x27;t do things differently in the right way perhaps one might expect the effort to also not work out. Or maybe the problems are entirely non-technical and things could work out in either language.
      • erupti2 hours ago
        &gt; I think that will depend on the exact reason(s) C++ with LLVM offload didn&#x27;t work out?<p>Are you making a claim or asking a question? ESL?
    • boxed11 hours ago
      Seems to work out well for Mojo, so I&#x27;d guess it&#x27;s more an issue with C++.
    • jcelerier10 hours ago
      &gt; However, such an approach has previously not really worked for C++ with LLVM offload<p>... isn&#x27;t Metal shading language just C++17 compiled with LLVM ? working on every Mac and iPhone in the world is not what I would call &quot;not really worked&quot;. Likewise, SYCL works just fine.
      • pjmlp2 hours ago
        It is C++14.
      • mathisfun12310 hours ago
        bruh lol this is so wrong and so confident i don&#x27;t want to even attempt to explain how wrong you are.<p>&gt; just C++17 compiled with LLVM<p>i invite you to attempt to compile&#x2F;run absolutely any C++17 codebase on your iphone&#x27;s GPU lol!
        • pjmlp2 hours ago
          For starters Metal Shading Language is based on C++14, so naturally any C++17 will fail.
        • nish__9 hours ago
          Wouldn&#x27;t any metal app have to be written in C++17?
        • jcelerier8 hours ago
          I mean &quot;any C++ codebase&quot; doesn&#x27;t make sense in general. I run C++23 code on ESP32, that doesn&#x27;t mean I&#x27;m gonna build KDE or chrome for it, and that doesn&#x27;t make it any less C++.
    • winningChild11 hours ago
      [dead]
    • winningChild11 hours ago
      [dead]
  • Driftbench58 minutes ago
    Ownership tracking should map well to GPU memory lifetimes. That&#x27;s one place Rust has a real edge over C++.
  • bicepjai11 hours ago
    I write all my code in Rust because I am a Rustacean. In many of my custom LLM inference engine projects, the biggest fight has always been bindings. I don’t want to maintain and write bindings; also, if I use an existing project that provides bindings, then I have to wait for the owner to update or fork it and then maintain it on top. It has been a big headache. Running Rust core on GPU sounds like something I will try from day one. Kudos to the team and will watch it closely.
  • YuechenLi12 hours ago
    So... why go through LLVM at all instead of having the MIR target PTX&#x2F;HIP C directly then?<p>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&#x2F;GLSL&#x2F;WGSL etc. As it stands, the way they use Rust here feels more like using it like TypeScript types&#x2F;interfaces than anything else.<p>Again, the size of most operations that should be done on the GPU is known ahead of time before compilation, so it&#x27;s very much possible to statically allocate memory at compile time instead of going through all this trouble to write what&#x27;s essentially a Rust shaped DSL for GPU compute.
    • minraws9 hours ago
      Because it&#x27;s convenient? Shader and vulkan semantics can be quite limiting and annoying to write.<p>Maybe it doesn&#x27;t matter in a post AI world but perhaps it will allow better abstractions.<p>No need to yuck someone else&#x27;s yum.
      • gmueckl2 hours ago
        The compute shader side of Vulkan is actually fairly smooth compared to graphics. It&#x27;s not really that different from low level CUDA or OpenCL. The Vulkan complexities overwhelmingly concern rasterization and raytracing.
    • sanxiyn11 hours ago
      People go through trouble to write Python-shaped DSL for GPU compute. We will go &quot;why o why?&quot;, but apparently such things are necessary to succeed in the market.
      • YuechenLi11 hours ago
        Well, I suppose fake Python is better than fake C++ at least.<p>But yeah, I think Python&#x27;s dominance in science&#x2F;ML will eventually pass, just as FORTRAN and Matlab did before.
  • Thomashuet14 hours ago
    That&#x27;s promising but did they publish any code? I can&#x27;t find anything in the abstract.
    • supermatt14 hours ago
      It is a part of the rust codebase:<p><a href="https:&#x2F;&#x2F;rustc-dev-guide.rust-lang.org&#x2F;offload&#x2F;internals.html" rel="nofollow">https:&#x2F;&#x2F;rustc-dev-guide.rust-lang.org&#x2F;offload&#x2F;internals.html</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;issues&#x2F;131513" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;issues&#x2F;131513</a>
  • boywitharupee12 hours ago
    is this mainly about making host binaries self-contained for heterogenous workloads?<p>also, seems like this is mostly targeted towards HPC audience?
  • maxchisto13 hours ago
    does anyone know Mojo well enough to comment how Rust + gpu-offload compares to it?
    • giancarlostoro13 hours ago
      Mojo is not fully open sourced yet, but it will eventually be, would be an interesting comparison though.
      • maxchisto13 hours ago
        Mojo&#x27;s OSS status doesn&#x27;t prevent us from evaluating its memory model, writing and benchmarking kernels in it, etc
        • giancarlostoro13 hours ago
          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.
  • jasonjmcghee14 hours ago
    &gt; the rust-gpu project has to emulate pointers[8], which we consider a blocking issue for most HPC benchmarks.<p>Why is it a blocking issue?<p>I feel like this is very aligned with the goals of rust-gpu.
    • minraws13 hours ago
      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&#x27;s hard for me to say anything I just use&#x2F;abuse CUDA pointers as well.
      • adgjlsfhk113 hours ago
        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)
  • Arsen-V47 minutes ago
    [flagged]
  • Alephinitesimal13 hours ago
    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&#x27;s safety model seems pretty compelling. I&#x27;m curious how portable the performance is in practice.
  • jheriko13 hours ago
    [dead]
  • iberator14 hours ago
    [flagged]
    • aabhay14 hours ago
      Genuinely curious what these constant changes are. In fact I don’t feel they’re moving fast enough to give us improvements to core.
      • frollogaston14 hours ago
        It was changing quickly in the earliest releases, about 10 years ago. Like one day I pulled our repo and there was new &quot;?&quot; syntax, but that was a feature I&#x27;d been wanting anyway.<p>Edit: Oh, async&#x2F;await was a bigger and more recent one, 2019. I&#x27;ve heard that this wasn&#x27;t an easy decision for them but was kinda needed.
        • aabhay14 hours ago
          A few years in between releases with a sane versioning system seems fine to me. If you don’t want new features don’t build with that new toolchain.<p>It’s not javascript where you need to support all possible browsers.
          • frollogaston14 hours ago
            Teams will disagree over what toolchain to use, and you will read others&#x27; code, so this doesn&#x27;t dodge the issue. Otherwise there&#x27;d be no complaint about C++. I don&#x27;t think Rust is bloated though, every feature has a very good reason.
            • speedstyle9 hours ago
              Would they disagree, new toolchains work great with old code? And even add 95% of the features to older editions, just not new keywords or inference defaults. I think in C++ people complain about the effort to migrate --std, rather than having to learn variants or concepts. It does add to the complexity of course, and it&#x27;s useful to agree on a consistent style, I just mean Rust doesn&#x27;t have the particular issues with everyone having to migrate in lockstep, or anyone needing to for new tools
              • frollogaston9 hours ago
                Same with C++, new standards will support old code. But they&#x27;ll disagree on using the new features in the new toolchains. Or more likely, they&#x27;ll just use the new features. So there&#x27;s no option of sticking to old feature sets, you will encounter the new ones at the very least.<p>Even with a style guide in C++... Google is known for having one. I was forced to change how I use basic strings multiple times there. They also changed the rules around refs (&amp;).
    • jjice14 hours ago
      That&#x27;s an opinion. One you&#x27;re very welcome to hold, but it&#x27;s not universal by any means. Lots of people enjoy rust.
  • rfgplk14 hours ago
    Fascinating how many people still overcomplicate offloading to GPUs.
    • MBCook13 hours ago
      How so? I don’t know anything about this area.
    • konradha12 hours ago
      What&#x27;s the easy way here? Linking CUDA into your Rust binary?
      • binsquare12 hours ago
        :)<p>This might be an relevant read: <a href="https:&#x2F;&#x2F;smolmachines.com&#x2F;engineering&#x2F;gpu-over-vsock">https:&#x2F;&#x2F;smolmachines.com&#x2F;engineering&#x2F;gpu-over-vsock</a>
        • dc44310 hours ago
          I just read this tool up and down but still can&#x27;t conceive of a use case.
        • foltik4 hours ago
          No, it’s not relevant to simple GPU offload, stop spam linking your slop blog.