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

View File

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