News for hackers. Stuff that matters.
Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by ChuckNorris89 on Friday June 02, 2023 @10:21AM (#36165447)
>their equivalent of CUDA

Nvidia didn't pull their AI leadership out of thin air overnight, but they shipped the first CUDA capable consumer cards with the GeForce 8000 series way back in 2007 and committed to this ecosystem over the years, consistently investing in the HW, SW.

By the time AMD woke up and shipped ROCm in 2016, Nvidia already had nearly 10 years head start and a cemented moat in this field. AMD now has a huge mountain to climb to catch up to Nvidia.

Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by mahkeiro on Friday June 02, 2023 @10:31AM (#36165597)
I always had hope that ROCm will be able to compete with CUDA but it’s nowhere here despite the time. Seems funny to see that Intel is doing a better job at that with OneAPI.
Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by bryanlarsen on Friday June 02, 2023 @10:53AM (#36165929)
AMD invested significantly into OpenCL prior to 2016. It seemed like a safe bet -- the open industry standard usually ends up beating the proprietary standard in the long run.

Especially for something like this, with massive open source / open standard companies like Google as heavy users. It seems surprising to me that Google didn't ensure that open standards won in an area that they are so heavily dependent on.

Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by ChuckNorris89 on Friday June 02, 2023 @12:50PM (#36167568)
Because all the researchers that used GPUs for CV and ML used what they had at their disposal, which was Nvidia GPUs and CUDA.

OpenCL brought no advantage here considering it only worked on AMD GPUs which were lackluster in performance and switching from CUDA to OpenCL meant extra work that researches already iterating on CUDA weren't willing to do.

Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by cibyr on Friday June 02, 2023 @01:59PM (#36168564)
OpenCL works fine on Nvidia GPUs. It's more annoying to code for, and harder to get good performance out of than CUDA, but it works.
Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by dragontamer on Friday June 02, 2023 @02:06PM (#36168678)
Poorly, in my experience.

CUDA is compiled into PTX, an intermediate language. PTX is then compiled into a specific NVidia assembly language (often called SASS, though each SASS for each generation of cards is different). This way, NVidia can make huge changes to the underlying assembly code from generation-to-generation, but still have portability.

OpenCL, especially OpenCL 1.2, (which is the version of OpenCL that works on the widest set of cards), does not have an intermediate language. SPIR is an OpenCL2.+ concept.

This means that OpenCL 1.2 code is distributed in source and recompiled in practice. But that means that compiler errors can kill your code before it even runs. This is especially annoying because the OpenCL 1.2 compiler is part of a device-driver. Meaning if the end-user updates the device driver, the compiler may have a new bug (or old bug), that changes the behavior of your code.

-------------

This doesn't matter for DirectX, because like CUDA, Microsoft compiles DirectX into DXIR / DirectX intermediate language. And then has device drivers compile the intermediate-language into the final assembly code on a per-device basis.

-------------

It is this intermediate layer that AMD is missing, and IMO is the key to their problems in practice.

SPIR (OpenCL's standard intermediate layer) has spotty support across cards. I'm guessing NVidia knows that PTX intermediate language is their golden goose and doesn't want to offer good SPIR support. Microsoft probably prefers people to use DirectX / DXIR as well. So that leaves AMD and Intel as the only groups who could possibly push SPIR and align together. SPIR is a good idea, but I'm not sure if the politics will allow it to happen.

Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by KeplerBoy on Friday June 02, 2023 @04:12PM (#36170128)
OpenCL also gets compiled to PTX on Nvidia GPUs.
Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by dragontamer on Friday June 02, 2023 @04:24PM (#36170264)
But as an OpenCL programmer, you don't distribute PTX intermediate code. You distribute OpenCL kernels around and recompile every time. That's more or less the practice.
Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by KeplerBoy on Friday June 02, 2023 @04:29PM (#36170338)
True.

And the resulting PTX is worse when it's generated from OpenCL C instead of CUDA C. I tested that recently with a toy FFT kernel and the CUDA pipeline produced a lot more efficient FMA instructions.

Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by JonChesterfield on Friday June 02, 2023 @06:39PM (#36171759)
It's really difficult to tell whether the PTX layer approach is something AMD _should_ adopt. That's roughly what the (I think now abandoned) HSAIL thing was.

It's one where packaging concerns and compiler dev concerns are probably in tension. Compiling for N different GPUs is really annoying for library distribution and probably a factor in the shortish list of officially supported ROCm cards.

However translating between IRs is usually lossy so LLVM to PTX to SASS makes me nervous as a pipeline. Intel are doing LLVM to SPIRV to LLVM to machine code which can't be ideal. Maybe that's a workaround for LLVM's IR being unstable, but equally stability in IR comes at a development cost.

I think amdgpu should use a single llvm IR representation for multiple hardware revisions and specialise in the backend. That doesn't solve binary stability hazards but would take the edge off the packaging challenge. That seems to be most of the win spirv markets at much lower engineering cost.

Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by DeepYogurt on Friday June 02, 2023 @02:06PM (#36168665)
OpenCL did (and still does I think) work on nvidia cards. People I talked to back in the day complained more about OpenCL being "C but on GPUs" while cuda was more akin to C++. They could move faster and do more in cuda and the nvidia lock in didn't matter as the fastest cards of the day were nvidia. I think vega cards were faster (or faster per dollar maybe) for some of the code that was relevant, but not by much and by that point legacy code lock in had taken over.
Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by belval on Friday June 02, 2023 @02:13PM (#36168772)
If you ever get the chance to write something in OpenCL and then in CUDA I promise you will understand immediately why Google didn't push for it.

There is a lot more boilerplate to it, read/write to the buffer, queueing being handled explicitly. Here's an example that illustrate what I mean: https://github.com/rsnemmen/OpenCL-examples/blob/master/mand...

For comparison here is an implementation in CUDA: http://selkie.macalester.edu/csinparallel/modules/CUDAArchit...

Notice how the CUDA code is more readable.

Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by bryanlarsen on Friday June 02, 2023 @02:20PM (#36168847)
Google is part of the Khronos group. They were well positioned to steer the standard towards one that doesn't suck. Or they could have championed a different standard. Google has the scale that only Google is to blame that they are still heavily dependent on a closed standard.

Open Standards almost always beat closed ones. IMO AMD was right to bet on open standards. They lost the bet but I think it was the right bet.

Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by barbariangrunge on Friday June 02, 2023 @05:18PM (#36170869)
> the Khronos group

I still wake up at night, sweating, thinking about my time learning OpenGL in university. The docs were a nightmare back then

Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by shaklee3 on Saturday June 03, 2023 @01:14AM (#36173917)
openCL != openGL
Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by SuchAnonMuchWow on Friday June 02, 2023 @03:24PM (#36169624)
In the link provided, the CUDA example only show the compute kernel itself and not the boilerplate required to run it. On the other hand, your OpenCL example only show the boilerplate.

This is the OpenCL kernel from the same repo, for a more fair comparison: https://github.com/rsnemmen/OpenCL-examples/blob/master/mand...

This is much more readable. OpenCL-C the language is fine: it's how you deploy the program on the cards that is complicated with opencl.

Re:Lisa Su Saved AMD. Now She Wants Nvidia's AI Crown by Keyframe on Friday June 02, 2023 @02:35PM (#36169002)
Nvidia took a big gamble with CUDA and it took years and ton of investment to get there. Jensen Huang talks about it on commencement speech he did in Taiwan recently here https://www.youtube.com/watch?v=oi89u6q0_AY It's a big moat to cross.