Пример #1
0
def pcid() -> str:
    import cpuid
    from functools import reduce

    regs = cpuid.CPUID()(1)

    return str(reduce(lambda x, y: x ^ y, [regs[0], regs[2], regs[3]]))
Пример #2
0
def getCpuidRegs(fn):
    if args.libcpuid:
        regs = (ctypes.c_uint32 * 4)(fn, 0, 0, 0)
        cpuid(regs)
    else:
        regs = cpuid.CPUID()(fn)
    return regs
Пример #3
0
def getCpuidCacheInfo():
   if not hasattr(getCpuidCacheInfo, 'cpuidCacheInfo'):
      cpu = cpuid.CPUID()
      log.debug(cpuid.get_basic_info(cpu))
      getCpuidCacheInfo.cpuidCacheInfo = cpuid.get_cache_info(cpu)

      if not len(set(c['lineSize'] for c in getCpuidCacheInfo.cpuidCacheInfo.values())) == 1:
         raise ValueError('All line sizes must be the same')
   return getCpuidCacheInfo.cpuidCacheInfo
Пример #4
0
def getCPUVendor():
    if not hasattr(getCPUVendor, 'vendor'):
        cpu = cpuid.CPUID()
        getCPUVendor.vendor = cpuid.cpu_vendor(cpu)
    return getCPUVendor.vendor
Пример #5
0
def getArch():
    if not hasattr(getArch, 'arch'):
        cpu = cpuid.CPUID()
        getArch.arch = cpuid.micro_arch(cpu)
    return getArch.arch
Пример #6
0
def getPkgType():
    eax, ebx, ecx, edx = cpuid.CPUID()(0x80000001)
    type = ebx >> 28
    print("Package Type: %01d" % type)
    return type
Пример #7
0
def getCpuid():
    eax, ebx, ecx, edx = cpuid.CPUID()(0x00000001)
    print("CPUID: %08X" % eax)
    return eax
Пример #8
0
@param {reg_idx} idx of [%eax, %ebx, %ecx, %edx], 0-based
@param {bit} bit of reg selected by {reg_idx}, 0-based
"""


def is_set(cpu, leaf, subleaf, reg_idx, bit):
    regs = cpu(leaf, subleaf)

    if (1 << bit) & regs[reg_idx]:
        return "Yes"
    else:
        return "--"


if __name__ == "__main__":
    cpu = cpuid.CPUID()

    print("Vendor ID : %s" % cpu_vendor(cpu))
    print("CPU name  : %s" % cpu_name(cpu))
    print()
    print("Vector instructions supported:")
    print("SSE       : %s" % is_set(cpu, 1, 0, 3, 25))
    print("SSE2      : %s" % is_set(cpu, 1, 0, 3, 26))
    print("SSE3      : %s" % is_set(cpu, 1, 0, 2, 0))
    print("SSSE3     : %s" % is_set(cpu, 1, 0, 2, 9))
    print("SSE4.1    : %s" % is_set(cpu, 1, 0, 2, 19))
    print("SSE4.2    : %s" % is_set(cpu, 1, 0, 2, 20))
    print("SSE4a     : %s" % is_set(cpu, 0x80000001, 0, 2, 6))
    print("AVX       : %s" % is_set(cpu, 1, 0, 2, 28))
    print("AVX2      : %s" % is_set(cpu, 7, 0, 1, 5))
    print("BMI1      : %s" % is_set(cpu, 7, 0, 1, 3))
Пример #9
0
#!/bin/python3

import os
import sys
import struct
from time import sleep

# Hack to import local cpuid.py without installing it
sys.path.append(os.path.abspath("."))
import cpuid

_cpuid = cpuid.CPUID()

FS_PATH = '/sys/kernel/ryzen_smu_drv/'
SMN_PATH = FS_PATH + 'smn'
VER_PATH = FS_PATH + 'version'
PM_PATH = FS_PATH + 'pm_table'
PMT_PATH = FS_PATH + 'pm_table_version'
CN_PATH = FS_PATH + 'codename'

PM_TABLE_FP = False


def is_root():
    return os.getenv("SUDO_USER") is not None or os.geteuid() == 0


def driver_loaded():
    return os.path.isfile(VER_PATH)

Пример #10
0
def has_sse42():
    cpu = cpuid.CPUID()
    regs = cpu(1)
    return bool((1 << 20) & regs[2])