AMD's Kernel Graphics Code Is Approaching One Million Lines

Written by Michael Larabel in Linux Kernel on 13 April 2017 at 11:16 AM EDT. 30 Comments
LINUX KERNEL
With the DRM driver features settled for Linux 4.12, I was curious about the size of these Direct Rendering Manager drivers.

In particular, I was curious about the size of the AMDGPU code-base now that it's merged the (non-display) Radeon RX Vega support, which is quite large. It's difficult to give an exact size to AMDGPU since there are some shader folders for headers, PowerPlay, and scheduler. But if looking at the drivers/gpu/drm/amd it's almost up to one million lines of code via the DRM-Next code:
----------------------------------------
Language files blank comment code
----------------------------------------
C/C++ Header 362 14968 61140 815246
C 172 26133 17535 135252
make 7 50 34 132
----------------------------------------
SUM: 541 41151 78709 950630
----------------------------------------

Though that does include the AMDKFD driver (~9.2k), but even if factoring in for the shared code, the modern AMDGPU kernel driver stack is quite large. Once the DC (DAL) code lands in the future, it will surely push it over one million lines. That obviously also doesn't account for the size of the RadeonSI Gallium3D driver, RADV, or the AMDGPU LLVM back-end that's also a critical part of the open-source driver stack. But even with those, still not quite as large as Catalyst / Radeon Software. I believe the last I heard on their binary driver front that amounted to around 14 million lines.

For comparison, the older Radeon DRM code amounts to just shy of 160k lines:
----------------------------------------
Language files blank comment code
----------------------------------------
C 111 17667 13075 120408
C/C++ Header 83 4042 5657 39438
make 1 29 7 78
----------------------------------------
SUM: 195 21738 18739 159924
----------------------------------------

Or the Intel i915 DRM driver at around 126k:
----------------------------------------
Language files blank comment code
----------------------------------------
C 144 24992 21837 107781
C/C++ Header 65 3350 5248 18072
make 2 17 14 119
----------------------------------------
SUM: 211 28359 27099 125972
----------------------------------------

The Nouveau open-source NVIDIA DRM driver also hits the sweet spot of 100~150k lines:
----------------------------------------
Language files blank comment code
----------------------------------------
C 600 14247 18203 96046
C/C++ Header 292 2050 3041 28395
----------------------------------------
SUM: 892 16297 21244 124441
----------------------------------------

The ARM/embedded DRM drivers tend to be much smaller. The VC4 DRM driver for Raspberry Pi Broadcom graphics is just shy of 10k:
----------------------------------------
Language files blank comment code
----------------------------------------
C 18 1828 1506 8367
C/C++ Header 5 291 413 1429
make 1 5 2 22
----------------------------------------
SUM: 24 2124 1921 9818
----------------------------------------

Lastly, for the overall size of the drivers/gpu/drm size is about 1.6 million lines -- including the 900k+ of the modern AMD DRM code -- and including all of the smaller drivers and common DRM code:
----------------------------------------
Language files blank comment code
----------------------------------------
C/C++ Header 1092 35927 86860 957335
C 1650 143418 116701 721653
make 65 211 111 926
----------------------------------------
SUM: 2807 179556 203672 1679914
----------------------------------------

In relation to the overall size of the Linux kernel tree, here were the stats on the DRM-Next branch as of today:
------------------------------------------------
Language files blank comment code
------------------------------------------------
C 24369 2364992 2151438 12025516
C/C++ Header 18489 458709 829512 3298053
Assembly 1454 49188 114748 249156
JSON 121 0 0 81164
make 2296 8515 8044 36053
Perl 50 5062 3740 26164
Bourne Shell 232 2694 3929 13929
Python 66 2139 2503 11857
HTML 3 537 0 4523
yacc 8 662 356 4393
lex 8 301 300 1907
C++ 7 287 71 1838
Bourne Again Shell 46 384 315 1699
awk 12 185 170 1510
Markdown 1 220 0 1077
TeX 1 108 3 904
NAnt script 2 156 0 588
Pascal 3 49 0 231
Objective C++ 1 55 0 189
m4 1 15 1 95
XSLT 6 13 27 71
CSS 1 14 23 35
vim script 1 3 12 27
sed 3 2 30 21
Windows Module Definition 1 0 0 8
------------------------------------------------
SUM: 47182 2894290 3115222 15761008
------------------------------------------------

The kernel tree has a sum of around 15.7 million lines. So DRM keeps getting bigger and the modern AMD DRM graphics driver code itself amounts to about 6% of the Linux kernel size (on DRM-Next) while will surely be getting larger when DC lands, future ASIC enablement, and other features.
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