Re: [eigen] Trouble using ARM NEON vector instructions on Android

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Thanks Gael, that makes sense. With the macro change, Vector4f addition does generate a vector instruction. I'll have to investigate further to see if I can actually do this safely on my target system.

Cheers,
Patrick


On Thu, Jul 11, 2013 at 10:28 PM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote:
Yes, this is because on ARM the stack was not aligned, and so we could
not guarantee the alignment of Vector4f-likes objects, and so the
vectorization on ARM is only enabled for dynamic size objects (e.g.,
VectorXd). Perhaps, this is not the case on recent systems. You can
try by changing line 53 in Eigen/src/Core/util/Macros.h to:

#if defined(__GNUC__) && !(defined(__i386__) || defined(__x86_64__) ||
defined(__powerpc__) || defined(__ppc__) || defined(__ia64__) ||
defined(__ARM_NEON__))

gael

On Fri, Jul 12, 2013 at 2:34 AM, Patrick Mihelich
<patrick.mihelich@xxxxxxxxx> wrote:
> Hi all,
>
> I am cross-compiling lots of Eigen code to ARM on Android, and for some
> reason I am not getting vector instructions.
>
> Versions:
>
> GCC: 4.6 standalone toolchain in Android NDK r8e, with flags including
> "-march=armv7-a -mfloat-abi=softfp -mfpu=neon"
> Eigen: I've tried 3.1.2, 3.2.0-beta1, and unstable dev.
>
> I've attached a trivial code snippet, which adds 4-element float vectors in
> 3 ways:
>
> vaddq_f32 intrinsic. Compiles to vadd.f32 instruction.
> Eigen's internal padd() on Packet4f's. Also compiles to vadd.32f.
> Adding Eigen::Vector4f's. Compiles to four fadds instructions!
>
> I've also attached the assembly output. Full command for generating it
> yourself (with NDK r8e installed) is at the top of the source file.
>
> I checked that EIGEN_VECTORIZE_NEON is defined, and
> Eigen::SimdInstructionSetsInUse() returns "ARM NEON".
>
> Any ideas? I know other people on this list are using Eigen on ARM. It looks
> like operator+ for Vector4f is not dispatching to the Packet4f
> specializations properly, but I'm not current enough on that infrastructure
> to understand why.
>
> Cheers,
> Patrick





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/