MCPcopy Create free account
hub / github.com/pydata/numexpr / get_processor_brand

Method get_processor_brand

numexpr3/cpuinfo.py:961–1012  ·  view source on GitHub ↗
(self, max_extension_support)

Source from the content-addressed store, hash-verified

959
960 # http://en.wikipedia.org/wiki/CPUID#EAX.3D80000002h.2C80000003h.2C80000004h:_Processor_Brand_String
961 def get_processor_brand(self, max_extension_support):
962 processor_brand = ""
963
964 # Processor brand string
965 if max_extension_support >= 0x80000004:
966 instructions = [
967 b"\xB8\x02\x00\x00\x80", # mov ax,0x80000002
968 b"\xB8\x03\x00\x00\x80", # mov ax,0x80000003
969 b"\xB8\x04\x00\x00\x80" # mov ax,0x80000004
970 ]
971 for instruction in instructions:
972 # EAX
973 eax = self._run_asm(
974 instruction, # mov ax,0x8000000?
975 b"\x0f\xa2" # cpuid
976 b"\x89\xC0" # mov ax,ax
977 b"\xC3" # ret
978 )
979
980 # EBX
981 ebx = self._run_asm(
982 instruction, # mov ax,0x8000000?
983 b"\x0f\xa2" # cpuid
984 b"\x89\xD8" # mov ax,bx
985 b"\xC3" # ret
986 )
987
988 # ECX
989 ecx = self._run_asm(
990 instruction, # mov ax,0x8000000?
991 b"\x0f\xa2" # cpuid
992 b"\x89\xC8" # mov ax,cx
993 b"\xC3" # ret
994 )
995
996 # EDX
997 edx = self._run_asm(
998 instruction, # mov ax,0x8000000?
999 b"\x0f\xa2" # cpuid
1000 b"\x89\xD0" # mov ax,dx
1001 b"\xC3" # ret
1002 )
1003
1004 # Combine each of the 4 bytes in each register into the string
1005 for reg in [eax, ebx, ecx, edx]:
1006 for n in [0, 8, 16, 24]:
1007 processor_brand += chr((reg >> n) & 0xFF)
1008
1009 # Strip off any trailing NULL terminators and white space
1010 processor_brand = processor_brand.strip("\0").strip()
1011
1012 return processor_brand
1013
1014 # http://en.wikipedia.org/wiki/CPUID#EAX.3D80000006h:_Extended_L2_Cache_Features
1015 def get_cache(self, max_extension_support):

Callers 1

Calls 1

_run_asmMethod · 0.95

Tested by

no test coverage detected