Module: OS::Linux::Hardware::CPU::ClassMethods Private

Extended by:
T::Helpers
Defined in:
extend/os/linux/hardware/cpu.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Instance Method Summary collapse

Instance Method Details

#amd_family(family, cpu_model) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'extend/os/linux/hardware/cpu.rb', line 96

def amd_family(family, cpu_model)
  case family
  when 0x06
    :amd_k7
  when 0x0f
    :amd_k8
  when 0x10
    :amd_k10
  when 0x11
    :amd_k8_k10_hybrid
  when 0x12
    :amd_k10_llano
  when 0x14
    :bobcat
  when 0x15
    :bulldozer
  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

#familyObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'extend/os/linux/hardware/cpu.rb', line 21

def family
  return :arm if arm?
  return :ppc if ppc?
  return :dunno unless intel?

  # See https://software.intel.com/en-us/articles/intel-architecture-and-processor-identification-with-cpuid-model-and-family-numbers
  # and https://github.com/llvm/llvm-project/blob/main/llvm/lib/TargetParser/Host.cpp
  # and https://en.wikipedia.org/wiki/List_of_Intel_CPU_microarchitectures#Roadmap
  vendor_id = cpuinfo[/^vendor_id\s*: (.*)/, 1]
  cpu_family = cpuinfo[/^cpu family\s*: ([0-9]+)/, 1].to_i
  cpu_model = cpuinfo[/^model\s*: ([0-9]+)/, 1].to_i
  unknown = :"unknown_0x#{cpu_family.to_s(16)}_0x#{cpu_model.to_s(16)}"
  case vendor_id
  when "GenuineIntel"
    intel_family(cpu_family, cpu_model)
  when "AuthenticAMD"
    amd_family(cpu_family, cpu_model)
  end || unknown
end

#featuresObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Compatibility with Mac method, which returns lowercase symbols instead of strings.



141
142
143
# File 'extend/os/linux/hardware/cpu.rb', line 141

def features
  @features ||= flags[1..].map(&:intern)
end

#flagsObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Supported CPU instructions



134
135
136
137
# File 'extend/os/linux/hardware/cpu.rb', line 134

def flags
  @flags ||= cpuinfo[/^(?:flags|Features)\s*: (.*)/, 1]&.split
  @flags ||= []
end

#intel_family(family, cpu_model) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'extend/os/linux/hardware/cpu.rb', line 41

def intel_family(family, cpu_model)
  case family
  when 0x06
    case cpu_model
    when 0x3a, 0x3e
      :ivybridge
    when 0x2a, 0x2d
      :sandybridge
    when 0x25, 0x2c, 0x2f
      :westmere
    when 0x1a, 0x1e, 0x1f, 0x2e
      :nehalem
    when 0x17, 0x1d
      :penryn
    when 0x0f, 0x16
      :merom
    when 0x0d
      :dothan
    when 0x1c, 0x26, 0x27, 0x35, 0x36
      :atom
    when 0x3c, 0x3f, 0x45, 0x46
      :haswell
    when 0x3d, 0x47, 0x4f, 0x56
      :broadwell
    when 0x4e, 0x5e, 0x8e, 0x9e, 0xa5, 0xa6
      :skylake
    when 0x66
      :cannonlake
    when 0x6a, 0x6c, 0x7d, 0x7e
      :icelake
    when 0xa7
      :rocketlake
    when 0x8c, 0x8d
      :tigerlake
    when 0x97, 0x9a, 0xbe, 0xb7, 0xba, 0xbf, 0xaa, 0xac
      :alderlake
    when 0xc5, 0xb5, 0xc6, 0xbd
      :arrowlake
    when 0xcc
      :pantherlake
    when 0xad, 0xae
      :graniterapids
    when 0xcf, 0x8f
      :sapphirerapids
    end
  when 0x0f
    case cpu_model
    when 0x06
      :presler
    when 0x03, 0x04
      :prescott
    end
  end
end

#optimization_flagsObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



13
14
15
16
17
18
19
# File 'extend/os/linux/hardware/cpu.rb', line 13

def optimization_flags
  @optimization_flags ||= begin
    flags = super.dup
    flags[:native] = arch_flag(Homebrew::EnvConfig.arch)
    flags
  end
end

#sse3?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


152
153
154
# File 'extend/os/linux/hardware/cpu.rb', line 152

def sse3?
  flags.include?("pni") || flags.include?("sse3")
end

#sse4?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


156
157
158
# File 'extend/os/linux/hardware/cpu.rb', line 156

def sse4?
  flags.include? "sse4_1"
end