Merge pull request #18748 from alebcay/linux-amd-cpus

This commit is contained in:
Carlo Cabrera 2024-11-10 17:18:17 +08:00 committed by GitHub
commit 40f4ab2546
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 4 deletions

View File

@ -28,7 +28,7 @@ module Hardware
when "GenuineIntel"
intel_family(cpu_family, cpu_model)
when "AuthenticAMD"
amd_family(cpu_family)
amd_family(cpu_family, cpu_model)
end || unknown
end
@ -87,7 +87,7 @@ module Hardware
end
end
def amd_family(family)
def amd_family(family, cpu_model)
case family
when 0x06
:amd_k7
@ -106,9 +106,21 @@ module Hardware
when 0x16
:jaguar
when 0x17
case cpu_model
when 0x10..0x2f
:zen
when 0x30..0x3f, 0x47, 0x60..0x7f, 0x84..0x87, 0x90..0xaf
:zen2
end
when 0x19
case cpu_model
when ..0x0f, 0x20..0x5f
:zen3
when 0x10..0x1f, 0x60..0x7f, 0xa0..0xaf
:zen4
end
when 0x1a
:zen5
end
end

View File

@ -21,6 +21,7 @@ RSpec.describe Hardware::CPU do
describe "::family" do
let(:cpu_families) do
[
:alderlake,
:amd_k7,
:amd_k8,
:amd_k8_k10_hybrid,
@ -38,6 +39,7 @@ RSpec.describe Hardware::CPU do
:arm_twister,
:arm_typhoon,
:arm_vortex_tempest,
:arrowlake,
:atom,
:bobcat,
:broadwell,
@ -47,6 +49,7 @@ RSpec.describe Hardware::CPU do
:core,
:core2,
:dothan,
:graniterapids,
:haswell,
:icelake,
:ivybridge,
@ -54,15 +57,22 @@ RSpec.describe Hardware::CPU do
:kabylake,
:merom,
:nehalem,
:pantherlake,
:penryn,
:ppc,
:prescott,
:presler,
:rocketlake,
:sandybridge,
:sapphirerapids,
:skylake,
:tigerlake,
:westmere,
:zen,
:zen2,
:zen3,
:zen4,
:zen5,
:dunno,
]
end