← Back to context

Comment by jacobgorm

12 hours ago

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.

> 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,

Yes, I also prefer doing it that way, but in Cuda with the driver API. Allows you to handle kernels like shaders, including editing and hot-reloading at runtime.

The reason I'm sticking with CUDA is because it's by far the most convenient API to use, without nonsense like 50-liners to alloc memory or the need to manage descriptors, bindings, queue families, etc.

> I strongly dislike CUDA. Once you have allowed that proprietary cr*p

Genuine question...why not just type "crap"? It's not even that much of a curse, but I've never really understood the point of self-censorship. If you don't want to curse then you could just use a non-curse word.

  • I thought that cp*p is some kind of ugly cuda pointer declaration :D And being non-standard C++ syntax it wouldn’t compile.

  • Because I know it is not technically crap, a lot of competent people worked on it, most with good intentions. I suppose it is better described as a cleverly designed Trojan horse than can infect your software and make that software become crap, in the sense that it becomes harder to maintain, increases code duplication, messes with your build system, ties your build system to platforms that have their toolchain binaries available, etc., etc., without bringing any long-term benefits over learning things the hard way.

  • * is used to give emphasis and show that they are using the word as curse word rather just calling it bad

    • It doesn't read as emphasis to me. It reads like the person is trying hard not to curse, and they think "crap" is a curse word. It's a little bit adorable, like I'm reading a comment from an obedient child.

      19 replies →

    • I think a string of non-alphanumeric characters would work much better here, like "Once you have allowed that proprietary @#$&% into your C++ codebase”

      Leaves more to the imagination.

    • In any context I've seen, asterisks are for wrapping formatting and said formatting it to add emphasis. So being in the habit of typing `emphasised phrase`, for italics - regardless of whether the platform parses markdown/similar formatting, e.g. SMS.

      To have an unclosed asterisk replacing characters in a word? I've only ever seen that as a way to bypass censorship. This spans communications from people currently in their 40s down to 20.

    • i do this to put emphasis, i always type "h*ck".

      (although it is a half-joke since it's definitely not a curse word imo)

  • Platform may retroactively make up and enforce rules that makes your content violate terms (and remove them)

    See YouTube.

    • I certainly dislike how everyone on YouTube is saying “SA” and “unalive” and “corn”.

      It’s one thing if it’s some funny commentary channel avoiding those words, but what bothers me is the true crime YouTubers. In the subject of true crime, rape and murder are just things that are probably going to come up, and when they refuse to use the appropriate language, it comes off as infantilizing, which is weird considering that my actual YouTube account is over 18, let alone the viewer using it.

      Advertisers ruin everything, I guess.

      6 replies →

  • IMO cr*p and crap are both valid but separate swear words. People have a wide option to choose from when they want to swear, and people like variety (much much more than LLMs do). People also tend to influence each other with their usages: cr*p is popular because it is popular.

    Otherwise cr*p is just as good as crap, shit, horseshit, poopoo or such.

    edit: * replaced with \* as HN interprets asterisks as formatting for emphasis. Thx latexr for informing me

    • To use a literal asterisk on HN, do ** or \*. Your single usage in two places instead turned the majority of the post italic.

  • His kids were probably watching him type over his shoulder and he didn’t want to hear, “Daddy, what does crap mean?”

    • "Daddy, what does cr*p mean?" Kids aren't stupid and this self-censorship isn't protecting anyone from anything.

      (if a platform is serious about Bad Words for whatever reason (moral?) they would also forbid character replacements; ultimately it's the intent, not the word itself, that they try to steer with rules like that)

    • I'd consider that a joke - but also zero issue using any words talking in front of kids. You might wish to explain them anyways.

    • I am arguing that they would ask that anyway.

      I guess I never understood censorship when it’s plainly obvious what you’re censoring. Anyone who can read will clearly know that it said “crap”, so I don’t see how it’s fundamentally different than just saying the word. You still put the word into my brain.

  • My guess is that jacobgorm will not reply. I would love a reply, because I want to understand how others think.

    I believe we'll be left to wonder.

> 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.

  • > I don't see how it's worth having any emotions or opinions about it.

    Ironic, seeing as that is an opinion about it. Also weird telling people in an online discussion forum not to have opinions.

  • > Are win32 APIs proprietary?

    Yes. And crap. Not in my code bases.

    • 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.

      4 replies →

    • The CPU on most machines is quite proprietary. I don’t understand this faux purity dogma.

      Practical computing is not and never has been an abstract pure concept. It’s about making machines built by corporations to do usefull things at scale.

      There is no ”non proprietary” computing unless you make your own stack.

      10 replies →

  • CUDA is not an API, CUDA is a language, so you cannot make that comparison.

Launching kernels manually is an error prone PITA which I believe is the principle reason for CUDA's popularity. Having the compiler give an error when you mess up is a huge benefit. But having the compiler allow you to express "I want to launch this kernel over a grid with these dimensions, with these arguments" as a single expression is where the vast majority of the value comes from.

The having it all in a single file is mostly an artefact of the fact that it is C++, because C++ is single file at a time compilation. In D (which is multiple files in a single compiler invocation) with DCompute (which targets CUDA and OpenCL with upcoming support for Vulkan and Metal), you are required to write the kernels in a separate module, but you get all the benefits of the compiler complaining when you mess up _and_ the expressivity of "launch me this kernel".

  • > Having the compiler give an error when you mess up is a huge benefit.

    Shouldn't this be alleviated by the current code generation machines?

Having also played with Metal and WebGPU (at least years ago), I would say that CUDA is, amazingly, the best GPGPU API we have. Do I wish we had an open source parallel programming language as good or better than it? Yes. But asymmetrically hating on CUDA like this is how we continue to lag behind it in UX.

> 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

Not to mention that this is a completely sane way to use CUDA as well.

  • People that attack proprietary APIs always miss the point why most devs outside FOSS circles prefer them.

    Turns out when one isn't ideologically against something they aren't willing to put up with a lesser experience just for the cause.

    • I know it's not the same thing because proprietary vs open software it's way less important but, generally if you are not ideologically against something you can easily follow the stream and do lot of nefarious actions, especially if the action has enough degrees of separations from the actual nefast outcome.

from what i can tell, you're going to be stuck with that no matter what you do

i'm currently using vulkan, and HLSL via dxc. which should be portable but it's not.

apple refuses to support vulkan, and relies on moltenvk and there's a bunch of OS/hardware/driver differences no matter what you do, that you'll probably have to feature test for, and compile a few different versions of your code no matter what you do

i think if you're doing something that you don't have to distribute to customers, just picking one stack and getting locked in has some appeal.

it leaves you vulnerable to lockin. but, especially in the age of ai, "claude, port this to vulkan" seems like a good enough defense against that

I don't mind CUDA, I do mind that all of the SDKs don't dynamically load the various CUDA shared libraries at runtime.. intertwining itself into your application linking process makes for extreme binary portability inconvenience.

> 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

Isn't that how CUDA code is normally written?

  • No. CUDA allows you to write all the code in a single file, and uses a preprocessor to split it back out and pass it through separate compilers, one for host and one for device.

    • This true, but you can write the two separately if you want.

      The disadvantages of writing them together are listed in the various parent posts. But some code authors really like the convenience of having the two in the same file.

You could also use Mojo, one language for all targets.

  • Or julia if you want a much more mature ecosystem.

    • I highly recommend Julia for (scientific) GPU programming but it would be nice if there was a larger community and/or funding behind the GPU side of things. It has very few core devs for what it is.

  • I began to lose interest after the acquisition. Have you been following along, are they still going to open source it?

    • The Mojo compiler has been open source for over a month now.

      And the Mojo standard library has been open source for over a year.

      It’s all open source. Go check it out!

      1 reply →

? I find it hard to see the issue here. Just put it in a separate file and call it?

Is this satire? D3D12 and Metal aren't any less proprietary than CUDA.

  • You can call their APIs without needing to compile your code with a proprietary compiler or adopt a bastardized version of C++.

yeah, just write a stub/wrapper around it and abstract. it's the classic coupling problem. nothing to do with CUDA