Skip to content

common: detect and prefer big cores on AArch64 hybrid CPU on linux #14532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kiwi142857
Copy link

@kiwi142857 kiwi142857 commented Jul 4, 2025

common : improve CPU detection on AArch64 hybrid systems

This PR enhances CPU detection logic for Linux on AArch64 platforms (excluding Android) by adding support for identifying big.LITTLE hybrid architectures. It introduces the following changes:

Features
•Hybrid CPU detection via is_hybrid_cpu(): determines whether the system uses heterogeneous cores by comparing max frequencies of CPUs.
•Efficiency core check with is_running_on_efficiency_core(): identifies whether the current thread is pinned to a lower-performance core.
•Big core counting logic in cpu_count_math_cpus(): identifies high-performance (“big”) cores based on frequency and returns their count.
•Logs total logical threads (n_threads) and big core detection results to aid diagnostics.

Motivation
Some AArch64 systems (e.g., ARMv8 CPUs like RK3588) include a mix of high-performance and power-efficient cores. Using all cores indiscriminately can lead to suboptimal performance. This patch aims to:
•Prefer high-performance cores when selecting threads for computation.
•Retain compatibility with existing systems by falling back to physical core count when necessary.

Testing
•Verified functional behavior on RK3588 running Ubuntu. From 3.44 tokens/s to 5.66 tokens/s for Qwen3-30bA3b model on CPU only.
•Confirmed llama-bench performance improvements when using only big cores.
•No changes to inference accuracy or perplexity.
•No impact on other architectures or platforms (code is gated behind aarch64 && linux && !ANDROID).

Adds logic to detect hybrid big.LITTLE CPU architectures on AArch64 Linux systems
by checking per-core max frequency. Only high-performance (big) cores are
counted for math-intensive workloads to improve performance on heterogeneous systems.

This change affects only AArch64 + Linux (non-Android) and has no impact
on other platforms.

Signed-off-by: kiwi <779490624@qq.com>
@kiwi142857 kiwi142857 changed the title [common]: detect and prefer big cores on AArch64 hybrid CPU on linux common: detect and prefer big cores on AArch64 hybrid CPU on linux Jul 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant