floats and integers on arm

mjohansson

Supporter
Joined
Feb 10, 2011
Messages
409
Hey, the arm cpu dont have an fpu right? So what about sin using double as standard and float if defined? Isnt it required to calculate your own rotations on GL ES2.0? Does anyone know how to rotate with integers only?
 

Tehel

Still Fresh
Joined
Dec 10, 2010
Messages
31
Age
45
Location
Southern France
The ARM cpus do floating point operations very well, don't worry.


The wikipedia page on ARM Cortex-A8 is not decisive, since it states that the cpu has an "optional" VFPv3 Floating Point Unit.


But the doc for the OMAP3530 is affirmative on page 1 :


ARM Cortex™-A8 Core


– ARMv7 Architecture Anti-Aliasing


· Trust Zone®


· Thumb®-2


· MMU Enhancements


– In-Order, Dual-Issue, Superscalar Microprocessor Core


– NEON™ Multimedia Architecture


– Over 2x Performance of ARMv6 SIMD


- Supports Both Integer and Floating Point SIMD


...


For more details about the actual floating point instruction set, I can only point you to the Appendix B of the ARM Assembly Language Programming book. Haven't read it myself (and do not think I actually will if not required to :) )


Too bad, though, I nearly had a chance re-using my assembly integer calculus tricks from the HP48 era. Those were the days. If I remember well we were using matrix calculus to do rotations/translations, etc...
 
Last edited by a moderator:

notaz

Certified Guru
Joined
Aug 23, 2005
Messages
4,913
Location
Lithuania
Website
notaz.gp2x.de
While Cortex-A8 integer performance is comparable to something like pentium3, it's float capabilities are much more limited in the same comparison, unless you can manage to use NEON SIMD. However gcc is not good at generating NEON code and you'd need to write assembly code.
 

mjohansson

Supporter
Joined
Feb 10, 2011
Messages
409
Ok so it can do floats but not particulary fast? Theres some rotation code using sin on the web, but I havent yet found any good explenation of quaternions, none that I could understand and do myself, I have no mathskills whatsoever is that a limit on using quaternions? Cos it does normal multiplication only wich should be faster then a sin calculation especially on the arm would be my guess. I found a great sample page for openGL code for any other beginners like myself: http://www.opengl.org/resources/code/samples/redbook/


Havent looked through much yet but it seems very simple compared to many other guides.
 

Tehel

Still Fresh
Joined
Dec 10, 2010
Messages
31
Age
45
Location
Southern France
Oh, ok. Anyway... ;)


Real Programmers scorn floating point arithmetic. The decimal point was invented for pansy bedwetters who are unable to "think big."


(sorry, couldn't resist)


However, I read somewhere that Ubuntu had a "NEON-enabled versions of critical shared libraries"


since 9.04 (it is now in its 10.x versions).


Isn't there something we could borrow there ? (if we didn't already, that is, in which case having good floating performance is just a matter of using the right lib instead of letting gcc compile the math).
 
Last edited by a moderator:

Exophase

Nothing good will ever come of Exophase.
Joined
Sep 21, 2006
Messages
10,308
Age
36
Location
Cleveland OH
I doubt those critical shared libraries include things like rotation. NEON is probably used to improve performance of things like memcpy and string operations, probably mostly integer stuff.


All geometry in OpenGL will be shaded by multiplying it against a transformation matrix. In OpenGL ES 2.0 you have to do this manually in a vertex shader, while in OpenGL ES 1.x it'll happen for you and will be based on how you setup OpenGL state matrices (projection, modelview). Either way, the actual vertex rotation happens in hardware, but setting up the rotation matrix happens in software (normally anyway, technically you can setup the shaders to do matrix math too, and there's an IMG compiler optimization to get them to not redo it for every vertex, but it has to be done just right). If you're doing a call to standard sin/cos to do this it'll be relatively slow no matter what, but you shouldn't need to constantly create rotation matrices.


The parameters in OpenGL ES can be either floating point or fixed point. So you can send both the vectors and the matrices themselves as fixed point, and it'll be converted to floating point on the chip. You can make sin/cos functions that operate in fixed point too; how much faster than the slow non-NEON floating point implementations will depend on how it's done.


You don't want to use double precision because that'll definitely not be implemented with NEON, and it's slower than single precision even in VFPU. sin/cos will especially be slower as double because more approximation steps will have to be taken in software. You should use single precision (float) instead, and sinf/cosf if you have to.


Since you seem to be starting out with this sort of thing I recommend using OpenGL ES 1.1 first, and using glRotatef to setup the modelview matrix for rotations. If you have to do it yourself check out Adventus's NEON math library - it has matrix multiplication and sin/cos implementations using NEON.
 
Last edited by a moderator:
Top