‹ BackHN Continuity

Thread

Nvidia announces native GPU programming in Rust

970 points · 404 comments · nonmaskable

  1. jacobgorm · · focus · HN ↗
    I strongly dislike CUDA. Once you have allowed that proprietary cr*p into your C++ codebase, it is very hard to get rid, and you end up with code that is either tied to a single vendor or an #ifdef hell, probably both.

    The best way to program GPUs is face up to the reality that they are not the same machine as the CPU, write your kernels in separate files, and launch them manually, like in Metal, OpenCL, and D3D12, etc. These days we even have DSLs like Triton that make kernel writing much more ergonomic than anything you would hope to achieve in Rust.

    1. fg137 · · focus · HN ↗
      > Once you have allowed that proprietary cr*p into your C++ codebase

      People have been doing that all the time for every kind of codebase. It's just part of the business. I don't see how it's worth having any emotions or opinions about it. Seems like you are wasting your energy.

      Are win32 APIs proprietary? So you decide to use them, use a wrapper/UI framework, or don't develop for Windows. Easy choice.

      Developing for embedded devices? So you read the manufacturers manual and implement based on the spec, use some sort of HAL if they are available, or you don't have a job. Even simpler.

      1. worik · · focus · HN ↗
        > Are win32 APIs proprietary?

        Yes. And crap. Not in my code bases.

        1. josephg · · focus · HN ↗
          If you're going to make apps in windows, you need to call their proprietary API somehow. Maybe you do it via a wrapper library, or via electron or something. But that's the same thing, just with more indirection.
          1. rfgplk · · focus · HN ↗
            > If you're going to make apps in windows, you need to call their proprietary API somehow. Maybe you do it via a wrapper library, or via electron or something. But that's the same thing, just with more indirection.

            Not even close to being true. You can invoke syscalls directly, just needs a bit of reverse engineering. I wrote a bare metal libc library, with (not a whole lot of) effort I'm fully able to interface with the kernel/open windows etc. Fully statically linked, no libc, no win32, compiled on Linux executed on Windows.

            The problem is this isn't really well documented _at all_, and I even ended up attempting to get in touch with the Windows kernel dev team to give me the actual internal syscalls/endpoints, but they refuse to cooperate. Which is why writing anything for Windows is entirely pointless.

            1. miki123211 · · focus · HN ↗
              The problem is much deeper than that. Most OSes' syscall ABIs are not stable and could change without warning. What is stable is the dynamically-loaded libraries, shipped as part of the system. Linux is the notable exception here; the Linux kernel project doesn't ship a libc, and Linus is very famously opposed to "breaking userspace."

              There's nothing that can stop you from using syscalls in theory, but if you want your app to be portable across different OS versions, past and future, you'd better not.

              Incidentally, syscalls would also break Wine. The way Wine works is basically by shipping their own versions of Windows DLLs, which express their operations in terms of Linux APIs. Because Windows programs don't rely on syscalls, and call all system functions via the system-provided libraries, the Wine loader can just link Wine's version and let the program work normally.

              1. bentcorner · · focus · HN ↗
                <a href="https:&#x2F;&#x2F;blog.hiler.eu&#x2F;win32-the-only-stable-abi&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.hiler.eu&#x2F;win32-the-only-stable-abi&#x2F;
              2. uncle_kostya · · focus · HN ↗
                If I recall correctly, the Golang team got bitten by this on MacOS.

                They initially implemented the Golang runtime directly on top of MacOS syscalls (not the C runtime library), just like they did on Linux - and then those syscalls changed, breaking Golang.

                They had to switch to the official stable API which on MacOS is the C runtime library, not syscalls.

            2. vhiremath4 · · focus · HN ↗
              &gt; This isn’t even close to being true. Here’s a thing I did that made things way more complicated than is worth it for 99% of developers when there is a proprietary solution made so I do not need to worry about these things. Because it is so hard to work around it, it is entirely pointless to develop for one of the most used operating systems in the world.

              Just being totally honest this is how I read this comment when I insert context that seems important to me. I respect having principles but at some point there needs to be more value in practicality over your codebase not being locked into a proprietary framework at all.

            3. josephg · · focus · HN ↗
              &gt; Not even close to being true. You can invoke syscalls directly,

              The windows syscall API is yet another proprietary windows API. Sure - you can call it without loading any DLLs. But you&#x27;re still calling into a proprietary windows API.

              If you really hate calling proprietary windows APIs that much, maybe stop developing for windows? Develop software for linux. Or make your own kernel, or whatever. But if you keep developing software for windows, stop fighting it. Unless you have a very good reason, your software should try to fit in on its host platform. It should behave well, and work like other windows software.

              It&#x27;s like travel. If you fly to France, try to fit in. Maybe learn a bit of French before you go. If you hate France, don&#x27;t go.

            4. drdexebtjl · · focus · HN ↗
              That’s insane. Windows does not have a stable syscall ABI. The way you’re supposed to interact with the kernel is through the userspace library. Of course the kernel team refuses to cooperate.

              Do you want to keep reverse engineering the syscall ABI for every Windows edition and update ever? Do you want to ask your users to disable Windows Update?

              Regardless, I don’t even understand how that’s relevant, since you’re still introducing a dependency on a proprietary ABI.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.