News for hackers. Stuff that matters.
Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by agloe_dreams on Thursday August 31, 2023 @01:47PM (#37341040)
I'm not sure I get why the comparison to the Kernel is needed. GPUs are wildly complex. Rendering is wildly complex. Managing memory and data is complex. Managing connected hardware is complex. I am not sure why anyone would expect a GPU Driver to be small while also doing a billion things and playing games as well as mature gaming platforms.
Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by harry8 on Thursday August 31, 2023 @02:21PM (#37341586)
If you're not intimately familiar with GPU drivers and what goes on this gives you a very quick, back-of-the-envelope of the size and complexity of the work involved. 1/7th the size and complexity of the kernel for this one driver.

I raised an eyebrow but I have only the vaguest notion of how the hardware works and what a driver might have to manage.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by dralley on Thursday August 31, 2023 @02:39PM (#37341855)
As the article pointed out, the vast majority of the lines of code in the driver are autogenerated header files for things like defining hardware registers. There's not much complexity or logic in that type of code.

Probably if AMD wanted to spend the time, they could compress it down to a fraction of it's current size.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by jmole on Thursday August 31, 2023 @03:07PM (#37342209)
Right, if you have 7 different architectures, each with it's own register map, and then model-specific tweaks, you're going to have a ton of code like that.
Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by undersuit on Thursday August 31, 2023 @03:51PM (#37342781)
We could just compile it into a proprietary blob like Nvidia! /s
Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by benlwalker on Thursday August 31, 2023 @04:35PM (#37343359)
Is it really that much code? I don't know GPU hardware, but the NVMe spec header file in SPDK is around 4k lines[0]. If there's 7 of them and they're twice as complicated each, we're still well under 100k from register map headers. I didn't actually look through Linux to see how big they are, so maybe it is that much more complex.

0: https://github.com/spdk/spdk/blob/master/include/spdk/nvme_s...

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by StillBored on Thursday August 31, 2023 @08:06PM (#37345156)
NVMe is largely the model people here are complaining about. A small kernel shim driver that is talking to a huge firmware code base on the other side of a mailbox interface.

Even on small m.2 style standalone drives, your looking at code, which not only handles the details of managing flash error correction, wear leveling, garbage collection, etc, etc, but all the code required to manage the thermal, voltage, pcie link training, etc of the 2-5 or so microcontrollers embedded in the drive and possibly an RTOS or two hosting it all.

Never mind fabric attach (DPU?) NVMe devices which do all that, plus deal with thin provisioning, partitioning, deduplication, device sharing, replication, RAID, etc, etc. Frequently themselves embedding a Linux (or similar level of complexity OS) kernel in the control plane.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by scns on Thursday August 31, 2023 @04:58PM (#37343593)
> if you have 7 different architectures

GPU or CPU? If talking about the latter only two [four] should count (ARM & x86 [+ [* 2 64BitVersion]]. If you meant the former forget my comment.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by userbinator on Thursday August 31, 2023 @08:08PM (#37345183)
Do they modify where all the registers are and the meaning of their bits with each new generation? That seems like an extremely wasteful way to do things.

I'm not familiar with AMD's GPUs, but have done some "bare metal" Intel GPU programming, and there's definitely a lot of commonality between different generations going all the way back to the i810.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by tester756 on Thursday August 31, 2023 @03:00PM (#37342123)
>If you're not intimately familiar with GPU drivers and what goes on this gives you a very quick, back-of-the-envelope of the size and complexity of the work involved. 1/7th the size and complexity of the kernel for this one driver.

ehh, no.

almost all of this are header files

>Meanwhile the open-source NVIDIA "Nouveau" driver is around 201k (21.7k blank lines, 24.3k lines of comments, and 155k lines of code). Or the Intel i915 DRM kernel graphics driver is around 381k lines via the same cloc judgment.

so it seems like GPU driver is around 1% of kernel's code

and you start thinking why actually kernel has this much code if GPU (out of all software) needs just around 1%.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by boppo1 on Thursday August 31, 2023 @03:58PM (#37342882)
Nouveau barely works iirc
Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by smashed on Thursday August 31, 2023 @10:23PM (#37346058)
That is a bit harsh..

Nouveau will bring up you're Linux desktop just fine and connect all your monitors.

It will run OpenGL apps and light games.

Last time I checked it could not boost the clock and push most chips to high performance mode.

This is mostly 100% Nvidia's fault of not opening up the specs.

Otherwise what nouveau has been able to reverse engineer is just amazing.

The nouveau driver is so much less painful to use, it just works completely seamlessly. If you don't need the extra performance, it is not worth the trouble to install the Nvidia blob.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by torginus on Friday September 01, 2023 @08:15AM (#37349791)
Unfortunately I had very negative experience with it. I have a laptop with an Nvidia secondary, GPU and had the repeat terrible experience of my computer locking up right on boot due to the broken Nouveau driver that shipped with the kernel. It'd have been fine to not even initialize the GPU, as I wasn't actually using it, which is what I ended up doing, disabling nouveau right from the Grub menu.
Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by nvm0n2 on Thursday August 31, 2023 @04:10PM (#37343038)
The NVIDIA proprietary driver is about the same size compiled as the Linux kernel, iirc.

The reason is, GPU drivers are basically complete operating systems, just for the secondary computer we call the GPU instead of the CPU.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by extropy on Thursday August 31, 2023 @07:37PM (#37344957)
That GPU firmware is generally just a blob that has never been open sourced. The driver is the part that talks to the GPU, not the OS that runs inside the GPU. Unless I'm mistaken in which case this would be a huge deal.
Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by AnthonyMouse on Thursday August 31, 2023 @08:04PM (#37345144)
I don't think that's the reason.

The large majority of the "Linux kernel code" is drivers, but the large majority of the driver code is the GPU drivers. And the GPU doesn't have its own collection of drivers for every network chip or USB controller ever made.

The second biggest part of the Linux kernel is "arch/" which is the architecture-specific stuff, but GPUs don't really have that either -- a given vendor more or less corresponds to a platform architecture, but if you compare it to, say, "x86/" that's only ~11% of "arch/" and <1% of the kernel.

The reason the GPU drivers are so big is that they're gibberish. Instead of specifying an interface to interact with the GPU in a sane way, they're full of magic numbers that seem to map a (large, overly complex) API interface into the values you pass to the GPU to call the API functions implemented by the GPU's firmware, which is the actual GPU "operating system" but the vendors want to keep as a black box.

Which is obviously counter-productive because it keeps users from optimizing for their GPU, which would make things run faster on it (or have fewer stability bugs), which would make more people want to buy them over a competitor's, which was supposed to be the reason for the secrecy.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by sylware on Thursday August 31, 2023 @02:47PM (#37341955)
It is said nvidia hardware programming interface is much more simple than AMD one.

If true, AMD is doing something wrong here. And yes, giga tons of generated headers related to registers.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by fulafel on Friday September 01, 2023 @02:00AM (#37347333)
This is specifically about the kernel driver part.

Most of the GPU software stack can reasonably be outside the kernel. There's no obvious reason why much of it would need to be in ring-0 where bugs cause OS crashes and security vulnerabilities.

> Meanwhile the open-source NVIDIA "Nouveau" driver is around 201k (21.7k blank lines, 24.3k lines of comments, and 155k lines of code). Or the Intel i915 DRM kernel graphics driver is around 381k lines via the same cloc judgment.

But without separate line counts of the generated data tables and actual human written code, we don't have the real line count numbers to compare.

Re:AMD Open-Source GPU Kernel Driver Above 5M Lines, Entire ... by flohofwoe on Friday September 01, 2023 @04:14AM (#37348080)
All of this is also true for modern CPUs, yet I don't need a driver to talk to CPUs because the ISA serves as the abstracted and standardized programming interface to the underlying CPU hardware. If GPU vendors wouldn't be so keen about protecting their "IP", GPUs could have gone that same path.