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?
 
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:
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.
 
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.
 
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:
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:
Back
Top