AMD Open-Source GPU Kernel Driver Above 5 Million Lines, Entire Linux Kernel At 34.8 Million

Written by Michael Larabel in Radeon on 31 August 2023 at 11:13 AM EDT. 98 Comments
RADEON
With the in-development Linux 6.6 kernel adding support for more upcoming Radeon graphics processors, that means more auto-generated header files for the new IP blocks... I was curious to see the overall size now of the AMDGPU kernel driver along with its associated code like the AMDKFD compute driver. It's now above 5 million lines for the kernel driver portion.

Following the DRM-Next merge to Linux 6.6, I ran some cloc stats on the AMD Linux kernel graphics driver code. In particular, the drivers/gpu/drm/amd/ area that contains the modern code around the AMDGPU DRM driver with AMDKFD compute, display code, common header files, etc (but not counting the older "Radeon" driver in drivers/gpu/drm/radeon/). This open-source AMD Linux kernel graphics driver amounts to more than 5 million lines:
    2173 text files.
    2172 unique files.                                          
       5 files ignored.

github.com/AlDanial/cloc v 1.90  T=16.28 s (133.2 files/s, 309249.2 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C/C++ Header                  1363          66401         452869        3789164
C                              749         100186          73147         546125
Assembly                         3            597            525           1955
make                            53            391           1257            867
-------------------------------------------------------------------------------
SUM:                          2168         167575         527798        4338111
-------------------------------------------------------------------------------

Of course, much of that is auto-generated header files... A large portion of it with AMD continuing to introduce new auto-generated header files with each new generation/version of a given block. These verbose header files has been AMD's alternative to creating exhaustive public documentation on their GPUs that they were once known for.

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.

It's also worth reminding users that this is just the kernel graphics driver code and not counting all of the code within Mesa for providing the OpenGL and Vulkan driver support or other user-space components.

The entire Linux kernel source tree as of this morning comes in at around 34.8 million lines, including the documentation, various in-tree utilities/tools, other helpers, etc. That figure is from 4,414,747 blank lines, 4,246,577 lines of comments, and 26,168,342 detected lines of code.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week