Archspec

0.2.5 · active · verified Thu Apr 16

Archspec is a Python library designed to provide a standard set of human-understandable labels for system architectures, primarily focusing on CPU microarchitectures. It offers APIs to detect, query, and compare different CPU types. The project originated from Spack and is under active development. The current version is 0.2.5. While it does not follow a strict release cadence, its update history, including a significant release in October 2024, indicates ongoing maintenance and development.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart code snippet demonstrates how to detect the host CPU microarchitecture using `archspec.cpu.detect.host()` and print its name. It also includes basic error handling for unsupported architectures.

import archspec.cpu.detect

try:
    host_cpu = archspec.cpu.detect.host()
    if host_cpu:
        print(f"Detected host CPU microarchitecture: {host_cpu.name}")
        # Example of accessing properties
        # print(f"Vendor: {host_cpu.vendor}")
        # print(f"Ancestors: {[a.name for a in host_cpu.ancestors]}")
    else:
        print("Could not detect host CPU microarchitecture.")
        print(f"Reason: {archspec.cpu.detect.why_not('native')}")
except archspec.cpu.UnsupportedMicroarchitecture:
    print("Host microarchitecture is not recognized or supported by archspec.")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →