How to use the numexpr.cpuinfo.CPUInfoBase function in numexpr

To help you get started, weā€™ve selected a few numexpr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pydata / numexpr / numexpr / cpuinfo.py View on Github external
def _getNCPUs(self):
        return 1

    def __get_nbits(self):
        abits = platform.architecture()[0]
        nbits = re.compile('(\d+)bit').search(abits).group(1)
        return nbits

    def _is_32bit(self):
        return self.__get_nbits() == '32'

    def _is_64bit(self):
        return self.__get_nbits() == '64'


class LinuxCPUInfo(CPUInfoBase):
    info = None

    def __init__(self):
        if self.info is not None:
            return
        info = [{}]
        ok, output = getoutput(['uname', '-m'])
        if ok:
            info[0]['uname_m'] = output.strip()
        try:
            fo = open('/proc/cpuinfo')
        except EnvironmentError as e:
            warnings.warn(str(e), UserWarning)
        else:
            for line in fo:
                name_value = [s.strip() for s in line.split(':', 1)]
github pydata / numexpr / numexpr / cpuinfo.py View on Github external
cpuinfo = LinuxCPUInfo
elif sys.platform.startswith('irix'):
    cpuinfo = IRIXCPUInfo
elif sys.platform == 'darwin':
    cpuinfo = DarwinCPUInfo
elif sys.platform[0:6] == 'netbsd':
    cpuinfo = NetBSDCPUInfo
elif sys.platform.startswith('sunos'):
    cpuinfo = SunOSCPUInfo
elif sys.platform.startswith('win32'):
    cpuinfo = Win32CPUInfo
elif sys.platform.startswith('cygwin'):
    cpuinfo = LinuxCPUInfo
#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.
else:
    cpuinfo = CPUInfoBase

cpu = cpuinfo()

if __name__ == "__main__":

    cpu.is_blaa()
    cpu.is_Intel()
    cpu.is_Alpha()

    info = []
    for name in dir(cpuinfo):
        if name[0] == '_' and name[1] != '_':
            r = getattr(cpu, name[1:])()
            if r:
                if r != 1:
                    info.append('%s=%s' % (name[1:], r))
github pydata / numexpr / numexpr / cpuinfo.py View on Github external
return self.__machine(28)

    def _is_IP30(self):
        return self.__machine(30)

    def _is_IP32(self):
        return self.__machine(32)

    def _is_IP32_5k(self):
        return self.__machine(32) and self._is_r5000()

    def _is_IP32_10k(self):
        return self.__machine(32) and self._is_r10000()


class DarwinCPUInfo(CPUInfoBase):
    info = None

    def __init__(self):
        if self.info is not None:
            return
        info = command_info(arch='arch',
                            machine='machine')
        info['sysctl_hw'] = key_value_from_command(['sysctl', 'hw'], sep='=')
        self.__class__.info = info

    def _not_impl(self): pass

    def _getNCPUs(self):
        return int(self.info['sysctl_hw'].get('hw.ncpu', 1))

    def _is_Power_Macintosh(self):
github pydata / numexpr / numexpr / cpuinfo.py View on Github external
def _is_ppc750(self): return self.__machine(750)

    def _is_ppc403(self): return self.__machine(403)

    def _is_ppc505(self): return self.__machine(505)

    def _is_ppc801(self): return self.__machine(801)

    def _is_ppc821(self): return self.__machine(821)

    def _is_ppc823(self): return self.__machine(823)

    def _is_ppc860(self): return self.__machine(860)

class NetBSDCPUInfo(CPUInfoBase):
	info = None

	def __init__(self):
		if self.info is not None:
			return
		info = {}
		info['sysctl_hw'] = key_value_from_command(['sysctl', 'hw'], sep='=')
		info['arch'] = info['sysctl_hw'].get('hw.machine_arch', 1)
		info['machine'] = info['sysctl_hw'].get('hw.machine', 1)
		self.__class__.info = info

	def _not_impl(self): pass

	def _getNCPUs(self):
		return int(self.info['sysctl_hw'].get('hw.ncpu', 1))
github pydata / numexpr / numexpr / cpuinfo.py View on Github external
return re.match(r'.*?\bsse2\b', self.info[0]['flags']) is not None

    def _has_sse3(self):
        return re.match(r'.*?\bpni\b', self.info[0]['flags']) is not None

    def _has_ssse3(self):
        return re.match(r'.*?\bssse3\b', self.info[0]['flags']) is not None

    def _has_3dnow(self):
        return re.match(r'.*?\b3dnow\b', self.info[0]['flags']) is not None

    def _has_3dnowext(self):
        return re.match(r'.*?\b3dnowext\b', self.info[0]['flags']) is not None


class IRIXCPUInfo(CPUInfoBase):
    info = None

    def __init__(self):
        if self.info is not None:
            return
        info = key_value_from_command('sysconf', sep=' ',
                                      successful_status=(0, 1))
        self.__class__.info = info

    def _not_impl(self):
        pass

    def _is_singleCPU(self):
        return self.info.get('NUM_PROCESSORS') == '1'

    def _getNCPUs(self):
github pydata / numexpr / numexpr / cpuinfo.py View on Github external
def _not_impl(self): pass

	def _getNCPUs(self):
		return int(self.info['sysctl_hw'].get('hw.ncpu', 1))

	def _is_Intel(self):
		if self.info['sysctl_hw'].get('hw.model', "")[0:5] == 'Intel':
			return True
		return False

	def _is_AMD(self):
		if self.info['sysctl_hw'].get('hw.model', "")[0:3] == 'AMD':
			return True
		return False

class SunOSCPUInfo(CPUInfoBase):
    info = None

    def __init__(self):
        if self.info is not None:
            return
        info = command_info(arch='arch',
                            mach='mach',
                            uname_i=['uname', '-i'],
                            isainfo_b=['isainfo', '-b'],
                            isainfo_n=['isainfo', '-n'],
        )
        info['uname_X'] = key_value_from_command(['uname', '-X'], sep='=')
        for line in command_by_line(['psrinfo', '-v', '0']):
            m = re.match(r'\s*The (?P<p>[\w\d]+) processor operates at', line)
            if m:
                info['processor'] = m.group('p')</p>
github pydata / numexpr / numexpr / cpuinfo.py View on Github external
return re.match(r'.*Sun-Fire', self.info['uname_i']) is not None

    def _is_ultra(self):
        return re.match(r'.*Ultra', self.info['uname_i']) is not None

    def _is_cpusparcv7(self):
        return self.info['processor'] == 'sparcv7'

    def _is_cpusparcv8(self):
        return self.info['processor'] == 'sparcv8'

    def _is_cpusparcv9(self):
        return self.info['processor'] == 'sparcv9'


class Win32CPUInfo(CPUInfoBase):
    info = None
    pkey = r"HARDWARE\DESCRIPTION\System\CentralProcessor"
    # XXX: what does the value of
    #   HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0
    # mean?

    def __init__(self):
        try:
            import _winreg
        except ImportError:  # Python 3
            import winreg as _winreg

        if self.info is not None:
            return
        info = []
        try: