lib/Rex/GPU/NVIDIA/Requirement.pm

filter: Statementstmt 100% 128 / 128 Branchbran 98.0% 98 / 100 Conditioncond 84.0% 58 / 69 MC/DCmcdc 72.0% 31 / 43 Subroutinesub 100% 21 / 21 Podpod 90.0% 9 / 10 totaltotal 92.9% 345 / 371 CC 79 SCAR 22.6
CC
79
Cov
96%
why_not
20.0
_lookup
13.1
conflicts
10.0
CRAP 9.5
« lib/Rex/GPU/AMD.pm ↑ Summary lib/Rex/GPU/Detect/Sysfs.pm »
1 # ABSTRACT: What NVIDIA driver a GPU generation needs (experimental)
2  
3 package Rex::GPU::NVIDIA::Requirement;
4 49 our $VERSION = '0.006';
5 49 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 49 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 49 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 49 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 49 my %KERNEL_MODULES = map { $_ => 1 } qw( open proprietary either );
11  
12  
13 49 has generation => ( is => 'ro' );
14  
15  
16 has kernel_module => (
17 is => 'ro',
18 default => 'either',
19 3082 ▶ isa => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
20 croak __PACKAGE__.'->kernel_module must be open, proprietary or either, not '
21 .( defined $_[0] ? "'".$_[0]."'" : 'undef' )
22 3082 ▶ unless defined $_[0] && $KERNEL_MODULES{ $_[0] };
Branch: 2 branches
BranchTrueFalseTotal
unless defined $_[0] and $KERNEL_MODULES{$_[0]} 3 3079 3082
defined $_[0] ? : 2 1 3
Condition100%3/3
defined $_[0] and $KERNEL_MODULES{$_[0]}
!ll&&!rl&&r
123079
MC/DC100%2/2
defined $_[0] and $KERNEL_MODULES{$_[0]}
defined $_[0] $KERNEL_MODULES{$_[0]}
Truth table100%3/3
A and B
A= defined $_[0]B= $KERNEL_MODULES{$_[0]}
ABresult
0X0
100
111
23 }
24 49 );
25  
26  
27 49 has min_branch => ( is => 'ro', isa => \&_check_branch );
28 49 has max_branch => ( is => 'ro', isa => \&_check_branch );
29  
30 2815 ▶sub _check_branch {
Subroutine _check_branch: called CC=3 SCAR=11.1
31 2815 my ( $branch ) = @_;
32 2815 ▶ croak __PACKAGE__.': a driver branch is an integer like 580, not '."'".$branch."'"
Branch: 1 branch
BranchTrueFalseTotal
if defined $branch and not $branch =~ /^\d+\z/ 1 2814 2815
Condition66%2/3
defined $branch and not $branch =~ /^\d+\z/
!ll&&!rl&&r
028141
MC/DC50%1/2
defined $branch and not $branch =~ /^\d+\z/
defined $branch not $branch =~ /^\d+\z/
Truth table66%2/3
A and not(B)
A= defined $branchB= not $branch =~ /^\d+\z/
ABresult
0X0
100
111
33 if defined $branch && $branch !~ /^\d+\z/;
34 }
35  
36  
37 has device_id => (
38 is => 'ro',
39 2864 ▶ isa => sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
40 2864 ▶ croak __PACKAGE__.'->device_id must be four lowercase hex digits, not '."'".$_[0]."'"
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] and not $_[0] =~ /^[0-9a-f]{4}\z/ 1 2863 2864
Condition66%2/3
defined $_[0] and not $_[0] =~ /^[0-9a-f]{4}\z/
!ll&&!rl&&r
028631
MC/DC50%1/2
defined $_[0] and not $_[0] =~ /^[0-9a-f]{4}\z/
defined $_[0] not $_[0] =~ /^[0-9a-f]{4}\z/
Truth table66%2/3
A and not(B)
A= defined $_[0]B= not $_[0] =~ /^[0-9a-f]{4}\z/
ABresult
0X0
100
111
41 if defined $_[0] && $_[0] !~ /^[0-9a-f]{4}\z/;
42 }
43 49 );
44  
45  
46 49 has name => ( is => 'ro' );
47 2985 ▶has members => ( is => 'ro', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
48  
49  
50 49 has compute => ( is => 'ro' );
51  
52 3078 ▶sub BUILD {
Subroutine BUILD: called CC=4 SCAR=13.9
Pod undocumented
53 3078 my ( $self ) = @_;
54 3078 ▶ croak __PACKAGE__.': min_branch '.$self->min_branch.' is above max_branch '
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->min_branch and defined $self->max_branch and $self->min_branch > $self->max_branch 1 3077 3078
Condition100%6/6
defined $self->min_branch and defined $self->max_branch and $self->min_branch > $self->max_branch
!ll&&!rl&&r
3063141
defined $self->min_branch and defined $self->max_branch
!ll&&!rl&&r
963210015
MC/DC100%3/3
defined $self->min_branch and defined $self->max_branch and $self->min_branch > $self->max_branch
defined $self->min_branch defined $self->max_branch $self->min_branch > $self->max_branch
Truth table100%4/4
A and B and C
A= defined $self->min_branchB= defined $self->max_branchC= $self->min_branch > $self->max_branch
ABCresult
0XX0
10X0
1100
1111
55 .$self->max_branch.': no driver branch can satisfy that'
56 if defined $self->min_branch && defined $self->max_branch
57 && $self->min_branch > $self->max_branch;
58 }
59  
60  
61 # The rows, and where they come from (moved here from Rex::GPU::Detect, karr
62 # #16 and #26). The compute flag decides Rex::GPU::Detect::_is_nvidia_compute
63 # before any name rule (karr #45, #54). Maintainer decision (karr #54): every
64 # GPU usable for AI is compute -- MX, GT and GTX 9xx with 2 GB included -- as
65 # long as a current driver branch supports it; the criterion is the
66 # generation, not the marketing name. So Maxwell through Blackwell Ultra carry
67 # compute => 1 and the Kepler-or-older row compute => 0 (skipped with a
68 # warning, not a die, before the PCI class rule (karr #55): gpu_setup /
69 # Rex::Rancher gpu => 1 keep going without the old card, a K80 included). An ID no row covers (0x3000+
70 # except Blackwell Ultra) has no verdict; Detect uses its name rules and its
71 # unknown-model default compute => 0 there.
72 #
73 # Checked 2026-09-24 against NVIDIA's supportedchips READMEs (Linux-x86_64
74 # 615.71.09, 580.95.05, 580.126.09, 550.163.01, 535.247.01) and pci.ids of
75 # 2026-09-24:
76 # * 580.95.05 / 580.126.09 "current" list starts at 1340: every ID of the
77 # 615 legacy_580 list (1340..1DF6) is current there -- incl. Maxwell Gen1
78 # GM107/GM108: GTX 750 Ti 1380, GTX 745 1382, 940MX 134D, MX130 174D,
79 # MX110 174E -- except 137D (GeForce 940A, subsystem entry only) and 1DF5
80 # (V100-SXM2-16GB), which only the 615 legacy_580 list names.
81 # * No legacy_470-or-older ID is >= 1340; no current/legacy_580 ID < 1340.
82 # * pci.ids: no 10de ID >= 1340 carries a Kepler-or-older codename (GK, GF,
83 # GT2xx, G8x/G9x, NVxx), and no Maxwell-or-newer codename sits below 1340
84 # except HD-audio functions (PCI class 0403, never read by detection).
85 # pci.ids does name two Kepler IDs like Maxwell/Pascal products -- 0FC5
86 # "GK107 [GeForce GT 1030]", 11C7 "GK106 [GeForce GTX 750 Ti]" -- which is
87 # why the ID row decides before any name rule.
88 #
89 # Blackwell (karr #16): NO proprietary kernel module — NVIDIA's open GPU
90 # kernel modules are the only ones that bind — on every architecture, x86_64
91 # included. Source: the supported-GPU table in NVIDIA's open-gpu-kernel-modules
92 # README.md (github.com/NVIDIA/open-gpu-kernel-modules, driver 615.71.09). In
93 # that table the last pre-Blackwell (Ada) ID is 28F8, and every listed ID from
94 # 2901 up to 2F58 is Blackwell: B200 (2901, 2909), GB200 (2941), GeForce RTX
95 # 50xx desktop/laptop and RTX PRO Blackwell (2B85..2F58), GB10 (2E12).
96 # 0x2900-0x2FFF is therefore taken as a block: an unlisted ID inside it is
97 # post-Ada silicon and gets the open module (which supports every GPU from
98 # Turing on). Blackwell Ultra (B300 3182, GB300 31C2/31C3) is listed
99 # explicitly, NOT as a block — whatever else lands at 0x3000+ is unknown.
100 # min_branch 570 / 580: the first branch with Blackwell / Blackwell Ultra
101 # support (research for epic karr #25).
102 #
103 # GB10 (2E12, DGX Spark) is the exception inside the Blackwell block: min 580
104 # (karr #33, checked 2026-09-23 against NVIDIA's primary sources). 2E12 is
105 # absent from the open-gpu-kernel-modules README.md of every 570.x and 575.x
106 # tag and of 580.65.06 .. 580.105.08; it first appears in tag 580.119.02
107 # ("NVIDIA GB10 | 2E12 10DE 21EC"), and is in 580.126.09, 590.48.01, 595.44.02
108 # and 615.71.09 -- but NOT in 590.44.01. The aarch64 driver README
109 # (us.download.nvidia.com/XFree86/aarch64/<ver>/README/supportedchips.html)
110 # agrees: absent in 580.95.05 and 590.44.01, present in 580.119.02 and
111 # 590.48.01. A branch-granular row cannot express "580.119.02 or newer".
112 #
113 # Pre-Turing (karr #26). Source: the legacy sections of NVIDIA's
114 # supportedchips README (driver 615.71.09, us.download.nvidia.com/XFree86/
115 # Linux-x86_64/615.71.09/README/supportedchips.html), checked 2026-09-23:
116 # * "current" list: lowest ID 1E02 (TITAN RTX, Turing). No current ID < 1E02.
117 # * 580.xx legacy list (Maxwell/Pascal/Volta): exactly 1340..1DF6, e.g.
118 # Tesla M60 13F2, M40 17FD, P100 15F7/15F8, P40 1B38, P4 1BB3, TITAN V
119 # 1D81, V100 1DB1/1DB4-1DB6, V100S 1DF6. Proprietary kernel module only —
120 # the open module needs GSP, which these chips lack — and 580 is their last
121 # branch (595+ dropped them).
122 # * 470.xx list (Kepler): 0FC6..12BA. The 390.xx (Fermi) list interleaves
123 # with it (1040..1251) and goes down to 06C0; older legacy lists reach
124 # down to 0020. No list has an ID in 12BB..133F or 1DF7..1E01.
125 # So every ID below 1340 is Kepler or older and no driver newer than 470
126 # supports it: one block, not a Kepler-only range, so a Fermi Tesla (C2050
127 # 06D1, M2090 1091) is rejected too. 1340..1DF6 is taken as a block like the
128 # Blackwell one: an unlisted ID inside it is Maxwell..Volta silicon.
129 #
130 # Turing, Ampere, Ada, Hopper (karr #54): 1DF7..28FF, compute 1. One block
131 # without bounds until k107; now four blocks, and an ID that NVIDIA lists
132 # first in a later branch than its block's floor has a row of its own with that
133 # branch as min_branch. Checked 2026-11-26 against the "current" list of
134 # NVIDIA's supportedchips README (us.download.nvidia.com/XFree86/<arch>/
135 # <version>/README/supportedchips.html) of every Linux-x86_64 release in
136 # download.nvidia.com/XFree86/Linux-x86_64/ from 470.42.01 to 620.73.04 (143
137 # READMEs; 470.82.01 and 525.60.13 have none) and of the aarch64 ones of the
138 # same versions (137; every floor below is the same on aarch64):
139 # * 470.256.02, the last 470 and the one Debian 11 ships, lists nothing above
140 # 25FA: no Hopper (23xx), no Ada (26xx..28xx). Neither does 515.105.01, the
141 # last 515. Both first appear in 520.56.06: H100 PCIe 2331 (as 2331 10DE
142 # 1626) and GeForce RTX 4090 2684. The open-gpu-kernel-modules README
143 # agrees: no 23xx or 26xx..28xx ID in tags 515.43.04, 515.65.01 and
144 # 515.105.01; 2331 from 520.56.06.
145 # * Block edges, over every section of all 143 READMEs: nothing is listed in
146 # 2239..230D, 2349..2413, 25FC..2683 or 28F9..2900. Below 2300 the highest
147 # ID is 2238 (A10M, Ampere), above 23FF the lowest 2414 (RTX 3060 Ti,
148 # Ampere); everything from 230E to 2348 is Hopper, from 2684 to 28F8 Ada.
149 # So 2300..23FF is taken as Hopper and 2600..28FF as Ada, blocks like the
150 # Blackwell one: an unlisted ID inside gets the generation's oldest branch,
151 # 520. pci.ids (version 2026.11.26, names only) has nothing else there
152 # either: only GH100 names in 2300..23FF, only AD102 (2681, 2682) in
153 # 2600..2683, and in 2239..22FF no display device (HD audio, NVSwitch,
154 # Tegra bridges) except 223F GA102GL.
155 # * Turing/Ampere, 1DF7..22FF and 2400..25FF: no bound. Every ID listed
156 # there is in 470.256.02 -- 470 is the oldest branch a built-in source
157 # installs -- except the IDs with their own rows in generations. Floors
158 # below 470 were not researched.
159 # * The row floor is the oldest branch whose LAST release lists the ID; the
160 # comment above each group of rows names the release that first lists it.
161 # Whole branches only: an earlier point release of that branch can lack
162 # the ID. The releases Debian ships list every ID whose row their branch
163 # passes (sources.debian.org, 2026-11-26: bullseye 470.256.02, bookworm
164 # 535.261.03, trixie 550.163.01).
165 # * A floor, never a ceiling: some IDs are missing again from a later
166 # branch's README ("not in NNN" in the group comments; no built-in source
167 # installs 515..530, 545 or 555..565), and the lists drop GPUs that are
168 # still supported (Tesla T4 1EB8 is missing from 495.29.05 to 570.211.01).
169 # * Sources disagree: 2685 (RTX 4090 D) is in 535.154.05 but in no other 535
170 # release, then from 550.40.07 on -- min 550, as 535's last release lacks
171 # it. 2336 (H100 80GB HBM2e) is listed in 525.85.05 only: no row of its
172 # own, it gets the Hopper block's 520.
173 #
174 # Grace Hopper GH200 (karr #72): 2342 and 2348 sit inside the Hopper block but
175 # get their own rows ahead of it -- open kernel module only, by MAINTAINER
176 # DECISION, not by NVIDIA's driver documentation. The open-only evidence is
177 # NVIDIA's blog post "NVIDIA Transitions Fully Towards Open-Source GPU Kernel
178 # Modules" (2024), which says Grace Hopper and Blackwell platforms must use
179 # the open modules. NVIDIA's driver README disagrees: kernel_open.html
180 # ("Open Linux Kernel Modules", aarch64 and Linux-x86_64 alike) of 560.35.03
181 # .. 580.126.09 says the proprietary flavor supports "later GPUs until
182 # Blackwell", of 590.48.01 and 615.71.09 "Turing, Ampere, Ada, and Hopper",
183 # with no Grace exception in any of them; and NVIDIA-Linux-aarch64-615.71.09
184 # .run ships a proprietary kernel/nv-kernel.o_binary. Checked 2026-09-26.
185 # IDs, from NVIDIA's supportedchips READMEs (aarch64 and Linux-x86_64,
186 # checked 2026-09-26); no other product uses them:
187 # * 2342 GH200 120GB (10DE:16EB, 10DE:1805), GH200 480GB (10DE:1809):
188 # in 535.247.01, 545.29.06 (16EB and 1809 only), 550.54.14, 560.35.03,
189 # 565.77, 570.86.16, 570.172.08, 615.71.09; NOT in 535.104.05. In the
190 # open-gpu-kernel-modules README from tag 550.54.14 on (not up to
191 # 545.23.06). min_branch 535: whole branches only, so an early 535
192 # point release (535.104.05) is not caught here. Every 535 release was
193 # checked on 2026-11-26 (k107): the first to list 2342 is
194 # 535.129.03, on Linux-x86_64 and aarch64; 535.113.01 does not.
195 # * 2348 GH200 144G HBM3e (10DE:18D2): from 565.77 on (not in 560.35.03);
196 # open-gpu-kernel-modules README of 570.172.08, 580.95.05, 615.71.09.
197 # min_branch 565. On 2026-11-26 (k107): already in 565.57.01, the
198 # first 565 release, on both architectures.
199 #
200 # Everything else — the gaps above 2FFF and any future ID — has no row:
201 # either kernel module, no bounds, no compute verdict.
202 2863 ▶sub generations {
Subroutine generations: called CC=1 SCAR=0.0
Pod documented
203 return (
204 { generation => 'Blackwell', first => 0x2e12, last => 0x2e12, # GB10, see above
205 kernel_module => 'open', min_branch => 580, compute => 1 },
206 { generation => 'Blackwell', first => 0x2900, last => 0x2fff, # GB100/GB102, GB20x, GB10
207 kernel_module => 'open', min_branch => 570, compute => 1 },
208 { generation => 'Blackwell Ultra', first => 0x3182, last => 0x3182, # B300 SXM6 AC
209 kernel_module => 'open', min_branch => 580, compute => 1 },
210 { generation => 'Blackwell Ultra', first => 0x31c2, last => 0x31c3, # GB300
211 kernel_module => 'open', min_branch => 580, compute => 1 },
212 { generation => 'Grace Hopper', first => 0x2342, last => 0x2342, # GH200 120GB/480GB, see above
213 kernel_module => 'open', min_branch => 535, compute => 1 },
214 { generation => 'Grace Hopper', first => 0x2348, last => 0x2348, # GH200 144G HBM3e
215 kernel_module => 'open', min_branch => 565, compute => 1 },
216 # Hopper, Ada and Turing/Ampere IDs NVIDIA lists first in a branch newer
217 # than their block's floor (k107, see above): one row per ID, as
218 # [ generation, min_branch, device IDs ]. Per group, the release that first
219 # lists each ID, and the later branches whose last release lacks one.
220 ( map {
221 2863 my ( $generation, $branch, @ids ) = @$_;
222 40082 map { +{ generation => $generation, first => hex $_, last => hex $_,
223 min_branch => $branch, compute => 1 } } @ids
224 }
225 # 525.85.05 2330 H100 80GB HBM3; 525.105.17 2322 H800 PCIe, 2324 H800,
226 # 2339 H100.
227 [ 'Hopper', 525, qw( 2322 2324 2330 2339 ) ],
228 # 535.104.05 2321 H100 NVL, 233A H800 NVL; 535.161.07 2329 H20;
229 # 535.230.02 232C H20-3e. Not in 545: 2329 232C; 555, 560: 232C.
230 [ 'Hopper', 535, qw( 2321 2329 232c 233a ) ],
231 # 550.90.07 2335 H200.
232 [ 'Hopper', 550, qw( 2335 ) ],
233 # 565.57.01 233B H200 NVL.
234 [ 'Hopper', 565, qw( 233b ) ],
235 # 580.82.07 230E H20 NVL16.
236 [ 'Hopper', 580, qw( 230e ) ],
237 # 525.60.11 26B1 RTX 6000 Ada, 26B5 L40, 2704 RTX 4080; 525.78.01 2782 RTX
238 # 4070 Ti; 525.89.02 2717/2757 RTX 4090 Laptop, 27A0/27E0 RTX 4080 Laptop,
239 # 2820/2860 RTX 4070 Laptop, 28A0/28E0 RTX 4060 Laptop, 28A1/28E1 RTX 4050
240 # Laptop; 525.105.17 27B0 RTX 4000 SFF Ada, 27B8 L4; 525.116.03 2730 RTX
241 # 5000 Ada Laptop, 2786 RTX 4070, 27BA RTX 4000 Ada Laptop, 27BB RTX 3500
242 # Ada Laptop, 2838 RTX 3000 Ada Laptop, 28B8 RTX 2000 Ada Laptop;
243 # 525.125.06 2803 RTX 4060 Ti; 525.147.05 2770 RTX 5000 Ada Embedded, 2805
244 # RTX 4060 Ti, 2882 RTX 4060, 28F8 RTX 2000 Ada Embedded. Not in 530: 2730
245 # 2770 2786 27BA 27BB 2803 2805 2838 2882 28B8 28F8.
246 [ 'Ada', 525, qw( 26b1 26b5 2704 2717 2730 2757 2770 2782 2786 27a0 27b0 27b8 27ba
247 27bb 27e0 2803 2805 2820 2838 2860 2882 28a0 28a1 28b8 28e0 28e1
248 28f8 ) ],
249 # 535.98 26B2 RTX 5000 Ada, 27B2 RTX 4000 Ada; 535.104.05 26B9 L40S, 27FB
250 # RTX 3500 Ada Embedded; 535.113.01 27B1 RTX 4500 Ada; 535.146.02 26B3 RTX
251 # 5880 Ada; 535.154.05 26BA L20, 27B6 L2; 535.171.04 28B9 RTX 1000 Ada
252 # Laptop, 28BB RTX 500 Ada Laptop; 535.183.01 28BA RTX 500 Ada Laptop. Not
253 # in 545: 26B3 26BA 27B6 28B9 28BA 28BB.
254 [ 'Ada', 535, qw( 26b2 26b3 26b9 26ba 27b1 27b2 27b6 27fb 28b9 28ba 28bb ) ],
255 # 550.40.07 2685 RTX 4090 D (see above), 2705 RTX 4070 Ti SUPER, 2783 RTX
256 # 4070 SUPER; 550.54.14 2702 RTX 4080 SUPER, 28B0 RTX 2000/2000E Ada;
257 # 550.67 2709 RTX 4070, 2788 RTX 4060 Ti, 2808 RTX 4060; 550.107.02 2822,
258 # 550.142 28A3, 550.163.01 28E3 RTX 3050 A Laptop. Not in 555: 2822 28A3
259 # 28E3; 560, 565: 28A3 28E3.
260 [ 'Ada', 550, qw( 2685 2702 2705 2709 2783 2788 2808 2822 28a3 28b0 28e3 ) ],
261 # 555.42.02 2689 RTX 4070 Ti SUPER.
262 [ 'Ada', 555, qw( 2689 ) ],
263 # 510.47.03 2233 RTX A5500, 2238 A10M; 510.60.02 24B1 RTX A4000H, 25AA
264 # MX570 A; 510.85.02 1F83 GTX 1630; 510.108.03 20F3 A800-SXM4-80GB, 20F5
265 # A800 80GB PCIe, 20F6 A800 40GB PCIe/Active, 2207 RTX 3070 Ti, 24C9 RTX
266 # 3060 Ti, 2521 RTX 3060 Laptop, 2544 RTX 3060. Not in 520: 20F3 20F5
267 # 20F6; 515, 525, 530: 20F6.
268 [ 'Turing/Ampere', 510, qw( 1f83 20f3 20f5 20f6 2207 2233 2238 24b1 24c9 2521 2544
269 25aa ) ],
270 # 515.105.01 2582 RTX 3050, 25AB RTX 3050 4GB Laptop, 25AC/25EC RTX 3050
271 # 6GB Laptop, 25AD/25ED RTX 2050, 25FB RTX A500 Embedded. Not in 520: all.
272 [ 'Turing/Ampere', 515, qw( 2582 25ab 25ac 25ad 25ec 25ed 25fb ) ],
273 # 525.116.03 24C7 RTX 3060, 25BC RTX A1000 6GB Laptop, 25BD RTX A500
274 # Laptop. Not in 530: all.
275 [ 'Turing/Ampere', 525, qw( 24c7 25bc 25bd ) ],
276 # 535.104.05 20BD A800-SXM4-40GB; 535.154.05 20FD AX800; 535.161.07 2584
277 # RTX 3050. Not in 545: 20FD 2584.
278 [ 'Turing/Ampere', 535, qw( 20bd 20fd 2584 ) ],
279 # 550.76 25B0 RTX A1000, 25B2 RTX A400.
280 [ 'Turing/Ampere', 550, qw( 25b0 25b2 ) ]
281 ),
282 { generation => 'Hopper', first => 0x2300, last => 0x23ff, # GH100; 2331 H100 PCIe, 520.56.06
283 min_branch => 520, compute => 1 },
284 { generation => 'Ada', first => 0x2600, last => 0x28ff, # AD10x; 2684 RTX 4090, 520.56.06
285 min_branch => 520, compute => 1 },
286 { generation => 'Turing/Ampere', first => 0x1df7, last => 0x22ff, # TU10x/TU11x, GA100, GA102
287 compute => 1 },
288 { generation => 'Turing/Ampere', first => 0x2400, last => 0x25ff, # GA103..GA107
289 compute => 1 },
290 { generation => 'Maxwell/Pascal/Volta', first => 0x1340, last => 0x1df6,
291 kernel_module => 'proprietary', max_branch => 580, compute => 1 },
292 { generation => 'Kepler or older', first => 0x0000, last => 0x133f,
293 kernel_module => 'proprietary', max_branch => 470, compute => 0 }
294 );
295 }
296  
297  
298 1368 ▶sub for_device_id {
Subroutine for_device_id: called CC=2 SCAR=8.1
Pod documented
299 1368 my ( $self, $device_id ) = @_;
300 1368 ▶ return ( ref $self || $self )->new( $self->_lookup( $device_id ) );
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
013680
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
301 }
302  
303 1551 ▶sub from_gpu {
Subroutine from_gpu: called CC=4 SCAR=14.2
Pod documented
304 1551 my ( $self, $gpu ) = @_;
305 1551 ▶ croak __PACKAGE__.'->from_gpu needs a GPU hashref from Rex::GPU::Detect::detect'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $gpu eq "HASH" 2 1549 1551
306 unless ref $gpu eq 'HASH';
307 return ( ref $self || $self )->new(
308 $self->_lookup( $gpu->{device_id} ),
309 1549 ▶ defined $gpu->{name} ? ( name => $gpu->{name} ) : ()
Branch: 1 branch
BranchTrueFalseTotal
defined $gpu->{'name'} ? : 1543 6 1549
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
015490
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
310 );
311 }
312  
313 # Constructor arguments for a device ID. The format check is the one
314 # Rex::GPU::Detect used before this table existed, kept as it was so the
315 # wrappers there return exactly what they did.
316 2917 ▶sub _lookup {
Subroutine _lookup: called CC=13 SCAR=25.7
317 2917 my ( $self, $device_id ) = @_;
318 2917 ▶ return () unless defined $device_id && $device_id =~ /^[0-9a-f]{4}$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $device_id and $device_id =~ /^[0-9a-f]{4}$/i 54 2863 2917
Condition100%3/3
defined $device_id and $device_id =~ /^[0-9a-f]{4}$/i
!ll&&!rl&&r
41132863
MC/DC100%2/2
defined $device_id and $device_id =~ /^[0-9a-f]{4}$/i
defined $device_id $device_id =~ /^[0-9a-f]{4}$/i
Truth table100%3/3
A and B
A= defined $device_idB= $device_id =~ /^[0-9a-f]{4}$/i
ABresult
0X0
100
111
319 2863 my $id = hex $device_id;
320 2863 my %args = ( device_id => lc substr( $device_id, 0, 4 ) );
321 2863 for my $row ( $self->generations ) {
322 croak __PACKAGE__.'->generations: every row needs first and last'
323 126266 ▶ unless defined $row->{first} && defined $row->{last};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $row->{"first"} and defined $row->{"last"} 0 126266 126266
Condition33%1/3
defined $row->{"first"} and defined $row->{"last"}
!ll&&!rl&&r
00126266
MC/DC0%0/2
defined $row->{"first"} and defined $row->{"last"}
defined $row->{"first"} defined $row->{"last"}
Truth table33%1/3
A and B
A= defined $row->{"first"}B= defined $row->{"last"}
ABresult
0X0
100
111
324 126266 ▶ next unless $id >= $row->{first} && $id <= $row->{last};
Branch: 1 branch
BranchTrueFalseTotal
unless $id >= $row->{"first"} and $id <= $row->{"last"} 123447 2819 126266
Condition100%3/3
$id >= $row->{"first"} and $id <= $row->{"last"}
!ll&&!rl&&r
90680327672819
MC/DC100%2/2
$id >= $row->{"first"} and $id <= $row->{"last"}
$id >= $row->{"first"} $id <= $row->{"last"}
Truth table100%3/3
A and B
A= $id >= $row->{"first"}B= $id <= $row->{"last"}
ABresult
0X0
100
111
325 return (
326 %args,
327 generation => $row->{generation},
328 kernel_module => $row->{kernel_module} // 'either',
329 defined $row->{min_branch} ? ( min_branch => $row->{min_branch} ) : (),
330 defined $row->{max_branch} ? ( max_branch => $row->{max_branch} ) : (),
331 2819 ▶ defined $row->{compute} ? ( compute => $row->{compute} ? 1 : 0 ) : ()
Branch: 4 branches
BranchTrueFalseTotal
defined $row->{'min_branch'} ? : 2013 806 2819
defined $row->{'max_branch'} ? : 680 2139 2819
defined $row->{'compute'} ? : 2817 2 2819
$row->{'compute'} ? : 2651 166 2817
Condition100%2/2
$row->{"kernel_module"} // "either"
l!l
15781241
MC/DC100%1/1
$row->{"kernel_module"} // "either"
$row->{"kernel_module"}
Truth table100%2/2
A
A= $row->{"kernel_module"}
Aresult
11
00
332 );
333 }
334 44 return %args;
335 }
336  
337  
338 48 ▶sub satisfied_by {
Subroutine satisfied_by: called CC=2 SCAR=6.9
Pod documented
339 48 my ( $self, $source ) = @_;
340 48 ▶ return defined $self->why_not( $source ) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->why_not($source) ? : 24 21 45
341 }
342  
343 1425 ▶sub why_not {
Subroutine why_not: called CC=20 SCAR=30.0
Pod documented
344 1425 my ( $self, $source ) = @_;
345 1425 ▶ croak __PACKAGE__.'->satisfied_by needs a source hashref { kernel_module, branch }'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $source eq "HASH" 1 1424 1425
346 unless ref $source eq 'HASH';
347 1424 my ( $branch, $floor ) = @{ $source }{qw( branch branch_at_least )};
348 1424 for my $n ( $branch, $floor ) {
349 2847 ▶ croak __PACKAGE__.'->satisfied_by: branch must be an integer like 580, not '."'".$n."'"
Branch: 1 branch
BranchTrueFalseTotal
if defined $n and not $n =~ /^\d+\z/ 2 2845 2847
Condition100%3/3
defined $n and not $n =~ /^\d+\z/
!ll&&!rl&&r
143514102
MC/DC100%2/2
defined $n and not $n =~ /^\d+\z/
defined $n not $n =~ /^\d+\z/
Truth table100%3/3
A and not(B)
A= defined $nB= not $n =~ /^\d+\z/
ABresult
0X0
100
111
350 if defined $n && $n !~ /^\d+\z/;
351 }
352  
353 1422 ▶ if ( $self->kernel_module ne 'either' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->kernel_module ne "either") 866 556 1422
354 866 my $module = $source->{kernel_module};
355 866 ▶ return ( defined $module ? $module : 'unknown' ).' kernel module, the '
Branch: 2 branches
BranchTrueFalseTotal
unless defined $module and $module eq $self->kernel_module 206 660 866
defined $module ? : 205 1 206
Condition100%3/3
defined $module and $module eq $self->kernel_module
!ll&&!rl&&r
1205660
MC/DC100%2/2
defined $module and $module eq $self->kernel_module
defined $module $module eq $self->kernel_module
Truth table100%3/3
A and B
A= defined $moduleB= $module eq $self->kernel_module
ABresult
0X0
100
111
356 .$self->kernel_module.' one is needed'
357 unless defined $module && $module eq $self->kernel_module;
358 }
359 1216 my ( $min, $max ) = ( $self->min_branch, $self->max_branch );
360 1216 ▶ return unless defined $min || defined $max;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $min or defined $max 73 1143 1216
Condition100%3/3
defined $min or defined $max
l!l&&r!l&&!r
87227173
MC/DC100%2/2
defined $min or defined $max
defined $min defined $max
Truth table100%3/3
A or B
A= defined $minB= defined $max
ABresult
1X1
011
000
361  
362 1143 ▶ if ( defined $branch ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $branch) 660 483 1143
363 660 ▶ return 'branch '.$branch.' is older than '.$min if defined $min && $branch < $min;
Branch: 1 branch
BranchTrueFalseTotal
if defined $min and $branch < $min 27 633 660
Condition100%3/3
defined $min and $branch < $min
!ll&&!rl&&r
23439927
MC/DC100%2/2
defined $min and $branch < $min
defined $min $branch < $min
Truth table100%3/3
A and B
A= defined $minB= $branch < $min
ABresult
0X0
100
111
364 633 ▶ return 'branch '.$branch.' is newer than '.$max if defined $max && $branch > $max;
Branch: 1 branch
BranchTrueFalseTotal
if defined $max and $branch > $max 6 627 633
Condition100%3/3
defined $max and $branch > $max
!ll&&!rl&&r
3732546
MC/DC100%2/2
defined $max and $branch > $max
defined $max $branch > $max
Truth table100%3/3
A and B
A= defined $maxB= $branch > $max
ABresult
0X0
100
111
365 627 return;
366 }
367 483 ▶ return 'driver branch not known, '.( defined $min ? $min.' or newer' : $max.' or older' )
Branch: 2 branches
BranchTrueFalseTotal
unless defined $floor 5 478 483
defined $min ? : 2 3 5
368 .' is needed'
369 unless defined $floor;
370 478 ▶ return 'installs the newest branch it carries, which can be newer than '.$max
Branch: 1 branch
BranchTrueFalseTotal
if defined $max 37 441 478
371 if defined $max;
372 441 ▶ return 'installs the newest branch it carries, known only to be '.$floor
Branch: 1 branch
BranchTrueFalseTotal
if $floor < $min 5 436 441
373 .' or newer; '.$min.' is needed'
374 if $floor < $min;
375 436 return;
376 }
377  
378  
379 529 ▶sub intersect {
Subroutine intersect: called CC=9 SCAR=22.0
Pod documented
380 529 my ( $self, @requirements ) = @_;
381 529 ▶ unshift @requirements, $self if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 2 527 529
382 529 my @members = $self->_members_of( @requirements );
383 527 ▶ return $requirements[0] if @requirements == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @requirements == 1 429 98 527
384  
385 98 my @conflicts = $self->conflicts( @members );
386 98 ▶ croak __PACKAGE__.'->intersect: no single NVIDIA driver supports all GPUs on this host: '
Branch: 1 branch
BranchTrueFalseTotal
if @conflicts 4 94 98
387 .join( '; ', @conflicts )
388 if @conflicts;
389  
390 94 my %module = map { $_->kernel_module => 1 } @members;
391 94 my ( $lower, $upper ) = $self->_bounds( @members );
392 94 ▶ my $class = ref $self || $self;
Condition66%2/3
ref $self || $self
l!l&&r!l&&!r
1930
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table66%2/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
393 return $class->new(
394 kernel_module => $module{open} ? 'open'
395 94 ▶ : $module{proprietary} ? 'proprietary'
Branch: 4 branches
BranchTrueFalseTotal
$module{'open'} ? : 64 30 94
$module{'proprietary'} ? : 16 14 30
$lower ? : 91 3 94
$upper ? : 16 78 94
396 : 'either',
397 $lower ? ( min_branch => $lower->min_branch ) : (),
398 $upper ? ( max_branch => $upper->max_branch ) : (),
399 members => \@members
400 );
401 }
402  
403 637 ▶sub conflicts {
Subroutine conflicts: called CC=10 SCAR=23.0
Pod documented
404 637 my ( $self, @requirements ) = @_;
405 637 ▶ unshift @requirements, $self if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 2 635 637
406 637 my @members = $self->_members_of( @requirements );
407  
408 637 my %by_module;
409 637 push @{ $by_module{ $_->kernel_module } }, $_ for @members;
410 637 my ( $lower, $upper ) = $self->_bounds( @members );
411  
412 637 my @conflicts;
413 30 ▶ push @conflicts, join( ', ', map { $_->who } @{ $by_module{open} } )
Branch: 1 branch
BranchTrueFalseTotal
@{$by_module{'open'};} == 1 ? : 30 0 30
414 30 .' need'.( @{ $by_module{open} } == 1 ? 's' : '' ).' the open kernel module, but '
415 31 ▶ .join( ', ', map { $_->who } @{ $by_module{proprietary} } )
Branch: 1 branch
BranchTrueFalseTotal
@{$by_module{'proprietary'};} == 1 ? : 29 1 30
416 30 .' need'.( @{ $by_module{proprietary} } == 1 ? 's' : '' ).' the proprietary one'
417 637 ▶ if $by_module{open} && $by_module{proprietary};
Branch: 1 branch
BranchTrueFalseTotal
if $by_module{"open"} and $by_module{"proprietary"} 30 607 637
Condition100%3/3
$by_module{"open"} and $by_module{"proprietary"}
!ll&&!rl&&r
37423330
MC/DC100%2/2
$by_module{"open"} and $by_module{"proprietary"}
$by_module{"open"} $by_module{"proprietary"}
Truth table100%3/3
A and B
A= $by_module{"open"}B= $by_module{"proprietary"}
ABresult
0X0
100
111
418 637 ▶ push @conflicts, $lower->who.' needs driver branch '.$lower->min_branch
Branch: 1 branch
BranchTrueFalseTotal
if $lower and $upper and $lower->min_branch > $upper->max_branch 3 634 637
Condition100%6/6
$lower and $upper and $lower->min_branch > $upper->max_branch
!ll&&!rl&&r
580543
$lower and $upper
!ll&&!rl&&r
13244857
MC/DC100%3/3
$lower and $upper and $lower->min_branch > $upper->max_branch
$lower $upper $lower->min_branch > $upper->max_branch
Truth table100%4/4
A and B and C
A= $lowerB= $upperC= $lower->min_branch > $upper->max_branch
ABCresult
0XX0
10X0
1100
1111
419 .' or newer, but '.$upper->who.' is supported only up to branch '.$upper->max_branch
420 if $lower && $upper && $lower->min_branch > $upper->max_branch;
421 637 return @conflicts;
422 }
423  
424 # Validated, flattened members of a list of requirements.
425 1166 ▶sub _members_of {
Subroutine _members_of: called CC=7 SCAR=19.5
426 1166 my ( $self, @requirements ) = @_;
427 1166 ▶ croak __PACKAGE__.'->intersect needs at least one requirement'
Branch: 1 branch
BranchTrueFalseTotal
unless @requirements 1 1165 1166
428 unless @requirements;
429 1165 for my $req ( @requirements ) {
430 1812 ▶ croak __PACKAGE__.'->intersect: not a '.__PACKAGE__.' object: '.( $req // 'undef' )
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($req) and $req->isa(__PACKAGE__) 1 1811 1812
Condition60%3/5
builtin::blessed($req) and $req->isa(__PACKAGE__)
!ll&&!rl&&r
101811
$req // "undef"
l!l
10
MC/DC50%1/2
builtin::blessed($req) and $req->isa(__PACKAGE__)
builtin::blessed($req) $req->isa(__PACKAGE__)
MC/DC0%0/1
$req // "undef"
$req
Truth table66%2/3
A and B
A= builtin::blessed($req)B= $req->isa(__PACKAGE__)
ABresult
0X0
100
111
Truth table50%1/2
A
A= $req
Aresult
11
00
431 unless blessed( $req ) && $req->isa( __PACKAGE__ );
432 }
433 1164 ▶ return map { @{ $_->members } ? @{ $_->members } : $_ } @requirements;
Branch: 1 branch
BranchTrueFalseTotal
@{$_->members;} ? : 1 1809 1810
434 }
435  
436 # The member with the highest lower bound and the one with the lowest upper
437 # bound (either may be undef).
438 731 ▶sub _bounds {
Subroutine _bounds: called CC=1 SCAR=0.0
439 731 my ( $self, @members ) = @_;
440 820 my ( $lower ) = sort { $b->min_branch <=> $a->min_branch }
441 731 grep { defined $_->min_branch } @members;
442 8 my ( $upper ) = sort { $a->max_branch <=> $b->max_branch }
443 731 grep { defined $_->max_branch } @members;
444 731 return ( $lower, $upper );
445 }
446  
447  
448 769 ▶sub describe {
Subroutine describe: called CC=6 SCAR=17.9
Pod documented
449 769 my ( $self ) = @_;
450 769 ▶ my $module = $self->kernel_module eq 'either'
Branch: 1 branch
BranchTrueFalseTotal
$self->kernel_module eq 'either' ? : 341 428 769
451 ? 'any kernel module'
452 : $self->kernel_module.' kernel module';
453 769 my ( $min, $max ) = ( $self->min_branch, $self->max_branch );
454 769 ▶ my $branch = defined $min && defined $max ? 'driver branch '.$min.' to '.$max
Branch: 3 branches
BranchTrueFalseTotal
defined $min && defined $max ? : 15 754 769
defined $min ? : 590 164 754
defined $max ? : 145 19 164
Condition100%3/3
defined $min and defined $max
!ll&&!rl&&r
16459015
MC/DC100%2/2
defined $min and defined $max
defined $min defined $max
Truth table100%3/3
A and B
A= defined $minB= defined $max
ABresult
0X0
100
111
455 : defined $min ? 'driver branch '.$min.' or newer'
456 : defined $max ? 'driver branch '.$max.' or older'
457 : 'any driver branch';
458 769 return $module.', '.$branch;
459 }
460  
461  
462 1188 ▶sub who {
Subroutine who: called CC=5 SCAR=16.1
Pod documented
463 1188 my ( $self ) = @_;
464 1188 ▶ return join( ', ', map { $_->who } @{ $self->members } ) if @{ $self->members };
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->members;} 121 1067 1188
465 1067 ▶ my @what = grep { defined } $self->generation,
Branch: 1 branch
BranchTrueFalseTotal
defined $self->device_id ? : 1047 20 1067
466 defined $self->device_id ? '10de:'.$self->device_id : undef;
467 1067 ▶ my $who = $self->name // 'NVIDIA GPU';
Condition100%2/2
$self->name // "NVIDIA GPU"
l!l
10625
MC/DC100%1/1
$self->name // "NVIDIA GPU"
$self->name
Truth table100%2/2
A
A= $self->name
Aresult
11
00
468 1067 ▶ return @what ? $who.' ('.join( ', ', @what ).')' : $who;
Branch: 1 branch
BranchTrueFalseTotal
@what ? : 1047 20 1067
469 }
470  
471 49 1;
472  
473 __END__
« lib/Rex/GPU/AMD.pm ↑ Summary lib/Rex/GPU/Detect/Sysfs.pm »