Skip to content
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

Similarities to other CPU feature projects (deduplicate?) #29

Open
captain5050 opened this issue Feb 21, 2018 · 4 comments
Open

Similarities to other CPU feature projects (deduplicate?) #29

captain5050 opened this issue Feb 21, 2018 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@captain5050
Copy link

ART on Android works around quirks/bugs in /proc/cpuinfo and aux vector, has support for cross compilation, detection of features via C preprocessor, CPUID instructions, undefined instruction exceptions, supports MIPS, ARM, Intel 32 and 64, etc.:
https://android.googlesource.com/platform/art/+/master/runtime/arch/instruction_set_features.h#36
Android NDK has something simple:
https://developer.android.com/ndk/guides/cpu-features.html
V8 CPU feature detection:
https://github.com/v8/v8/blob/master/src/base/cpu.h#L32

As there are OS/CPU bugs that cause issues standardizing on 1 library makes sense. As an author of the ART code I'm have a bias :-)

@gchatelet
Copy link
Collaborator

Thx for reaching out @captain5050 !
cpu_features is literally born from the fact that many libraries are coding their own routine (libwebp, libyuv, android NDK, OpenCV to name a few). It seems simple enough at first sight but you learn along the way how hard it is to get right.
This library has been designed with the author of the NDK's one you're referring to, the end goal was to replace it entirely with this library. It supports all of what you described for ART except the "undefined instruction exceptions" (additions welcome!). We also have a list of fixes for corrupted kernels and fallback for auxval via getauxval, /proc/self/auxval, /proc/cpuinfo.
Last but not least, this library is usable outside the Android ecosystem.

@gchatelet gchatelet added the question Further information is requested label Feb 22, 2018
@doctaweeks
Copy link

cpuid2cpuflags, although built for a specific use case, shares some similarities as well.

@psteinb
Copy link

psteinb commented May 22, 2018

for x86, I can throw my hat into the ring.

From my benchmarks, I saw that I am a tick faster than cpu_features when detecting sse4_1 (7x):

 Run on (4 X 3600 MHz CPU s)
2018-05-14 17:37:29
***WARNING*** CPU scaling is enabled, the benchmark real time ...
--------------------------------------------------------------
Benchmark                       Time           CPU Iterations
--------------------------------------------------------------
BM_compass_sse4_1              31 ns         31 ns   22705074
BM_cpu_features_sse4_1        242 ns        241 ns    2870098

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants
@gchatelet @doctaweeks @psteinb @captain5050 and others