Translations of this page?:

Emulators Profiled Compilation

Introduction

Beijing LUG member dsobodash has spent quite some time hacking into emulators on his own Yeelong laptop, the goal of this project is to achieve similar work for the Gdium.

SNES9X

MAME

gcc optimization flags

CFLAGS and CPPFLAGS

When compiling emulators, we use the following flags to optimize the process:

  • -O2: optimization level of the compilation, other possible values are 1 and 3.
  • -mtune=r4600
  • -march=r4600: target architecture the compiled code will only run on. r4600 is used with gcc 4.3 because it is the closest compatible architecture to the Longson CPU, in gcc 4.4, use march=native
  • -fprofile-generate
  • -ffast-math
  • -funroll-loops: loops will be unrolled, for example, if the upper boundary is known:

For example:

for (unsigned int i=0; i<10; i++) var[i]=0;

Will be turned into:

var[0]=0;
var[1]=0;
var[2]=0;
var[3]=0;
var[4]=0;
var[5]=0;
var[6]=0;
var[7]=0;
var[8]=0;
var[9]=0;

The resulting binary will be larger but will run faster since the tests are removed.


Personal Tools