8

I have different machines running OSX 10.12 and 10.13, which use different processors. I am trying to get from terminal, a string that can show me which CPU instructions are supported by that machine; so I can use the appropriate software (some of the software require specific instructions to be present on the CPU, and if that CPU does not support them, the software will either work incorrectly or crash).

I did check querying the system profiler via terminal but I can get only the CPU type and model, not the CPU instruction set that it support; and if I would do this by hand, getting every CPU model and checking online, it would take hours.

  • CPU instructions are these set of instructions like MMX, AVX, SSE; that allow your CPU to operate in a certain way. With years, they are added to the base CPU instruction set, so modern CPU these days support more than 15 different instruction types.
rataplan
  • 210
  • I was in doubt if it was a better question for SO or for AD. If this is possible via standard terminal command, then AD is appropriate; but if I write to script or code with external libraries, then it may be more fitting for SO. – rataplan Nov 02 '18 at 22:21
  • Would you object to changing this with an edit to make this about how to proble one Mac and get CPU data? That removes the doubt if this is off topic. Also, what exactly in technical terms or practical terms is a “CPU instruction set”. Are you looking to tell if a Mac is intel or PPC? You’ll need to edit that for anyone to know how to answer. – bmike Nov 03 '18 at 00:13
  • Hi Mike, no objections here; I think it is appropriate to get the right lingo in the question, so someone won't just mark it as off topic. Thanks! – rataplan Nov 03 '18 at 04:37

2 Answers2

6

Enter

sysctl -a | grep cpu.feat

get a list like

machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC POPCNT AES PCID XSAVE OSXSAVE TSCTMR AVX1.0
machdep.cpu.feature_bits: 2286390173542120447

Alternatively (avoiding the grep and being a lot faster, which might help you run this often within a script)

sysctl machdep.cpu.features
sysctl machdep.cpu.features machdep.cpu.feature_bits

gives you just the list (or both) directly.

Or just use: sysctl machdep.cpu to get them all

Prado
  • 2,074
LаngLаngС
  • 8,279
  • machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C

    -- This is the output of a late 2014 MacMini running Catalina 10.15.7 system + 1,4 GHz Dual-Core Intel Core i5 processor + Intel HD Graphics 5000 1536 MB GPU

    – Murilo Perrone Feb 12 '22 at 01:57
4

Just to extend LangLangC's answer, for some reason, AVX2 does not appear in the machdep.cpu.features list but in a separate list: machdep.cpu.leaf7_features. To check all supported flags you can use:

/usr/sbin/sysctl -n machdep.cpu.features machdep.cpu.leaf7_features

Resulting in an output like

FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX SMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C
RDWRFSGS TSC_THREAD_OFFSET SGX BMI1 HLE AVX2 SMEP BMI2 ERMS INVPCID RTM FPU_CSDS MPX RDSEED ADX SMAP CLFSOPT IPT MDCLEAR TSXFA IBRS STIBP L1DF SSBD
Daniel
  • 193