pytorch/cpuinfo

CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)

What it solves

It provides a cross-platform way to detect detailed hardware information about the host CPU, which is essential for performance optimization. It allows developers to identify the specific microarchitecture, supported instruction sets, and cache hierarchy of the processor to write code that leverages hardware-specific optimizations.

How it works

The library uses a variety of platform-specific methods to extract CPU data, including CPUID leaves on x86, /proc/cpuinfo and getauxval on ARM/Linux, and system APIs like GetLogicalProcessorInformationEx on Windows. It handles the complexities of different operating systems (Linux, Windows, macOS, Android, iOS, FreeBSD) and architectures (x86, x86-64, ARM, ARM64) to provide a unified C/C++ interface.

Who it’s for

Systems programmers and performance engineers who need to detect CPU features at runtime to dispatch to optimized kernels or handle heterogeneous core configurations (like ARM big.LITTLE).

Highlights

  • Cross-platform support: Works across major OSs and multiple CPU architectures.
  • Detailed hardware detection: Identifies SoC name, microarchitecture, cache sizes, and topology.
  • Instruction set detection: Detects support for AVX512 (x86) and ARMv8.3 extensions.
  • Production-ready: Thread-safe, no memory allocation after initialization, and includes work-arounds for hardware and OS kernel bugs.

Related

  • Project
  • Project
  • Project
  • Project
  • Project