3

I am struggling with the compilation of Eigen library for iPhone 4 which has an ARM processor with armv7 instruction set. Everything works fine so far when I specify the preprocessor define EIGEN_DONT_VECTORIZE. But due to some performance issues I would like to use armv7 optimised code.

Regardless which compiler I use LLVM-GCC 4.2 or LLVM CLang 2.0, I always run into compilation errors. I figured out (or better think so), that LLVM-GCC 4.2 is the only way to get access to these ARM-NEON specific instructions.

When I do not set EIGEN_DONT_VECTORIZE (and provide -mfloat-abi=softfp -mfpu=neon to gcc) I get the following gcc compiler error:

src/m3CoreLib/Eigen/src/Core/arch/NEON/PacketMath.h:89: error: expected unqualified-id before '__ extension__'

I have read about issues using the "old" gcc 4.2 and the recommendation to use a newer version of gcc. I am not sure but I believe this is not an option because of app store approval. Is there anything else I can do to get it compiled for iPhone.? Anybody out there who solved this?

Thanks, Kay

Kay
  • 12,918
  • 4
  • 55
  • 77
  • I don't know enough to properly answer your question, but I don't believe Apple care about what you compile with as long as it passes the static analysis. Certainly before iOS 4 came along there were apps that were modifying the compiler to obtain blocks support, for example. As long as you are producing a signed .ipa as your output you can really compile with whatever (to my knowledge: prepared to be proved wrong on this one). – lxt Jun 05 '11 at 18:35
  • @lxt: Thanks, maybe I should give using a newer gcc version a try. Then I get an idea about the possible amount of performance improvement. – Kay Jun 06 '11 at 09:05

1 Answers1

1

After fiddling around with different compiler settings hours and hours I found myself a satisfying solution and came to following conclusion.

There is a surprisingly huge difference between debug and release settings regarding Eigen's template library approach: Release settings with usual optimisation flags enabled let the application run 20 to 40 times faster than debug. I have never seen such a difference before in any language, from my experience it is usually 1.5 - 3.

Although I still cannot force vectorisation i.e. code compiles only with EIGEN_DONT_VECTORIZE defined, the resulting performance fits my needs now.

Kay
  • 12,918
  • 4
  • 55
  • 77
  • Man, that's great! Now, please do that one unique thing and share how did you manage to use eigen with xcode. Really please. I somehow can't... When I just include eigen's files into the project there's a long list of errors in eigen's files. That's surely problem on my side. If you could share your solution or prep some guideline many people would be grateful. Me included! :) – bor Mar 18 '12 at 11:41
  • Ok, never mind, it seems I'm just too tired. It works. Right out of the box. Just missed one `.m` unchanged to `.mm`. Sorry for bothering. – bor Mar 18 '12 at 12:40
  • I have run into the same performance issue with templates in debug mode. My guess is that most of the stuff doesn't get inlined since inline functions cannot be debugged (the function doesn't exist). And templates heavily rely on inlining, hence the performance issue. – Ali May 28 '12 at 08:10