GP2X Little Help Porting Sdl App


Have you tried profiling, to see what's actually slowing it down?

If the calculation is taken 90% of the time, shaving the odd millisecond off the rendering isn't going to make much difference.
 
That's my next task. Squidge has pointed me in a direction to get useful list files from the compiler - so I can see what's what.

In reality there isn't anything in the main loops that should compile into anything nasty - it's all integer maths and lookups - but I guess something daft will be going on.
 
Yikes - just seen the code the compiler is creating..

I know it's a RISC processor - but 7 instuctions to write from one address to another??

I can see a bit of inline asm coming this way.
 
just remember the generated assembly can be improved by using the optimization level -O? switch and by default the optimization is at it lowest level to allow debug. Also the ARM family like most RISC's has "branch slot delay" issues when doing branches (pipeline is flushed for conditional and unconditional branches) so the best behavior for pipeline is straight line flow when possible.

There have been time when -O3 screwed up my code with some version of gcc so pushing it up (larger than 2) can be problematic.
 
15fps with sky :)

Few more optimisations and -O3 does wonders.

Don't think I'll get much faster without hand coding in asm.
 
deluded said:
Don't think I'll get much faster without hand coding in asm.
ianac (coder) but don't be sure sure of that until you do the profiling. you may end up spending way more effort than you need to. plus, that's just how risc is in general, more operations, but faster for each. free barrel shifter etc.

definitely read through this if you haven't seen it

http://arm.nihilisme.ca/doc/DAI0034vA.pdf

to spoil the ending: compares with zeroes are basically free, also code with more simple functions is more easily optimized than fewer more complicated functions. you can designate functions as "pure" that don't need access to global vars or pointers, less overhead. global variables should not be used in critical loops since they are not normally stored in registers. unrolling loops can help with optimizing. switch statements are bad, incrementing loops considered harmful.

practical example: don't use loops to count upwards and compare to some value. instead, where possible, count downwards from that value and compare to zero instead.
 
Last edited by a moderator:
Cheers for that - will give it a read later - I guess its much easier to help the compiler do a better job than attempting to write in asm, and loose the ability to test on the PC!
 
Back
Top