Skip to content

Conversation

@naoNao89
Copy link
Contributor

Adds shared CPU feature detection to prevent code duplication. Detects AVX512/AVX2/PCLMUL/SSE2/ASIMD, parses GLIBC_TUNABLES, provides SIMD policy decisions.

Unblocks #9088 (cksum) and #9144 (wc) both can now use uucore::hardware instead of duplicate implementations.

@naoNao89 naoNao89 force-pushed the feat/uucore-shared-hardware-detection branch from 4a2c1ae to 999f40f Compare November 14, 2025 18:13
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

Copy link
Collaborator

@RenjiSann RenjiSann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice !

Small nitpick for the introduced cfg-if dependency, which I think is unnecessary, but a good patch otherwise ^^

@naoNao89 naoNao89 force-pushed the feat/uucore-shared-hardware-detection branch from 999f40f to 33b7daa Compare November 15, 2025 00:51
Add shared CPU hardware capability detection in uucore to prevent
code duplication across utilities. This provides a unified interface
for detecting CPU features (AVX512, AVX2, PCLMUL, SSE2, ASIMD) and
respecting GLIBC_TUNABLES environment variable.

This unblocks PR uutils#9088 (cksum --debug) and PR uutils#9144 (wc --debug) by
providing a common implementation that both utilities can use.

Features:
- CPU feature detection with caching (singleton pattern)
- GLIBC_TUNABLES parsing for hwcaps restrictions
- Cross-platform support (x86/x86_64, aarch64)
- Comprehensive test coverage
- Zero-cost abstractions using std::arch

Implementation details:
- Uses std::arch feature detection (no external deps for detection)
- Adds cfg-if dependency for conditional compilation
- Feature-gated behind "hardware" feature flag
- Android excluded (no CPUID access in sandboxed environment)

Related: uutils#9088, uutils#9144
@naoNao89 naoNao89 force-pushed the feat/uucore-shared-hardware-detection branch from 33b7daa to 07a1f05 Compare November 15, 2025 01:03
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@naoNao89
Copy link
Contributor Author

test_tail::test_follow_with_pid not related to hardware detection

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.

2 participants