-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[C++] Use existing library for CPU detection #45331
Comments
Looking at https://github.com/google/cpu_features/blob/main/include/cpuinfo_aarch64.h , it's not obvious to me how we could get the supported SVE vector widths. Do you have any idea @cyb70289 ? |
Edit: apparently there's an intrinsic to get the vector width: https://lemire.me/blog/2022/11/29/how-big-are-your-sve-registers-aws-graviton/ |
+1 |
1 similar comment
+1 |
The library itself looks good. My main concern is the slowdown of its release cadence: https://github.com/google/cpu_features/releases |
Hmm, that's a good point. Maintenance also seems to have slowed down a bit: https://github.com/google/cpu_features/graphs/contributors?from=20%2F01%2F2024 |
There's also https://github.com/anrieff/libcpuid , which only supports x86 and ARM but exposes a lot of information. |
And by the way, xsimd has a more limited functionality for CPU feature detection: https://xsimd.readthedocs.io/en/latest/api/arch.html . It only supports x86 and ARM, does not offer detailed CPU information, does not expose things like BMI2 etc. |
For completeness, you might be interested in https://github.com/archspec/archspec - it supports x64, aarch, ppc & risc, plus a lot of meta-information about the (partial) inclusion ordering of the various CPUs in terms of feature sets. I think it doesn't have a C/C++ API though, so this is probably a long shot (slow to call python from C++), but OTOH, querying CPU features is not a common occurrence (once per session...?) and could be cached. Numpy does it the other way around, detecting individual CPU features, rather than processor models, with a result à la:
It's implemented in C, but I don't think it has a public API. |
@h-vetinari Well, we don't want the core Arrow C++ library to depend on the existence of a Python interpreter and Python libraries. As for the NumPy C code, since it's internal it's probably not trivial to vendor, and I suppose its APIs have no stability guarantee either. |
Yeah, I understand. That's why I said "for completeness". :) |
Describe the enhancement requested
We currently use our own home-grown module for detecting CPU features, but it mainly supports x86, which implies that for now we cannot do dynamic dispatch on non-x86 CPUs (for example ARM where we might want to detect ARM or even SVE support at runtime).
We could probably reuse https://github.com/google/cpu_features instead. It doesn't seem to have any dependencies, and could be bundled as a private static library.
This was already proposed years ago as #16715
Component(s)
C++
The text was updated successfully, but these errors were encountered: