dynamic CPU detection for libgcrypt assembly code?
Hans-Christoph Steiner
hans at guardianproject.info
Fri Dec 20 20:16:38 CET 2013
On 12/20/2013 02:06 PM, Jussi Kivilinna wrote:
> On 20.12.2013 18:09, Hans-Christoph Steiner wrote:
>>
>>
>> On 12/20/2013 10:04 AM, Jussi Kivilinna wrote:
>>> On 20.12.2013 16:44, Hans-Christoph Steiner wrote:
>>>>
>>>> Hey,
>>>>
>>>> Its great to see all that work being done adding assembly optimizations to
>>>> libgcrypt, it should make a really big difference on mobile devices. My
>>>> question is whether there is any kind of dynamic CPU detection that would
>>>> enable certain modules, like ARM NEON code? We'd like to include the NEON
>>>> code, but if the same binary won't work on armv7 chips that don't have NEON,
>>>> then its a showstopper for us.
>>>
>>> Libgcrypt has HW detection modules for x86 and ARM. On x86, cpuid instruction
>>> is used to detect CPU features. On ARM, detection is platform dependent since
>>> there is no cpuid instruction; with linux/arm platform NEON detection is done through '/proc/self/auxv':AT_HWCAP. On non-linux/arm platform, NEON implementations can be enabled by compiling binary for ARMv7/NEON (libgcrypt notices that compiler has __ARM_NEON__ macro predefined).
>>
>> So Android is Linux but not GNU or UNIX. Sounds like /proc/self/auxv should
>> work for Android then, in my quick survey of one Android device, it does have
>> /proc/self/auxv.
>
> Well, after little bit of research, I found out that Android blocks read access
> to /proc/self/auxv. Instead there is another API for cpu features:
> http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
>
> For proper NEON support on Android, libgcrypt should use this API for arm hw
> detection.
> e
> -Jussi
Ok, sounds not too bad. I won't have time to work on this particular issue in
the near future, but I added it to our issue tracker:
https://dev.guardianproject.info/issues/2807
If someone implements it, I can test it. Indeed, our new automatic nightly
build of GnuPG for Android will run some of the tests on it automatically :).
.hc
--
PGP fingerprint: 5E61 C878 0F86 295C E17D 8677 9F0F E587 374B BE81
More information about the Gnupg-devel
mailing list