Slashdot Mirror


Genetic Algorithms for GCC Optimization

captain igor writes "For the power users in the house that enjoy taking the time to squeeze every last drop of performance out of their programs, here's an interesting little program I ran across today call Acovea. Out since 2003, Acovea's main function is using genetic algorithms to determine an optimal set off Gcc optimization flags to squeeze the most performance out of a given program. Certainly an interesting concept, definitely worth a look. Some nice results on a P4 and Opteron can be found here "

7 of 45 comments (clear)

  1. Even more interesting for OSS by MrIrwin · · Score: 2, Interesting
    Potentially one could distribute make scripts that would optimize the build of critical sections on installation.

    It's a feature on top of the existing advantages of "compiling into" instead of "installing onto" a system, and a feature that is pretty much esclusive to OSS.

    --

    And if you thought that was boring you obviously havn't read my Journal ;-)

  2. Didn't do -mfpmath=sse,387 by wowbagger · · Score: 3, Interesting

    It does not look like he checked the value of using -mfpmath=sse,387 - only -mfpmath=sse.

    I would question just using SSE for floating point if the code is written just using double values - IIRC SSE doesn't like doing doubles very well. Allowing the compiler to use both the 387 mathco registers as well as the SSE registers might be a win here.

    The other point about using SSE for floating point would be to use simple floats and see what difference the math options make.

  3. Performance by chance? by MacroRex · · Score: 4, Interesting

    Using a GA basically means it randomly tries some flags. While this is nice and automated, I'd rather have the developer understand his/her code and the compiler to the extent that the best flags can be picked deterministically. Besides, the "optimizer" might very well pick flags that work with the test cases, but break the executable at some other place. At worst this might result in a some terribly hard-to-track security vulnerability.

    1. Re:Performance by chance? by norwoodites · · Score: 2, Interesting

      Most optimizations break code because developers do not follow the standard of a language. For an example -fstrict-aliasing breaks code because people do not follow aliasing rules for the language which they are using. The Linux kernel does not follow them so they have to do -fno-strict-aliasing. Note this flags was truned on by defualt at -O2 for 2.95 and 2.95.1 but turned off for 2.95.3 and then reenabled for 3.0 while people fix their code. Most people have fixed their code but some code out there still violates these rules, the Linux kernel is just one of them.

  4. Gentoo by motown · · Score: 3, Interesting

    It would be really cool if this technology could somehow be integrated into the Gentoo project.

    Of course it would be unreasonable to have the each single ebuild compile and get benchmarked several times on each user's PC, but these genetical algorithms could be used to predetermine the optimal compiler settings for each architecture/ebuild-combination, store this information in a central database and have portage automatically select the optimal compiler setting from that database, each time it compiles an ebuild.

    No more figuring out what the best compiler options are: the ebuild maintainers will take on that job for you! :)

    --
    "Oooh, does that mean we get to kick some puffy white mad zionist butt?"
  5. Re: What about profiling? by ufnoise · · Score: 2, Interesting
    From the article:
    I envision Acovea as an optimization tool, similar in purpose to profiling. Traditional function-level profiling identifies the algorithms most influential in a program's performance; Acovea is then applied to those algorithms to find the compiler flags and options that generate the fastest code.
    In addition to just trying some new flags on critical sections, perhaps you can actually try to understand what parts of these algorithms may be improved instead of just trying a bunch of options. In C++, there are many things a compiler cannot do to your code (e.g. return value optimization, avoid temporaries, premature computation), unless you write your code in the proper way.
  6. PostgreSQL by Earlybird · · Score: 3, Interesting
    PostgreSQL has been using genetic algorithm internally for some time, to optimize query plans.

    A code optimizer seems like a natural application for GAs. If you can prove a piece of code's logical equivalence to another's, you can have a code generator produce random versions of the same code (functions, loops, blocks) and then run that as a GA to find the best-performing version. On the other hand, compilation might take ages to run.