0

I'm using a libjpeg-turbo port for Android. It's not much different from the base jpeg-turbo in terms of source code: http://git.linaro.org/gitweb?p=people/tomgall/libjpeg-turbo/libjpeg-turbo.git;a=shortlog;h=refs/heads/android

There is a module (static library) consisting of 2 cpu features-dependent files: jsimd_arm_neon.S and jsimd_arm.c. I want to compile jpeg-turbo with NEON support, I must define __ARM_HAVE_NEON and compile this module with -march=armv7-a -mfpu=neon. I want the library to run on older hardware with no Neon support (like Tegra 2), I should remove neon compiler flag and undef __ARM_HAVE_NEON.

My question is: how to compile it so that neon or non-neon path can be selected at runtime without SIGILL on non-neon hardware? I know how to check for NEON at runtime, but I don't know how to modify libjpeg-turbo and organize libraries.

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • Build two different versions of the same library then load the correct one at runtime. – auselen Dec 13 '13 at 13:30
  • @auselen: that's an obvious solution, but I wanted to avoid loading library dynamically (or building it to .so, for that matter, but it's not such a big deal). – Violet Giraffe Dec 13 '13 at 13:37
  • I'd simply ditch devices without neon : ARMv6 is way too old. Even if someone is still using an Android phone with ARMv6, he hardly downloads anything. Tegra2 isn't that old, but too minor that ditching it would hurt that much. – Jake 'Alquimista' LEE Dec 24 '13 at 05:54
  • @Jake'Alquimista'LEE: I don't think Tegra 2 is too minor. There are a lot of Tegra 2 devices out there. – Violet Giraffe Dec 24 '13 at 07:45
  • Were you able to get a solution for this problem? I am facing the same problem too. – rajaramyadhav Aug 15 '14 at 18:29
  • @rajaramyadhav: yes, I have implemented dynamic code path selection at runtime. See: http://stackoverflow.com/a/20697814/634821 – Violet Giraffe Aug 15 '14 at 19:38

1 Answers1

1

An old question but I'll add to it anyway just in case. Someone did go into detail and one of the issues was dynamically selecting NEON. It is explained here: https://stackoverflow.com/a/20697814/712413.

The relevant section is item 4 to modify some lines in the init_simd() method.

Community
  • 1
  • 1
Bruce
  • 306
  • 2
  • 7