Repository navigation
Fix a getauxval comment and expand the Krait idiv workaround - #206
Conversation
getauxval is available in Android starting with API 18, not 20. The comment about __ANDROID_API__ appears to have been copied from the NDK's cpufeatures, which always uses dlopen/dlsym and doesn't assume it can directly call getauxval, even if __ANDROID_API__ is new enough. With this project, though, when __ANDROID_API__ is 18 or up, the CMakeLists.txt file would detect that getauxval is available and define HAVE_STRONG_GETAUXVAL.
327045b to
da2f9a9
Compare
|
I'm wondering if the check should be more conservative. Maybe this instead: // Some Qualcomm Krait kernels forget to report IDIV support.
// https://github.com/torvalds/linux/commit/120ecfafabec382c4feb79ff159ef42a39b6d33b
if (info->implementer == 0x51 && info->architecture == 7 &&
(info->part == 0x4d || info->part == 0x6f)) {
info->features.idiva = true;
info->features.idivt = true;
}I can't find good documentation for the (0x4d or 0x6f), but I see a few places:
It looks like the only Krait part numbers are 0x4d (dual-core) and 0x6f (quad-core). |
I think it would be good if we switched to this implementation. I also searched everywhere but didn't find anything new, since VFPv4 is an optional extension, I would rather not specify the IDIV flag for everyone with part number in the range 0x40 to 0x7F, but only specify 0x4d and 0x6f, what do you think? |
Some Qualcomm Krait CPUs have IDIV support but the kernel doesn't report it. Previously, this code looked for two CPUs: - 0x510006F2 (0x51/'Q', variant 0, part 0x06f, rev 2) - 0x510006F3 (0x51/'Q', variant 0, part 0x06f, rev 3) This check misses my 2013 Nexus 7 device, which has this CPU ID: - 0x511006f0 (0x51/'Q', variant 1, part 0x06f, rev 0) My Nexus 7 device doesn't report idiv through AT_HWCAP or through /proc/cpuinfo (AT_HWCAP is 0x1b0d7). Expand the check to anything with: - implementer 0x51 - architecture 7 - part 0x4d or 0x6f Part 0x4d appears to be a dual-core Krait (e.g. see https://crbug.com/341598#c43). This new matching behavior is a subset of what the upstream kernel does (patch[1] contributed by CodeAurora), and also closely matches the behavior of pytorch/cpuinfo. [1] torvalds/linux@120ecfa
Yeah, that seems better to me. I updated the patch to do that. |
|
Is this change OK to merge now? |
|
@rprichard I have no objection to your changes, @gchatelet could you take a look? |
|
I completely missed this PR, my apologies. |
|
And thx a lot @rprichard for the PR and @toor1245 for the review. |
The next NDK (r24) raises the minimum supported Android API from 16 to 19. That's new enough that all supported targets with NDK r24 have the getauxval function. i.e. Maybe google/cpu_features can drop support for dlopen/dlsym of getauxval at some point.
I noticed the lack of idiv support on my 2013 Nexus 7 device, because I used that device to run the NDK's tests. One of the tests verifies that the idiv support reported by the NDK cpu-features library matches what the device actually supports. Both the NDK's cpu-features and this cpu_features library only recognize the 0x510006f2 and 0x510006f3 CPU IDs for this workaround.
See android/ndk#1605.