| 1 | # ABSTRACT: AMD GPU driver (amdgpu) and ROCm management (experimental) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Rex::GPU::AMD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 40 | our $VERSION = '0.006'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use v5.14.4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 40 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 40 | ▶ | use Rex::Commands::Run (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 40 | ▶ | use Rex::Config (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 40 | ▶ | use Rex::Logger; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 40 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 40 | ▶ | use Rex::GPU::NVIDIA (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 40 | ▶ | use Rex::GPU::AMD::Hardware; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 40 | ▶ | use Rex::GPU::AMD::Setup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 40 | ▶ | use Rex::GPU::AMD::Setup::Apt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 40 | ▶ | use Rex::GPU::AMD::Setup::Debian; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 40 | ▶ | use Rex::GPU::AMD::Setup::RHEL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 40 | ▶ | use Rex::GPU::AMD::Setup::Ubuntu; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # karr k1. No Rex::Exporter: the functions are called fully qualified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # (Rex::GPU::AMD::install_driver(...), the contract with kubernetes-ocp) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # as class methods, so a Rexfile that also uses Rex::GPU::NVIDIA keeps its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # install_driver. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # Every host command of this module and its setup classes goes through ONE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # method, host_run: a subclass that overrides it sees (and may refuse) every | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # command, and the golden harness records them. Files are written with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # printf + mv over the exec channel, never through Rex's file commands: these | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # hosts have no SFTP subsystem. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # True while Rex::GPU::gpu_setup runs install_driver (local there, k90): its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # die for GPUs whose rows disagree then names gpu_setup's ways out. Internal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # no option, so install_driver -- a subclass's override included -- gets the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # arguments it always got from gpu_setup. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 40 | our $GPU_SETUP; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # The driver state, one read-only command with shell builtins only (a fork | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # only per AMD device for its driver/render symlink). Lines: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # amdgpu 0|1 /sys/module/amdgpu exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # kfd 0|1 /dev/kfd is a character device | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # pci SLOT CLASS DEVICE DRV every vendor 0x1002 device of class 0x03xxxx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # or 0x1200xx; DRV the bound driver or "-" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # vram SLOT BYTES / gtt SLOT BYTES mem_info_vram_total / mem_info_gtt_total | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # render renderDN VENDOR SLOT every /sys/class/drm/renderD* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # node N / prop KEY VALUE KFD topology nodes, decimal properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # end the read got to its end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 40 | my $STATE_SCRIPT = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | q{[ -d /sys/module/amdgpu ] && echo 'amdgpu 1' || echo 'amdgpu 0'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | . q{[ -c /dev/kfd ] && echo 'kfd 1' || echo 'kfd 0'; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | . q{for d in /sys/bus/pci/devices/*; do [ -r "$d/vendor" ] && [ -r "$d/class" ] || continue; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | . q{read -r v < "$d/vendor"; [ "$v" = 0x1002 ] || continue; read -r c < "$d/class"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | . q{case $c in 0x03*|0x1200*) ;; *) continue;; esac; i=-; [ -r "$d/device" ] && read -r i < "$d/device"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | . q{r=-; [ -e "$d/driver" ] && r=$(cd -P "$d/driver" 2>/dev/null && echo "${PWD##*/}"); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | . q{echo "pci ${d##*/} $c $i ${r:--}"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | . q{[ -r "$d/mem_info_vram_total" ] && read -r m < "$d/mem_info_vram_total" && echo "vram ${d##*/} $m"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | . q{[ -r "$d/mem_info_gtt_total" ] && read -r m < "$d/mem_info_gtt_total" && echo "gtt ${d##*/} $m"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | . q{done; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | . q{for d in /sys/class/drm/renderD*; do [ -r "$d/device/vendor" ] || continue; read -r v < "$d/device/vendor"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | . q{s=$(cd -P "$d/device" 2>/dev/null && echo "${PWD##*/}"); echo "render ${d##*/} $v ${s:--}"; done; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | . q{for n in /sys/class/kfd/kfd/topology/nodes/*; do [ -r "$n/properties" ] || continue; echo "node ${n##*/}"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | . q{while read -r k v; do case $k in gfx_target_version|vendor_id|device_id|location_id|domain|drm_render_minor) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | . q{echo "prop $k $v";; esac; done < "$n/properties"; done; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | . q{echo end}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 458 | ▶ | sub install_driver { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_driver: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 458 | ▶ | my $class = _invocant(@_) // return __PACKAGE__->configured_class->install_driver(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
_invocant(@_) // (return __PACKAGE__->configured_class->install_driver(@_))
MC/DC100%1/1
_invocant(@_) // (return __PACKAGE__->configured_class->install_driver(@_))
_invocant(@_)
Truth table100%2/2
A
A= _invocant(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 252 | my ( undef, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 252 | $class->_check_options('install_driver', \%opts, qw( gpus method reboot )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 250 | ▶ | my $method = $opts{method} // 'auto'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"method"} // "auto"
MC/DC100%1/1
$opts{"method"} // "auto"
$opts{"method"}
Truth table100%2/2
A
A= $opts{"method"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 250 | ▶ | die "install_driver: method must be 'auto', 'inbox' or 'dkms', not '$method'. " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ."Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | unless $method =~ /\A(?:auto|inbox|dkms)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 249 | my $gpus = $class->_check_gpus('install_driver', $opts{gpus}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 242 | my $state = $class->read_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 242 | ▶ | die "install_driver: could not read the AMD driver state from the host (sysfs, KFD " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ."topology). Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | unless $state; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 239 | my @targets = $class->_targets($state, $gpus); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 239 | ▶ | die "install_driver: no AMD GPU found on the host (vendor 1002, PCI class 03xx or 1200 " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ."under /sys/bus/pci/devices). Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | unless @targets; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 238 | for my $missing (grep { $_->{missing} } @targets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | die 'install_driver: '.$class->gpu_label($missing).' is not on the host. ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ."Nothing was changed on the host\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 235 | $class->_check_method($method, \@targets); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # A working driver is never touched, whatever the method (karr k1): an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # explicit method that is not the working driver's only gets a warning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 233 | ▶ | unless ($class->state_problems($state, \@targets)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 12 | ▶ | if ($method ne 'auto') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 6 | ▶ | my $source = $class->module_source // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$class->module_source // ""
MC/DC100%1/1
$class->module_source // ""
$class->module_source
Truth table100%2/2
A
A= $class->module_source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 6 | ▶ | if ($source ne $method) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | ▶ | my $have = { inbox => 'inbox ', dkms => 'DKMS ' }->{$source} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
{"inbox", "inbox ", "dkms", "DKMS "}->{$source} // ""
MC/DC100%1/1
{"inbox", "inbox ", "dkms", "DKMS "}->{$source} // ""
{"inbox", "inbox ", "dkms", "DKMS "}->{$source}
Truth table100%2/2
A
A= {"inbox", "inbox ", "dkms", "DKMS "}->{$source}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | Rex::Logger::info("install_driver: method => '$method' asked, but a working ${have}amdgpu " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | .'already drives the GPUs; install_driver never replaces a working driver. Nothing was ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | .'changed on the host', 'warn'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 12 | Rex::Logger::info('AMD driver already active: '.join(', ', map { $class->gpu_label($_) } @targets)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 12 | return 'present'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 221 | ▶ | $class->_warn_inbox_for_dkms(\@targets) if $method eq 'inbox'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 221 | my $setup = $class->setup_for(gpus => \@targets, state => $state); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 220 | ▶ | $method = $class->_auto_method(\@targets, $setup) if $method eq 'auto'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | Rex::Logger::info("Installing the AMD driver ($method) for " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 198 | .join(', ', map { $class->gpu_label($_) } @targets)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 198 | my $installed = $setup->install($method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 46 | return $class->_activate($method, \@targets, $state, $installed, $opts{reboot}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # Before the present check: method => 'dkms' for a GPU AMD supports only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # with the inbox driver dies, also on a host where the driver works. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 235 | ▶ | sub _check_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_method: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 235 | my ( $class, $method, $targets ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 235 | ▶ | return unless $method eq 'dkms'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 157 | ▶ | my @inbox = grep { ( $_->{driver} // '' ) eq 'inbox' } @$targets; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->{"driver"} // ""
MC/DC0%0/1
$_->{"driver"} // ""
$_->{"driver"}
Truth table50%1/2
A
A= $_->{"driver"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | die "install_driver: method => 'dkms', but AMD supports " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 157 | ▶ | .join(', ', map { $class->gpu_label($_) } @inbox) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ." only with the distribution kernel's inbox amdgpu, not amdgpu-dkms. " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ."Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | if @inbox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 155 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # After the present check, only when the inbox driver is really installed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # for a GPU AMD supports with amdgpu-dkms. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 30 | ▶ | sub _warn_inbox_for_dkms { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_warn_inbox_for_dkms: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 30 | my ( $class, $targets ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | Rex::Logger::info(' '.$class->gpu_label($_).": AMD supports it with amdgpu-dkms; using the " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ."inbox driver as asked (method => 'inbox')", 'warn') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 30 | ▶ | for grep { ( $_->{driver} // '' ) eq 'dkms' } @$targets; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_->{"driver"} // ""
MC/DC0%0/1
$_->{"driver"} // ""
$_->{"driver"}
Truth table50%1/2
A
A= $_->{"driver"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 30 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 38 | ▶ | sub _auto_method { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_auto_method: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 38 | my ( $class, $targets, $setup ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 38 | my %by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 38 | push @{ $by{ $_->{driver} } }, $class->gpu_label($_) for grep { defined $_->{driver} } @$targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 22 | $class->_die_mixed_drivers($setup, join(', ', @{ $by{inbox} }), join(', ', @{ $by{dkms} }), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 44 | ▶ | !grep { ( $_->{driver} // '' ) eq 'inbox' && !$_->{integrated} } @$targets) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
($_->{'driver'} // '') eq 'inbox' && !$_->{'integrated'}
$_->{"driver"} // ""
MC/DC50%1/2
($_->{'driver'} // '') eq 'inbox' && !$_->{'integrated'}
$_->{"driver"}
!$_->{'integrated'}
Truth table66%2/3
A && not(B)
A= $_->{"driver"}B= !$_->{'integrated'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 38 | ▶ | if $by{inbox} && $by{dkms}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$by{"inbox"} and $by{"dkms"}
MC/DC100%2/2
$by{"inbox"} and $by{"dkms"}
$by{"inbox"}
$by{"dkms"}
Truth table100%3/3
A and B
A= $by{"inbox"}B= $by{"dkms"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 16 | ▶ | return 'inbox' if $by{inbox}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 10 | ▶ | return 'dkms' if $by{dkms}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | my $method = $setup->fallback_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | Rex::Logger::info(" no hardware row says which driver AMD supports for these GPUs: $method " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | .( $method eq 'inbox' ? '(the running kernel has or can get amdgpu.ko)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | : '(the running kernel has no amdgpu.ko and cannot get one)' )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | return $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # Rows that disagree under auto (karr k85): the way out it names must not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # die in turn. method => 'inbox' only where plan_inbox would let every GPU | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # through (the same checks, host-read-only, in its order), else gpus => with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # the amdgpu-dkms GPUs only. On a host no driver may go to, that reason. A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # Radeon GPU outside AMD's matrix on this host (k82) is in both ways out -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # every GPU for inbox, and its row says dkms -- and both plans die for it: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # no way out is named, check_radeon dies as the plans would. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # Called from Rex::GPU::gpu_setup ($GPU_SETUP, k90), whose caller cannot pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # method or gpus: its ways out first -- leaving out amd_integrated, only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # where that skips every inbox-only GPU ($apus: all of them integrated) -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # then install_driver called directly, with the hints above. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 22 | ▶ | sub _die_mixed_drivers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_die_mixed_drivers: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 22 | my ( $class, $setup, $inbox, $dkms, $apus ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 22 | ▶ | if (my $why = $setup->host_unsupported) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | die 'install_driver: '.$why.". Nothing was changed on the host\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 20 | $setup->check_radeon; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 19 | my $only = $setup->inbox_only_unsupported; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 19 | ▶ | my $all = $only ? undef : $setup->inbox_unsupported; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 19 | ▶ | my $hint = ( $only ? "method => 'inbox' is no way out on this host for ".$inbox.': '.$only.'. ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$only or $all
MC/DC100%2/2
$only or $all
$only
$all
Truth table100%3/3
A or B
A= $onlyB= $all
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | : $all ? "method => 'inbox' is no way out on this host: ".$all.'. ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | : "Pass method => 'inbox' to drive all of them with the inbox driver. " ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | .( $only || $all ? 'Pass gpus => with '.$dkms.' only to leave '.$inbox.' out. ' : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 19 | ▶ | $hint = ( $apus ? "Leave out gpu_setup's amd_integrated => 1 to give the driver to ".$dkms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | .' only; gpu_setup then skips '.$inbox.' with a warning. Or call' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | : 'Call' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | .' Rex::GPU::AMD->install_driver directly instead of gpu_setup: '.lcfirst($hint) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | if $GPU_SETUP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 19 | die 'install_driver: AMD supports '.$inbox.' only with the inbox driver and '.$dkms | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | .' with amdgpu-dkms, and one amdgpu drives every GPU of a host. '.$hint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ."Nothing was changed on the host\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # After the install: load the module if it was not loaded, else (or if that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # was not enough) reboot -- only with reboot => 1, else warn and return. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 46 | ▶ | sub _activate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_activate: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 46 | my ( $class, $method, $targets, $before, $installed, $reboot ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 46 | ▶ | my $what = 'AMD driver ('.$method.') '.( $installed ? 'installed' : 'already installed' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 46 | my @problems; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 46 | ▶ | unless ($before->{amdgpu}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 42 | $class->host_run('modprobe amdgpu'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 42 | @problems = $class->state_problems($class->read_state, $targets); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 42 | ▶ | unless (@problems) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 41 | Rex::Logger::info($what.', amdgpu loaded and verified'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 41 | return $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | ▶ | unless ($reboot) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | ▶ | Rex::Logger::info($what.', not active yet'.( @problems ? ' ('.join('; ', @problems).')' : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | .' -- reboot the host (or pass reboot => 1) to activate it', 'warn'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | return $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 3 | $class->reboot_and_wait; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | @problems = $class->state_problems($class->read_state, $targets); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | die $what.', but not usable after the reboot: '.join('; ', @problems)."\n" if @problems; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | Rex::Logger::info($what.' and verified after the reboot'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | return $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 40 | ▶ | sub verify_amd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_amd: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 40 | ▶ | my $class = _invocant(@_) // return __PACKAGE__->configured_class->verify_amd(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
_invocant(@_) // (return __PACKAGE__->configured_class->verify_amd(@_))
MC/DC100%1/1
_invocant(@_) // (return __PACKAGE__->configured_class->verify_amd(@_))
_invocant(@_)
Truth table100%2/2
A
A= _invocant(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 21 | my ( undef, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 21 | my $gpus = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 21 | $class->_check_options('verify_amd', \%opts, 'gpus'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 20 | $class->_check_gpus('verify_amd', $opts{gpus}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 21 | ▶ | unless ($gpus) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 4 | ( my $error = $@ ) =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 4 | $error =~ s/ Nothing was changed on the host\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 4 | Rex::Logger::info($error, 'warn'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 4 | return { ok => 0, gpus => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 17 | my $state = eval { $class->read_state }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 17 | ▶ | unless ($state) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | Rex::Logger::info('verify_amd: could not read the AMD driver state from the host', 'warn'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | return { ok => 0, gpus => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 16 | my @targets = $class->_targets($state, $gpus); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 16 | my @problems = $class->state_problems($state, \@targets); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 16 | Rex::Logger::info(' AMD: '.$_, 'warn') for @problems; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | Rex::Logger::info(@problems ? 'AMD driver verification failed ('.scalar(@problems).' problem(s))' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 16 | ▶ | : 'AMD driver verified: '.join(', ', map { $class->gpu_label($_) } @targets)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | ok => @problems ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | gpus => [ map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 16 | ▶ | { slot => $_->{slot}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | device_id => $_->{device_id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | gfx_target => $_->{gfx_target}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | vram_bytes => $_->{vram_bytes}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | gtt_bytes => $_->{gtt_bytes}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | kfd_node => $_->{kfd_nodes}[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 18 | kfd_nodes => [ @{ $_->{kfd_nodes} } ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } @targets ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 181 | ▶ | sub install_rocm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_rocm: called CC=17 SCAR=28.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 181 | ▶ | my $class = _invocant(@_) // return __PACKAGE__->configured_class->install_rocm(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
_invocant(@_) // (return __PACKAGE__->configured_class->install_rocm(@_))
MC/DC100%1/1
_invocant(@_) // (return __PACKAGE__->configured_class->install_rocm(@_))
_invocant(@_)
Truth table100%2/2
A
A= _invocant(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 92 | my ( undef, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 92 | $class->_check_options('install_rocm', \%opts, qw( release gpus targets )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 91 | my $releases = $class->rocm_releases; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 91 | my $known = join ', ', sort keys %$releases; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | die "install_rocm: release => '...' is required (known: $known). Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 91 | ▶ | unless defined $opts{release}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | my $rocm = $releases->{ $opts{release} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 90 | ▶ | or die "install_rocm: unknown ROCm release '$opts{release}' (known: $known). " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | ."Nothing was changed on the host\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | die "install_rocm: pass gpus or targets, not both. Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 88 | ▶ | if defined $opts{gpus} && defined $opts{targets}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $opts{"gpus"} and defined $opts{"targets"}
MC/DC100%2/2
defined $opts{"gpus"} and defined $opts{"targets"}
defined $opts{"gpus"}
defined $opts{"targets"}
Truth table100%3/3
A and B
A= defined $opts{"gpus"}B= defined $opts{"targets"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 87 | my @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 87 | ▶ | if (defined $opts{targets}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | die "install_rocm: targets must be an arrayref of gfx target names. Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 76 | ▶ | unless ref $opts{targets} eq 'ARRAY' && !grep { !defined $_ || ref $_ } @{ $opts{targets} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
ref $opts{"targets"} eq "ARRAY" and not grep({not defined $_ or ref $_;} @{$opts{"targets"};})
!defined($_) || ref $_
MC/DC50%1/2
ref $opts{"targets"} eq "ARRAY" and not grep({not defined $_ or ref $_;} @{$opts{"targets"};})
ref $opts{"targets"} eq "ARRAY"
not grep({not defined $_ or ref $_;} @{$opts{"targets"};})
MC/DC0%0/2
!defined($_) || ref $_
!defined($_)
ref $_
Truth table66%2/3
A and not(B)
A= ref $opts{"targets"} eq "ARRAY"B= not grep({not defined $_ or ref $_;} @{$opts{"targets"};})
Truth table33%1/3
not(A) || B
A= !defined($_)B= ref $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 75 | @targets = map { lc } @{ $opts{targets} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | elsif (defined $opts{gpus}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 6 | for my $gpu (@{ $class->_check_gpus('install_rocm', $opts{gpus}) }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | die 'install_rocm: '.$class->gpu_label($gpu).' has no gfx_target; pass targets => [...]. ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | ."Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 8 | ▶ | unless defined $gpu->{gfx_target}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 7 | push @targets, lc $gpu->{gfx_target}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 5 | my $state = $class->read_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 5 | ▶ | @targets = map { $_->{gfx_target} } grep { defined $_->{gfx_target} } @{ $state ? $state->{nodes} : [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 84 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 84 | @targets = grep { !$seen{$_}++ } @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 84 | ▶ | die "install_rocm: no gfx target -- no AMD GPU with a running driver (KFD) found; pass " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | ."targets => [...]. Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | unless @targets; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 82 | my %ships = map { $_ => 1 } @{ $rocm->{targets} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 82 | for my $gfx (@targets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | die "install_rocm: ROCm $rocm->{release} has no package for $gfx (it ships: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | .join(' ', @{ $rocm->{targets} })."). Nothing was changed on the host\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 92 | ▶ | unless $ships{$gfx}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 81 | return $class->setup_for->install_rocm($rocm, \@targets); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 93 | ▶ | sub rocm_releases { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rocm_releases: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 93 | '10.1' => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | release => '10.1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | package_prefix => 'amdrocm10.1-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | targets => [qw( gfx908 gfx90a gfx942 gfx950 gfx1010 gfx1011 gfx1012 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | gfx1030 gfx1031 gfx1032 gfx1033 gfx1034 gfx1035 gfx1036 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | gfx1100 gfx1101 gfx1102 gfx1103 gfx1150 gfx1151 gfx1152 gfx1153 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | gfx1200 gfx1201 gfx1250 )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | extra_packages => [qw( libatomic1 libquadmath0 )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | repo_url => 'https://stable.repo.amd.com/rocm/core/packages/', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | key_url => 'https://stable.repo.amd.com/rocm/gpg/packages.gpg', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | key_fingerprint => 'D0F004A0025A1145C7807FCD0701EAC4D5E02107', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 747 | ▶ | sub state_script { $STATE_SCRIPT } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state_script: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 308 | ▶ | sub read_state { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_state: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 308 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 308 | my $out = $class->host_run($class->state_script); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 308 | return $class->parse_state($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 338 | ▶ | sub parse_state { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_state: called CC=20 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 338 | my ( $class, $out ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 338 | ▶ | return unless defined $out && $out =~ /^end\r?$/m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $out and $out =~ /^end\r?$/mu
MC/DC50%1/2
defined $out and $out =~ /^end\r?$/mu
defined $out
$out =~ /^end\r?$/mu
Truth table66%2/3
A and B
A= defined $outB= $out =~ /^end\r?$/mu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 322 | my %state = ( amdgpu => 0, kfd => 0, pci => [], render => [], nodes => [] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 322 | my ( %pci, $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 322 | for my $line (split /\r?\n/, $out) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 2257 | ▶ | if ($line =~ /\A(amdgpu|kfd) ([01])\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 644 | $state{$1} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | elsif ($line =~ /\Apci (\S+) 0x([0-9a-f]{4})[0-9a-f]{2} (\S+) (\S+)\z/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 352 | ▶ | my $slot = $class->normalize_slot($1) // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$class->normalize_slot($1) // (next)
MC/DC0%0/1
$class->normalize_slot($1) // (next)
$class->normalize_slot($1)
Truth table50%1/2
A
A= $class->normalize_slot($1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 352 | ▶ | my $dev = { slot => $slot, class => lc $2, device_id => _hex4($3), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | bound_driver => ( $4 eq '-' ? undef : $4 ), vram_bytes => undef, gtt_bytes => undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 352 | push @{ $state{pci} }, $dev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 352 | $pci{$slot} = $dev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | elsif ($line =~ /\A(vram|gtt) (\S+) (\d+)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 140 | ▶ | my $dev = $pci{ $class->normalize_slot($2) // '' } or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$class->normalize_slot($2) // ""
MC/DC0%0/1
$class->normalize_slot($2) // ""
$class->normalize_slot($2)
Truth table50%1/2
A
A= $class->normalize_slot($2)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 140 | $dev->{$1.'_bytes'} = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | elsif ($line =~ /\Arender (renderD\d+) (\S+) (\S+)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 94 | push @{ $state{render} }, { name => $1, vendor => _hex4($2), slot => $class->normalize_slot($3) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | elsif ($line =~ /\Anode (\d+)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 120 | push @{ $state{nodes} }, $node = { id => $1 + 0 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | ▶ | elsif ($node && $line =~ /\Aprop (\w+) (\d+)\z/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$node and $line =~ /\Aprop (\w+) (\d+)\z/u
MC/DC100%2/2
$node and $line =~ /\Aprop (\w+) (\d+)\z/u
$node
$line =~ /\Aprop (\w+) (\d+)\z/u
Truth table100%3/3
A and B
A= $nodeB= $line =~ /\Aprop (\w+) (\d+)\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 585 | $node->{$1} = $2 + 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 322 | for my $n (@{ $state{nodes} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 120 | $n->{gfx_target} = $class->hardware_class->gfx_target_from_version($n->{gfx_target_version}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 120 | ▶ | $n->{vendor} = sprintf '%04x', delete $n->{vendor_id} if defined $n->{vendor_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 120 | ▶ | $n->{device_id} = sprintf '%04x', $n->{device_id} if defined $n->{device_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # location_id = bus << 8 | devfn, both decimal in the topology | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | $n->{slot} = sprintf '%04x:%02x:%02x.%x', $n->{domain} // 0, $n->{location_id} >> 8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | ( $n->{location_id} & 0xff ) >> 3, $n->{location_id} & 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 120 | ▶ | if defined $n->{location_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$n->{"domain"} // 0
MC/DC0%0/1
$n->{"domain"} // 0
$n->{"domain"}
Truth table50%1/2
A
A= $n->{"domain"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 322 | @{ $state{nodes} } = sort { $a->{id} <=> $b->{id} } @{ $state{nodes} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 322 | return \%state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 293 | ▶ | sub state_problems { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state_problems: called CC=14 SCAR=28.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 293 | my ( $class, $state, $gpus ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 293 | ▶ | return ('the AMD driver state could not be read from the host') unless $state; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 293 | my @problems; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 293 | ▶ | push @problems, 'the amdgpu kernel module is not loaded (no /sys/module/amdgpu)' unless $state->{amdgpu}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 293 | ▶ | push @problems, 'no /dev/kfd (the ROCm compute interface of amdgpu)' unless $state->{kfd}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | my @gpus = $gpus && @$gpus ? @$gpus : map { $class->_target($state, $_) } @{ $state->{pci} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$gpus and @$gpus
MC/DC0%0/2
$gpus and @$gpus
$gpus
@$gpus
Truth table33%1/3
A and B
A= $gpusB= @$gpus
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 293 | ▶ | push @problems, 'no AMD GPU found on the host' unless @gpus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 293 | for my $gpu (@gpus) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 320 | my $label = $class->gpu_label($gpu); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 320 | ▶ | if ($gpu->{missing}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | push @problems, $label.': not on the host'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 319 | ▶ | push @problems, $label.': no KFD compute node (/sys/class/kfd/kfd/topology)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | unless $class->kfd_nodes($state, $gpu); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | push @problems, $label.': no render node (/sys/class/drm/renderD*)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 69 | ▶ | unless grep { ( $_->{vendor} // '' ) eq '1002' && defined $_->{slot} && $_->{slot} eq $gpu->{slot} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%4/8
($_->{'vendor'} // '') eq '1002' && defined $_->{'slot'} && $_->{'slot'} eq $gpu->{'slot'}
($_->{"vendor"} // "") eq 1002 and defined $_->{"slot"}
$_->{"vendor"} // ""
MC/DC33%1/3
($_->{'vendor'} // '') eq '1002' && defined $_->{'slot'} && $_->{'slot'} eq $gpu->{'slot'}
$_->{"vendor"}
defined $_->{"slot"}
$_->{'slot'} eq $gpu->{'slot'}
Truth table50%2/4
A and B && C
A= $_->{"vendor"}B= defined $_->{"slot"}C= $_->{'slot'} eq $gpu->{'slot'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 319 | ▶ | @{ $state->{render} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 293 | return @problems; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 616 | ▶ | sub kfd_nodes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
kfd_nodes: called CC=6 SCAR=20.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 616 | my ( $class, $state, $gpu ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 616 | my $slot = $class->normalize_slot($gpu->{slot}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 616 | my $id = _hex4($gpu->{device_id}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | return grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | $_->{gfx_target_version} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | && ( defined $_->{slot} ? defined $slot && $_->{slot} eq $slot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 155 | ▶ | : defined $id && ( $_->{device_id} // '' ) eq $id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition45%5/11
$_->{'gfx_target_version'} && (defined $_->{'slot'} ? defined $slot && $_->{'slot'} eq $slot : defined $id && ($_->{'device_id'} // '') eq $id)
defined $slot and $_->{"slot"} eq $slot
defined $id and ($_->{"device_id"} // "") eq $id
$_->{"device_id"} // ""
MC/DC100%2/2
$_->{'gfx_target_version'} && (defined $_->{'slot'} ? defined $slot && $_->{'slot'} eq $slot : defined $id && ($_->{'device_id'} // '') eq $id)
$_->{'gfx_target_version'}
(defined $_->{'slot'} ? defined $slot && $_->{'slot'} eq $slot : defined $id && ($_->{'device_id'} // '') eq $id)
MC/DC50%1/2
defined $slot and $_->{"slot"} eq $slot
defined $slot
$_->{"slot"} eq $slot
MC/DC0%0/2
defined $id and ($_->{"device_id"} // "") eq $id
defined $id
$_->{"device_id"}
Truth table100%3/3
A && B
A= $_->{'gfx_target_version'}B= (defined $_->{'slot'} ? defined $slot && $_->{'slot'} eq $slot : defined $id && ($_->{'device_id'} // '') eq $id)
Truth table66%2/3
A and B
A= defined $slotB= $_->{"slot"} eq $slot
Truth table0%0/3
A and B
A= defined $idB= $_->{"device_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 616 | } @{ $state->{nodes} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | # The GPUs a call is about, each resolved against the state: the given ones | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | # (matched by slot, else by device ID to a device not taken yet; one not on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | # the host gets missing => 1), or every AMD GPU the state lists. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 255 | ▶ | sub _targets { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_targets: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 255 | my ( $class, $state, $gpus ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 255 | ▶ | return map { $class->_target($state, $_) } @{ $state->{pci} } unless @$gpus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 242 | my ( @targets, %taken ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 242 | for my $gpu (@$gpus) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 269 | my $slot = $class->normalize_slot($gpu->{slot}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 269 | my $id = _hex4($gpu->{device_id}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | my ( $dev ) = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | !$taken{ $_->{slot} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 325 | ▶ | && ( defined $slot ? $_->{slot} eq $slot : ( $_->{device_id} // '' ) eq $id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
!$taken{$_->{'slot'}} && (defined $slot ? $_->{'slot'} eq $slot : ($_->{'device_id'} // '') eq $id)
$_->{"device_id"} // ""
MC/DC100%2/2
!$taken{$_->{'slot'}} && (defined $slot ? $_->{'slot'} eq $slot : ($_->{'device_id'} // '') eq $id)
!$taken{$_->{'slot'}}
(defined $slot ? $_->{'slot'} eq $slot : ($_->{'device_id'} // '') eq $id)
MC/DC0%0/1
$_->{"device_id"} // ""
$_->{"device_id"}
Truth table100%3/3
not(A) && B
A= !$taken{$_->{'slot'}}B= (defined $slot ? $_->{'slot'} eq $slot : ($_->{'device_id'} // '') eq $id)
Truth table50%1/2
A
A= $_->{"device_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 269 | } @{ $state->{pci} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 269 | ▶ | unless ($dev) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 4 | push @targets, { name => $gpu->{name}, slot => $slot, device_id => $id, missing => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | kfd_nodes => [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 265 | $taken{ $dev->{slot} } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 265 | push @targets, $class->_target($state, $dev, $gpu->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 242 | return @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 278 | ▶ | sub _target { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_target: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 278 | my ( $class, $state, $dev, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 278 | my @nodes = $class->kfd_nodes($state, $dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | my $hw = $class->hardware_class->resolve( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | device_id => $dev->{device_id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 278 | ▶ | kfd_gfx_target => ( @nodes ? $nodes[0]{gfx_target} : undef ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | slot => $dev->{slot}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | device_id => $dev->{device_id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | bound_driver => $dev->{bound_driver}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | vram_bytes => $dev->{vram_bytes}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | gtt_bytes => $dev->{gtt_bytes}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 278 | kfd_nodes => [ map { $_->{id} } @nodes ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | %$hw, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 653 | ▶ | sub gpu_label { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gpu_label: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 653 | my ( $class, $gpu ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 653 | ▶ | my $slot = $class->normalize_slot($gpu->{slot}) // $gpu->{slot}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$class->normalize_slot($gpu->{"slot"}) // $gpu->{"slot"}
MC/DC50%1/2
$class->normalize_slot($gpu->{"slot"}) // $gpu->{"slot"}
$class->normalize_slot($gpu->{"slot"})
$gpu->{"slot"}
Truth table66%2/3
A // B
A= $class->normalize_slot($gpu->{"slot"})B= $gpu->{"slot"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | return join ' ', 'AMD GPU', ( defined $slot ? $slot : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | '[1002:'.( _hex4($gpu->{device_id}) // '????' ).']', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 653 | ▶ | ( defined $gpu->{gfx_target} ? '('.$gpu->{gfx_target}.')' : () ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%2/2
_hex4($gpu->{"device_id"}) // "????"
MC/DC100%1/1
_hex4($gpu->{"device_id"}) // "????"
_hex4($gpu->{"device_id"})
Truth table100%2/2
A
A= _hex4($gpu->{"device_id"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 99 | ▶ | sub module_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
module_source: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 99 | my ( $class, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 99 | ▶ | my $kernel = $arg{kernel} // _trim($class->host_run('uname -r')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$arg{"kernel"} // _trim($class->host_run("uname -r"))
MC/DC0%0/2
$arg{"kernel"} // _trim($class->host_run("uname -r"))
$arg{"kernel"}
_trim($class->host_run("uname -r"))
Truth table66%2/3
A // B
A= $arg{"kernel"}B= _trim($class->host_run("uname -r"))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 99 | my $path = _trim($class->host_run('modinfo -n amdgpu 2>/dev/null')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 99 | ▶ | return unless length $path && $path =~ m{\A/}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $path and $path =~ m[\A/]u
MC/DC50%1/2
length $path and $path =~ m[\A/]u
length $path
$path =~ m[\A/]u
Truth table66%2/3
A and B
A= length $pathB= $path =~ m[\A/]u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 62 | ▶ | return 'inbox' if $path =~ m{\A(?:/usr)?/lib/modules/\Q$kernel\E/kernel/}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 39 | ▶ | return 'dkms' if $path =~ m{\A(?:/usr)?/lib/modules/\Q$kernel\E/(?:updates|extra)/}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | return 'other'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 5229 | ▶ | sub host_run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host_run: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 5229 | my ( $class, $command, %opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 5229 | my $out = Rex::Commands::Run::run($command, auto_die => 0, %opt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 5229 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # /etc/os-release, not Rex::Commands::Gather: Rex reports the lsb_release | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | # names where lsb_release is installed (Rocky, RockyLinux, AlmaLinux, ... -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | # karr #39), a release can come back with its dots in an unexpected form, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # and its probes are commands this module's host_run would not see. ID and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # VERSION_ID are the distribution's own, stable keys. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 302 | ▶ | sub read_os_release { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_os_release: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 302 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 302 | my $out = $class->host_run('cat /etc/os-release 2>/dev/null'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 302 | my %os; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 302 | ▶ | for my $line (split /\r?\n/, $out // '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$out // ""
MC/DC0%0/1
$out // ""
$out
Truth table50%1/2
A
A= $out
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 1705 | ▶ | next unless $line =~ /\A([A-Z][A-Z0-9_]*)=(.*)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 1705 | my ( $key, $value ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 1705 | $value =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 1705 | ▶ | $value = $1 if $value =~ /\A"(.*)"\z/ || $value =~ /\A'(.*)'\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$value =~ /\A"(.*)"\z/u or $value =~ /\A'(.*)'\z/u
MC/DC50%1/2
$value =~ /\A"(.*)"\z/u or $value =~ /\A'(.*)'\z/u
$value =~ /\A"(.*)"\z/u
$value =~ /\A'(.*)'\z/u
Truth table66%2/3
A or B
A= $value =~ /\A"(.*)"\z/uB= $value =~ /\A'(.*)'\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 1705 | $os{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 302 | return \%os; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 300 | ▶ | sub setup_class_for_os { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_class_for_os: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 300 | my ( $class, $os ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 300 | ▶ | my $id = lc( $os->{ID} // '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$os->{"ID"} // ""
MC/DC0%0/1
$os->{"ID"} // ""
$os->{"ID"}
Truth table50%1/2
A
A= $os->{"ID"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 300 | ▶ | return 'Rex::GPU::AMD::Setup::Ubuntu' if $id eq 'ubuntu'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 141 | ▶ | return 'Rex::GPU::AMD::Setup::Debian' if $id eq 'debian'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 44 | ▶ | return 'Rex::GPU::AMD::Setup::RHEL' if $id =~ /\A(?:rhel|rocky|almalinux)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 302 | ▶ | sub setup_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_for: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 302 | my ( $class, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 302 | my $os = $class->read_os_release; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | my $setup = $class->setup_class_for_os($os) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | or die 'Unsupported OS for the AMD driver: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 302 | ▶ | .( $os->{PRETTY_NAME} // $os->{ID} // 'unknown (no /etc/os-release)' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
($os->{"PRETTY_NAME"} // $os->{"ID"}) // "unknown (no /etc/os-release)"
$os->{"PRETTY_NAME"} // $os->{"ID"}
MC/DC0%0/2
($os->{"PRETTY_NAME"} // $os->{"ID"}) // "unknown (no /etc/os-release)"
$os->{"PRETTY_NAME"}
$os->{"ID"}
Truth table66%2/3
A // B
A= $os->{"PRETTY_NAME"}B= $os->{"ID"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | ." (supported: Ubuntu, Debian, RHEL, Rocky Linux, AlmaLinux). Nothing was changed on the host\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 300 | return $setup->new(amd => $class, os_release => $os, %arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 455 | ▶ | sub hardware_class { 'Rex::GPU::AMD::Hardware' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hardware_class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # Always one value (undef included), also in the list of a hash constructor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 2433 | ▶ | sub normalize_slot { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_slot: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 2433 | my ( $class, $slot ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 2433 | ▶ | return defined $slot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
defined $slot and $slot =~ /\A(?:([0-9a-f]{4,}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-7])\z/iu
$1 // "0000"
MC/DC100%2/2
defined $slot and $slot =~ /\A(?:([0-9a-f]{4,}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-7])\z/iu
defined $slot
$slot =~ /\A(?:([0-9a-f]{4,}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-7])\z/iu
MC/DC100%1/1
$1 // "0000"
$1
Truth table100%3/3
A and B
A= defined $slotB= $slot =~ /\A(?:([0-9a-f]{4,}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-7])\z/iu
Truth table100%2/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | && $slot =~ /\A(?:([0-9a-f]{4,}):)?([0-9a-f]{2}):([0-9a-f]{2})\.([0-7])\z/i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | ? lc join('', $1 // '0000', ':', $2, ':', $3, '.', $4) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 3 | ▶ | sub reboot_and_wait { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reboot_and_wait: called CC=8 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 3 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 3 | Rex::Logger::info('Rebooting host to activate the AMD driver...'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 3 | my $boot_id = $class->_read_boot_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 3 | ▶ | Rex::Logger::info(' boot_id not readable before reboot, checking only that the host answers') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | unless length $boot_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 3 | $class->host_run("nohup sh -c 'sleep 2 && shutdown -r now' >/dev/null 2>&1 &"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 3 | sleep 20; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 3 | my $conn = Rex::get_current_connection()->{conn}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 3 | for my $i (1 .. 60) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 62 | eval { $conn->disconnect() }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 62 | eval { $conn->reconnect() }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 62 | ▶ | unless ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 2 | my $test = eval { $class->host_run('echo ok') }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | ▶ | if (defined $test && $test =~ /^ok\r?$/m | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
defined $test and $test =~ /^ok\r?$/mu and !length($boot_id) || $class->_new_boot_id($boot_id)
defined $test and $test =~ /^ok\r?$/mu
not length $boot_id or $class->_new_boot_id($boot_id)
MC/DC0%0/4
defined $test and $test =~ /^ok\r?$/mu and !length($boot_id) || $class->_new_boot_id($boot_id)
defined $test
$test =~ /^ok\r?$/mu
not length $boot_id
$class->_new_boot_id($boot_id)
Truth table40%2/5
A and B and not(C) or D
A= defined $testB= $test =~ /^ok\r?$/muC= not length $boot_idD= $class->_new_boot_id($boot_id)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | && ( !length $boot_id || $class->_new_boot_id($boot_id) )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 2 | Rex::Logger::info(' Host is back online (after ~'.( $i * 5 + 20 ).'s)'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 60 | Rex::Logger::info(" Waiting for host to come back... ($i/60)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 60 | sleep 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 1 | die "Host did not come back after reboot\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 1 | ▶ | sub _new_boot_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_boot_id: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 1 | my ( $class, $old ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 1 | my $now = $class->_read_boot_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 1 | ▶ | return length $now && $now ne $old ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $now and $now ne $old
MC/DC0%0/2
length $now and $now ne $old
length $now
$now ne $old
Truth table33%1/3
A and B
A= length $nowB= $now ne $old
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 4 | ▶ | sub _read_boot_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_boot_id: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 4 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 4 | my $out = eval { $class->host_run('cat /proc/sys/kernel/random/boot_id 2>/dev/null') }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 4 | ▶ | return '' unless defined $out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 4 | ▶ | return $out =~ /^\s*([0-9a-fA-F-]{32,36})\s*$/m ? lc $1 : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 398 | ▶ | sub configured_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configured_class: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 398 | my ( $class, $amd ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 398 | my $origin = 'amd =>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 398 | ▶ | unless (defined $amd && $amd ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $amd and $amd ne ""
MC/DC100%2/2
defined $amd and $amd ne ""
defined $amd
$amd ne ""
Truth table100%3/3
A and B
A= defined $amdB= $amd ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 386 | $amd = Rex::Config->get('gpu_amd_class'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 386 | $origin = 'set gpu_amd_class'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 386 | ▶ | return __PACKAGE__ unless defined $amd && $amd ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $amd and $amd ne ""
MC/DC100%2/2
defined $amd and $amd ne ""
defined $amd
$amd ne ""
Truth table100%3/3
A and B
A= defined $amdB= $amd ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 14 | ▶ | croak 'AMD class from '.$origin.' must be a class name, not '.$amd.'. Nothing was changed on the host' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | if ref $amd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 14 | return Rex::GPU::NVIDIA->load_user_class($amd, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | base => __PACKAGE__, what => 'AMD class', origin => $origin); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 365 | ▶ | sub _check_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_options: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 365 | my ( $class, $fn, $opts, @known ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 365 | my %known = map { $_ => 1 } @known; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 365 | my @unknown = sort grep { !$known{$_} } keys %$opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 365 | ▶ | die "$fn: unknown option".( @unknown > 1 ? 's' : '' ).' '.join(', ', @unknown) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | .' (known: '.join(', ', @known)."). Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 361 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | # gpus => undef or a non-empty arrayref of hashrefs, each with a valid slot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | # or device_id. Returns the arrayref ([] for undef: every AMD GPU of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | # host). An explicit [] dies (karr k1): a caller that filtered every GPU out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | # must not get all of them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 275 | ▶ | sub _check_gpus { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_gpus: called CC=15 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 275 | my ( $class, $fn, $gpus ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 275 | ▶ | return [] unless defined $gpus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | die "$fn: gpus must be an arrayref of GPU hashrefs. Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 258 | ▶ | unless ref $gpus eq 'ARRAY' && !grep { ref $_ ne 'HASH' } @$gpus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $gpus eq "ARRAY" and not grep({ref $_ ne "HASH";} @$gpus)
MC/DC100%2/2
ref $gpus eq "ARRAY" and not grep({ref $_ ne "HASH";} @$gpus)
ref $gpus eq "ARRAY"
not grep({ref $_ ne "HASH";} @$gpus)
Truth table100%3/3
A and not(B)
A= ref $gpus eq "ARRAY"B= not grep({ref $_ ne "HASH";} @$gpus)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 255 | ▶ | die "$fn: gpus is empty; omit gpus for every AMD GPU of the host. Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | unless @$gpus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 251 | for my $gpu (@$gpus) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 281 | ▶ | my $name = $gpu->{name} // 'a GPU'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$gpu->{"name"} // "a GPU"
MC/DC100%1/1
$gpu->{"name"} // "a GPU"
$gpu->{"name"}
Truth table100%2/2
A
A= $gpu->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | die "$fn: $name is vendor '$gpu->{vendor}', not amd. Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 281 | ▶ | if defined $gpu->{vendor} && $gpu->{vendor} ne 'amd'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $gpu->{"vendor"} and $gpu->{"vendor"} ne "amd"
MC/DC100%2/2
defined $gpu->{"vendor"} and $gpu->{"vendor"} ne "amd"
defined $gpu->{"vendor"}
$gpu->{"vendor"} ne "amd"
Truth table100%3/3
A and B
A= defined $gpu->{"vendor"}B= $gpu->{"vendor"} ne "amd"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | die "$fn: $name has neither a slot nor a device_id. Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 280 | ▶ | unless defined $gpu->{slot} || defined $gpu->{device_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $gpu->{"slot"} or defined $gpu->{"device_id"}
MC/DC100%2/2
defined $gpu->{"slot"} or defined $gpu->{"device_id"}
defined $gpu->{"slot"}
defined $gpu->{"device_id"}
Truth table100%3/3
A or B
A= defined $gpu->{"slot"}B= defined $gpu->{"device_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | die "$fn: $name has a slot that is no PCI address: '$gpu->{slot}'. Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 279 | ▶ | if defined $gpu->{slot} && !defined $class->normalize_slot($gpu->{slot}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $gpu->{"slot"} and not defined $class->normalize_slot($gpu->{"slot"})
MC/DC100%2/2
defined $gpu->{"slot"} and not defined $class->normalize_slot($gpu->{"slot"})
defined $gpu->{"slot"}
not defined $class->normalize_slot($gpu->{"slot"})
Truth table100%3/3
A and not(B)
A= defined $gpu->{"slot"}B= not defined $class->normalize_slot($gpu->{"slot"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | die "$fn: $name has a device_id that is not four hex digits: '$gpu->{device_id}'. " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | ."Nothing was changed on the host\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 278 | ▶ | if defined $gpu->{device_id} && !defined _hex4($gpu->{device_id}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $gpu->{"device_id"} and not defined _hex4($gpu->{"device_id"})
MC/DC100%2/2
defined $gpu->{"device_id"} and not defined _hex4($gpu->{"device_id"})
defined $gpu->{"device_id"}
not defined _hex4($gpu->{"device_id"})
Truth table100%3/3
A and not(B)
A= defined $gpu->{"device_id"}B= not defined _hex4($gpu->{"device_id"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 247 | return $gpus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # '0x1586' / '1586' => '1586'; anything else undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 2259 | ▶ | sub _hex4 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hex4: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 2259 | my ( $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 2259 | ▶ | return defined $id && $id =~ /\A(?:0x)?([0-9a-f]{4})\z/i ? lc $1 : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $id and $id =~ /\A(?:0x)?([0-9a-f]{4})\z/iu
MC/DC100%2/2
defined $id and $id =~ /\A(?:0x)?([0-9a-f]{4})\z/iu
defined $id
$id =~ /\A(?:0x)?([0-9a-f]{4})\z/iu
Truth table100%3/3
A and B
A= defined $idB= $id =~ /\A(?:0x)?([0-9a-f]{4})\z/iu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 105 | ▶ | sub _trim { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trim: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 105 | my ( $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 105 | ▶ | $text //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$text //= ""
MC/DC0%0/1
$text //= ""
$text
Truth table50%1/2
A
A= $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 105 | $text =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 105 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | # As in Rex::GPU::NVIDIA: the invocant when called as a method on a class or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # object that isa Rex::GPU::AMD, undef when called as a function -- a first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | # argument such as 'gpus' is no package of ours. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 679 | ▶ | sub _invocant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_invocant: called CC=5 SCAR=16.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 679 | my ( $first ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 679 | ▶ | return unless defined $first && ( !ref $first || blessed $first ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $first and !ref($first) || builtin::blessed($first)
not ref $first or builtin::blessed($first)
MC/DC33%1/3
defined $first and !ref($first) || builtin::blessed($first)
defined $first
not ref $first
builtin::blessed($first)
Truth table50%2/4
A and not(B) or C
A= defined $firstB= not ref $firstC= builtin::blessed($first)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 663 | ▶ | return $first if eval { $first->isa(__PACKAGE__) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 298 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 40 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||