PDA

Ver la versión completa : Profiling Optimization por Notaz.



Rivroner
17/12/2007, 13:12
Pues esto es de hace ya unos meses pero por si a algún programador español se le ha escapado por no leer gp32x pues lo pongo para que se puedan aprovechar de él; igual la nueva versión de MetalBrain del GP2Xpectrum o la nueva del PocketSnes de Headoverheels puedan beneficiarse de esto :) AL igual que futuras versiones de emuladores como el FBA o el GP2XEngine y cualquier juego homebrew de cualquier programador :)

Reviving this thread to tell that I am using -fprofile-use and -fprofile-generate for quite some time now. It is giving ~20% improvement to recent uae4all builds, for example.

But there is one thing: it is quite important to do those profiling runs on GP2X itself. It doesn't require to port your program to PC and avoids all those CRC errors. The only problem is that you need Linux box to do it properly. It might be doable using cygwin, though.

Here is the method I am using, step by step:

1. If you havent already done so, install open2x toolchain to your linux box. You may also need a prebuilt library pack

2. Make a directory on your Linux box which can be made on your GP2X too. I use "sudo mkdir -p /mnt/sd/tmp", "chown notaz /mnt/sd/tmp"

3. Copy you whole sourcecode there. Add "-fprofile-generate" option to your compile flags. Make sure it gets passed to both compiling c/cpp files and the linking phase.

4. Clean old .o files, if there are any and recompile. This should create a bunch of .gcno files along with usual .o ones.

5. Copy the resulting binary from /mnt/sd/tmp on your PC to /mnt/sd/tmp on GP2X. It's important that the paths match, because full path is now embedded into the binary and will be used for the output profiling data files. You don't need to copy any .gcno files.

6. Run your newly built program on GP2X. If it's an emulator, load some heavy titles, which cause most slowdowns. I mostly load up 3-4 games and play every of them for a minute or two. Note that your program will run very slow, because it is also collecting profiling data, along with doing what it was meant to (or not smile.gif).

7. Exit your program. Do not kill it. Oh heck, I almost forgot. Make sure your program doesn't run the menu on exit (my emus have a command line option for this), or else it won't produce needed files. If everything went right, you now should have a bunch of *.gcda files in your GP2X /mnt/sd/tmp directory (and sub-dirs, if your source tree is more complicated).

8. Copy all those *.gcda files from GP2X /mnt/sd/tmp to your PC's /mnt/sd/tmp. They should be paired with *.gcno files, if you sort them by name.

9. Open up your Makefile again and change all "-fprofile-generate" to "-fprofile-use". Do not change any other compile options.

10. Clean your old .o files again (but do not kill .gcno and .gcda)

11. Recompile

Now you should have your optimized binary. It depends on your program itself how much better it performs. For example, PicoDrive doesn't perform much better with genesis games (as rendering code is asm anyway), but Sega CD scaling/rotation chip code performs much better (maybe 50% improvement?).

Si tenéis algún problema para hacerlo funcionar igual en este hilo os ayudan ;) :
http://www.gp32x.com/board/index.php?showtopic=28490&hl=gcc%20dynamic%20profiling&st=15

:lovegp2x:

headoverheels
17/12/2007, 14:05
Las versiones de PocketSnes ya están compiladas con esas optimizaciones. Este tema ya lo comenté en este hilo http://www.gp32spain.com/foros/showthread.php?t=46682

JoJo_ReloadeD
17/12/2007, 14:48
El otro dia me comentaron esto en gp32x.com, definitivamente creo que el gpfrontier puede acelerarse mucho gracias a el :)

Rivroner
17/12/2007, 18:55
El otro dia me comentaron esto en gp32x.com, definitivamente creo que el gpfrontier puede acelerarse mucho gracias a el :)

Me alegro :)

< - >

Las versiones de PocketSnes ya están compiladas con esas optimizaciones. Este tema ya lo comenté en este hilo http://www.gp32spain.com/foros/showthread.php?t=46682

Ya veo, se me pasaría, eso de currar 12 horas 4 días seguidos no puede ser bueno :D

Puck2099
17/12/2007, 20:39
Yo seguí esas instrucciones con el Fenix y no sé si alguno más y no me generaba los archivos .gcda en la GP2X...

headoverheels
17/12/2007, 23:32
Yo seguí esas instrucciones con el Fenix y no sé si alguno más y no me generaba los archivos .gcda en la GP2X...
Yo he compilado varios programas con esto (PocketSnes, MAME, MSX y UAE) y el único que me dio problemas fue el PocketSnes. El problema era que el programa no terminaba correctamente porque el hilo del sonido se quedaba pillado al salir y por eso no generaba los gcda.
También hay que tener cuidado de que el path en el que compilas sea exactamente igual que en el que vas a ejecutarlo y no lanzar ningún otro proceso antes de salir (gp2xmenu p.e.) Bueno básicamente lo que dice notaz :)