libnoise, NEON, and speed


mindlord

Notices Two Things
Joined
Mar 10, 2006
Messages
1,786
Location
In a cave.
Website
Visit site
I've been working on a project that uses libnoise to generate coherent noise textures for terrain and objects. So far things are looking pretty good. The library compiled fine without any code changes, and works ok considering the amount of floating point math involved. I'm looking to speed it up on the Pandora though, and I'm looking for pointers. I compiled the library with the following compiler flags:



Code:
-o3 -march=armv7-a -mfpu=neon -funsafe-math-optimizations -mthumb -ffast-math


But is there anything I can do to squeeze more speed out of it? Like, any specific Pandora unfriendly math or code structures I should look for in the source to change? I'm not asking for someone to do it for me, just point me at some NEON tweaking guides or something.


Thanks in Advance
 
I looked through the source and it looks like libnoise uses double precision arithmetic exclusively. NEON will be of no use for this and it'll always be pretty slow on Pandora. First thing you need to determine if you need this kind of precision and if not transition to floats or fixed point arithmetic. It's possible that even if you need the full precision you don't need the dynamic range, and some solutions can be used that don't need doubles straight up.


To go really further than this you'll need a more rigid way of evaluating performance. Write some test bed around the functions you've determined are too slow. Then some we can look at how to make it faster. It's a little too open ended right now.
 
No wonder I wasn't noticing any difference with -mfpu=neon there or not.


Maybe I'll try bringing it down to floats instead of doubles. Looking at the source I'm fairly certain I'm capable of making that modification. I certainly don't need that much precision. I'm not very well versed in fixed point arithmetic. That's probably beyond my abilities at the moment.


I've been using the examples provided on the site as a testbed. In particular the complexplanet.cpp example since I'll be using it in a slightly modified form to generate terrain. Currently it takes 30+ seconds to generate a 128x64 sample. I know that even 1 or 2 second response times aren't realistic here, but 30 seconds is pretty bad.


Thanks for the advice.


EDIT: I converted the code to run on floats instead of Doubles. It doesn't work. There's some bit math going on in there that I think is causing the output to only give maximums. I'll keep digging though. I've emailed the author as well looking for advice on conversion as well.
 
Last edited by a moderator:
Thanks Ashcloud


I'll take that into consideration. I'm already well into converting libNoise to fixed point now though. If that doesn't bear fruit, your solution might do the trick.
 
Back
Top