GP2X My Emulator Is Slow !!


_tyrell_

Member
Joined
May 3, 2003
Messages
159
Location
Belgium
Website
www.speccyal.be
Hi all!

I have a running binary of Speccyal on the gp2x. However it's slow like hell !
It seems like the emulator is running at 20 mhz or so ... strange.

I'm using the detvkitGP2x and rlyeh's minimal lib (v0.B version).
Is there some compilation option I should activate ? Is the minimal lib beta v0.B version slow ?

Also, I have problems with getting sound running. Would someone have some working sound code ?

Thanks for your help!

_tyrell_
 
_tyrell_ posted on Feb 18 2006 at 03:49 PM said:
Hi all!

I have a running binary of Speccyal on the gp2x. However it's slow like hell !
It seems like the emulator is running at 20 mhz or so ... strange.

You should profile first - check where the most of cpu cycles are spend. Without such knowledge it isn't possible say anything for certain.
 
Last edited by a moderator:
Anyway, here are the gcc options I've used (taken from mame) :

-W -Wall -Wno-sign-compare -Wno-unused -Wpointer-arith -Wbad-function-cast -Wcast-align \
-Waggregate-return -Wshadow -Wstrict-prototypes \
-mcpu=arm920 -mtune=arm920t -O2 -fstrict-aliasing -fexpensive-optimizations \
-falign-functions -fweb -frename-registers -fomit-frame-pointer -ffast-math \
-finline -finline-functions -fno-builtin -fno-common \
-mstructure-size-boundary=8 -msoft-float \
-pedantic \
 
rlyeh has example sound code in his sdk under the "examples" directory.

As for your slowness, you need to profile your code - this will tell you where most of the time is being taken, then you can optimize accordingly.
 
Speaking of profiling - what's the best way to go about it? I'm sure it depends on your environment. I'd like to avoid writing my own profiler, but if I'm using the Visual Studio 2005 dev env. Will I have to or are there some compilation options that I can turn on/off that will, with minimal work, allow me to output profiling info to a file? I know that I did something in class with gcc where I didn't write a profiler - I just ran or compiled with certain options.
 
For profiling C code, you can normally compiler to a windows application, and then run a profiler such as Compuwares DevStudio or Intel's VTune. These will tell you where most of the processor time is being used. You can then use this to optimize your program, as these same sections will be taking the longest on the gp2x, so they are the first things to optimize.

Other than that, you need to write your own profiler - ie, setup some functions or #define'd that record the value of a timer before and after a function or set of functions and see which ones take the longest. It's true that GCC has built in profiler, but I've never seen anyone get it to work properly under the ARM architecture unless optimization is disabled on the compiler, which then makes it quite pointless (as large sections of code could be deleted or modified that radically changes the profiling).
 
Squidge posted on Feb 18 2006 at 06:08 PM said:
For profiling C code, you can normally compiler to a windows application, and then run a profiler such as Compuwares DevStudio or Intel's VTune. These will tell you where most of the processor time is being used. You can then use this to optimize your program, as these same sections will be taking the longest on the gp2x, so they are the first things to optimize.

Other than that, you need to write your own profiler - ie, setup some functions or #define'd that record the value of a timer before and after a function or set of functions and see which ones take the longest. It's true that GCC has built in profiler, but I've never seen anyone get it to work properly under the ARM architecture unless optimization is disabled on the compiler, which then makes it quite pointless (as large sections of code could be deleted or modified that radically changes the profiling).
Yeah I have a couple articles on writing a profiler - so I definitely can - I just want to avoid it at the moment. So in the meantime, I'll take your suggestion and compile to windows as well and use devstudio or vtune. Thanks a lot squidge.
 
Last edited by a moderator:
While on the subject of profiling anyone got tips on profiling floating point code? I guess I can profile on x86, but I'm not sure how I can disable the fpu with gcc. With fpu enabled it runs fast, but then runs several hundred times slower on the GP2X!

Thanks,

Mark
 
gprof worked fine for me so long as I disabled the omit-frame-pointer optimisation - it shouldn't have too much effect on your code's speed anyway, as it only affects leaf functions and AFAIK the ARM architecture isn't as register-starved as Intel...

The profiling reports can be hard to read, but it can be good for finding hotspots, and there's probably a graphical frontend for it somewhere (maybe Dev-C++ supports it or something).

This kind of profiling is very intrusive, though - your game will run really slowly while being profiled. I generally prefer sample-based profiling - it would be cool to write a kernel module to manage that (hook timer interrupt, and peek at the watched process's instruction pointer?)
 
Back
Top