This forum has been archived. All content is frozen. Please use KDE Discuss instead.

issue with arm neon instructions and android build

Tags: None
(comma "," separated)
jsanz
Registered Member
Posts
9
Karma
0
OS
Hi,

I having problems porting some applications that use Eigen to Android when I activate neon instructions. I have seen that this bug http://eigen.tuxfamily.org/bz/show_bug.cgi?id=313 is still open and I do not know if it is related.

The thing is that running the eigen test (3.0.1 version) in linux (Ubuntu 10.10) in the same ARM device (http://pandaboard.org/) but using the the same gcc flags I am using for Android compilation in the ndk, some of the tests fail.

For instance compiling the test "triangular_4" with the next command :

Code: Select all
/usr/bin/c++   -DEIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS -fPIC -DANDROID -Wno-psabi -fsigned-char -O2 -DNDEBUG -mthumb -march=armv7-a -mfloat-abi=softfp -g2 -DNDEBUG  -fno-inline-functions  -Wl,--no-undefined -Wl,--fix-cortex-a8 -I/home/SVN-Scripting/eigen-eigen-599fc4f7c736/testBuild/test -I/home/SVN-Scripting/eigen-eigen-599fc4f7c736/test -I/home/SVN-Scripting/eigen-eigen-599fc4f7c736 -I/home/SVN-Scripting/eigen-eigen-599fc4f7c736/testBuild    -DEIGEN_TEST_FUNC=triangular  -DEIGEN_TEST_PART_4=1 -o CMakeFiles/triangular_4.dir/triangular.cpp.o -c /home/SVN-Scripting/eigen-eigen-599fc4f7c736/test/triangular.cpp

and this
Code: Select all
/usr/bin/c++  -fPIC -DANDROID -Wno-psabi -fsigned-char -O2 -DNDEBUG -mthumb -march=armv7-a -mfloat-abi=softfp  -g2 -DNDEBUG  -fno-inline-functions  -Wl,--no-undefined -Wl,--fix-cortex-a8   CMakeFiles/triangular_4.dir/triangular.cpp.o  -o triangular_4 -rdynamic


It runs smoothly but if I add the flag "-mfpu=neon" to both gcc invocations the test fails as follows :

Code: Select all
Initializing random number generator with seed 1312383973
Repeating each test 10 times
Test triangular_square(Matrix<std::complex<float>,8, 8>()) failed in /home/SVN-Scripting/eigen-eigen-599fc4f7c736/test/triangular.cpp (106)
    m2.isApprox(m3.adjoint() * (m1.adjoint().template triangularView<Lower>().solve(m2)), largerEps)


I have seen some other tests failing with these flags (including "-mfpu=neon"), the previous one is one of those.

Could you give a hand with this issue.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
hi, sorry for the late reply. Could you be more specific about the version of gcc. As far as I remember all tests passed on an ARM NEON with Eigen 3.0.1. I'll try again triangular_4. Do you remember which other tests failed?
jsanz
Registered Member
Posts
9
Karma
0
OS
Hi,

The compiler version is the following one
Code: Select all
~$ gcc --version
gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Actually last time I got lucky. The are more test failing in android than in Linux over the same device but I tested just "triangular_4" in Linux that failed and I assumed that the same tests were failling in both platforms.

The other ones than fail are ./redux_4:
Code: Select all
Test matrixRedux(MatrixXcf(3, 3)) failed in /home/SVN-Scripting/eigen-eigen-599fc4f7c736/test/redux.cpp (53)
    test_isApprox(m1.prod(), p)

and ... well schur_complex_2 is not even compiling
Code: Select all
/usr/bin/c++   -DEIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS -fPIC -DANDROID -Wno-psabi -fsigned-char -O2 -DNDEBUG -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon  -g2 -DNDEBUG  -fno-inline-functions  -Wl,--no-undefined -Wl,--fix-cortex-a8  -I/home/SVN-Scripting/eigen-eigen-599fc4f7c736/testBuild/test -I/home/SVN-Scripting/eigen-eigen-599fc4f7c736/test -I/home/SVN-Scripting/eigen-eigen-599fc4f7c736 -I/home/SVN-Scripting/eigen-eigen-599fc4f7c736/testBuild    -DEIGEN_TEST_FUNC=schur_complex  -DEIGEN_TEST_PART_2=1 -o CMakeFiles/schur_complex_2.dir/schur_complex.cpp.o -c /home/SVN-Scripting/eigen-eigen-599fc4f7c736/test/schur_complex.cpp
In file included from /home/SVN-Scripting/eigen-eigen-599fc4f7c736/Eigen/Core:335,
                 from /home/SVN-Scripting/eigen-eigen-599fc4f7c736/Eigen/QR:4,
                 from /home/SVN-Scripting/eigen-eigen-599fc4f7c736/test/main.h:168,
                 from /home/SVN-Scripting/eigen-eigen-599fc4f7c736/test/schur_complex.cpp:25:
/home/SVN-Scripting/eigen-eigen-599fc4f7c736/Eigen/src/Core/products/GeneralMatrixVector.h: In static member function ‘static void Eigen::internal::general_matrix_vector_product<Index, LhsScalar, 0, ConjugateLhs, RhsScalar, ConjugateRhs>::run(Index, Index, const LhsScalar*, Index, const RhsScalar*, Index, typename Eigen::internal::scalar_product_traits<LhsScalar, RhsScalar>::ReturnType*, Index, RhsScalar) [with Index = int, LhsScalar = std::complex<float>, bool ConjugateLhs = false, RhsScalar = std::complex<float>, bool ConjugateRhs = true]’:
/home/SVN-Scripting/eigen-eigen-599fc4f7c736/Eigen/src/Core/products/GeneralMatrixVector.h:286: internal compiler error: in change_address_1, at emit-rtl.c:1954
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.4/README.Bugs> for instructions.

But I guess that is not on your side ;-).

If you want I can give the full list of android failing test. But in order to reproduce I cross compiled the files with ndk and the run the test using adb (the procedure is long to explain here).

It seems I am pushing gcc limits here.
jsanz
Registered Member
Posts
9
Karma
0
OS
Has anyone tried to activate neon support in Android with Eigen? If I use "-mfpu=vfpv3" everything works smoothly. But if use -mfpu=neon the results goes crazy, it compiles but my application results are not right. I am using cmake (http://code.google.com/p/android-cmake/) to compile eigen with android ndk. My previous post were trying to focus in a specific problem. But it seems none had an answer or I did not explain myself right so if anyone has solved a similar problem please let me know. I have googled the issue but with no success.
kmhofmann
Registered Member
Posts
6
Karma
0
Hi all, I filed the other bug mentioned and am still interested in finding out what's going wrong - haven't made any progress so far. Coincidentally, I am going to receive a Pandaboard next week and will be able to run a few tests on it or provide assembly output. Might be also worthwhile to change the NDK toolchain to a later GCC, but it seems that might be taking some amount of effort.
jsanz
Registered Member
Posts
9
Karma
0
OS
Hi kmhofmann,

Did you successfully run any test in your new pandaboard either in Linux or in Android. If you need any help doing so please let me know. I would be great to have another user feedback to see if I am doing something wrong.
kmhofmann
Registered Member
Posts
6
Karma
0
Hi,

I have just done your tests on the Pandaboard. I'm compiling on the device using Ubuntu 11.10 with
> g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1

Both "triangular_4" as well as "schur_complex_2" have passed the test both with and without "mfpu=neon" enabled.

Therefore I suspect that the errors that we are seeing on Android are due to an outdated toolchain in the NDK releases.
I am still building the complete Eigen test suite on the Pandaboard, which will take some time. In case there are any errors, I will let you know.

Slightly off-topic:
There are attempts by others to provide custom-built NDK toolchains based on newer versions of gcc, binutils, etc. I am aware of this effort:
http://groups.google.com/group/android- ... f6f0bbc9d#
That said, I have tried to build my own software (which itself also contains both NEON assembly as well as intrinsics code) with it and got immediate crashes that I couldn't explain. And building my own toolchain seems a bit too time-consuming at the moment.

Cheers,

Michael
kmhofmann
Registered Member
Posts
6
Karma
0
For Android development, have a look at the new version of the Crystax NDK: http://www.crystax.net/en/android/ndk/7

This is the first custom NDK that managed to compile my code using Eigen and NEON vectorization without any apparent issues at compile or run-time, due to its GCC 4.6.3 toolchain.
The errors that I had been seeing have been almost certainly been compiler issues of previous versions of GCC.
jsanz
Registered Member
Posts
9
Karma
0
OS
Thanks Michael for your answers and feedback,

I will test it as soon as I have time an I will let you know.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]