workhorsy / py-cpuinfo

A module for getting CPU info with pure Python
MIT License
312 stars 59 forks source link

get_cpu_info()['flags'] return values varies call-to-call on OSX #135

Closed jhallard closed 4 years ago

jhallard commented 5 years ago

In your bug report please include:


I'm seeing the following behavior when trying to check for CPU flags on my MacBook

>>> import cpuinfo
>>> len(cpuinfo.get_cpu_info()['flags'])
61
>>> len(cpuinfo.get_cpu_info()['flags'])
61
>>> len(cpuinfo.get_cpu_info()['flags'])
74
>>> len(cpuinfo.get_cpu_info()['flags'])
74
>>> len(cpuinfo.get_cpu_info()['flags'])
61
>>> len(cpuinfo.get_cpu_info()['flags'])
61
>>> len(cpuinfo.get_cpu_info()['flags'])
61
>>> len(cpuinfo.get_cpu_info()['flags'])
61
>>>

This is the output of the 61 flags

['acpi',
 'aes',
 'apic',
 'avx1.0',
 'clfsh',
 'cmov',
 'cx16',
 'cx8',
 'de',
 'ds',
 'dscpl',
 'dtes64',
 'em64t',
 'erms',
 'est',
 'f16c',
 'fpu',
 'fxsr',
 'htt',
 'lahf',
 'mca',
 'mce',
 'mmx',
 'mon',
 'msr',
 'mtrr',
 'osxsave',
 'pae',
 'pat',
 'pbe',
 'pcid',
 'pclmulqdq',
 'pdcm',
 'pge',
 'popcnt',
 'pse',
 'pse36',
 'rdrand',
 'rdtscp',
 'rdwrfsgs',
 'sep',
 'smep',
 'ss',
 'sse',
 'sse2',
 'sse3',
 'sse4.1',
 'sse4.2',
 'ssse3',
 'syscall',
 'tm',
 'tm2',
 'tpr',
 'tsc',
 'tsci',
 'tsctmr',
 'vme',
 'vmx',
 'x2apic',
 'xd',
 'xsave']

this is the output of the 74 flags

['acpi',
 'aes',
 'apic',
 'avx',
 'avx1.0',
 'clflush',
 'clfsh',
 'cmov',
 'cx16',
 'cx8',
 'de',
 'ds',
 'ds_cpl',
 'dscpl',
 'dtes64',
 'dts',
 'em64t',
 'erms',
 'est',
 'f16c',
 'fpu',
 'fxsr',
 'ht',
 'htt',
 'lahf',
 'lahf_lm',
 'mca',
 'mce',
 'mmx',
 'mon',
 'monitor',
 'msr',
 'mtrr',
 'osxsave',
 'pae',
 'pat',
 'pbe',
 'pcid',
 'pclmulqdq',
 'pdcm',
 'pge',
 'pni',
 'popcnt',
 'pse',
 'pse36',
 'rdrand',
 'rdrnd',
 'rdtscp',
 'rdwrfsgs',
 'sep',
 'smep',
 'ss',
 'sse',
 'sse2',
 'sse3',
 'sse4.1',
 'sse4.2',
 'sse4_1',
 'sse4_2',
 'ssse3',
 'syscall',
 'tm',
 'tm2',
 'tpr',
 'tsc',
 'tscdeadline',
 'tsci',
 'tsctmr',
 'vme',
 'vmx',
 'x2apic',
 'xd',
 'xsave',
 'xtpr']

the one that really bothers me is that sometimes "avx" is included and sometimes it is missing, while "avx1.0" is always included

workhorsy commented 5 years ago

It looks like the same bug as #133. I'm still working on a new way to see why this is happening, but have been very busy lately. Any help with this would be appreciated.

jhallard commented 5 years ago

I might be able to help out a bit - one thing that is confusing to me is that I'm getting the flag avx1.0 as output from get_cpu_info['flags'], but I don't see avx1.0 as a string anywhere in this repo? I'm not sure where that would be generated from.

jhallard commented 5 years ago

I did some more research and found this project: https://github.com/Mysticial/FeatureDetector/blob/master/src/x86/cpu_x86.cpp

I built and ran the program 1000 times and it always reported AVX support as true, so I do believe that the issue exists only in this repo and is not some underlying OS error.

workhorsy commented 4 years ago

Closing this as it is a duplicate. See #133 for the original.