Search:  
Gentoo Wiki

Acovea

This article is still a Stub. You can help Gentoo-Wiki by expanding it.

Contents

Introduction

The purpose of this HOWTO is to show users who like to optimise their machines as much as possible (i.e. gentoo ricers) how to get acovea, install it, run it and use the results. The information in this HOWTO is loosely based upon http://forums.gentoo.org/viewtopic.php?t=157108.

acovea is written by Scott Robert Ladd and to find out more about how his program works you really should read http://www.coyotegulch.com/products/acovea/.

To start off with, acovea is all about which CFLAGS to use. Anyone having installed Gentoo will know the CFLAGS section in /etc/make.conf. These are compiler flags that are passed to gcc everytime it is invoked by portage. That means every time you emerge a program, it gets emerged with the flags set in make.conf.

Effect of Optimisation Flags

The GNU Compiler Collection (GCC) compiles the C or C++ code that it is given into machine code that is understandable to the processor. In doing this there are many choices the compiler is faced with. There are many different ways of implementing various control structures in machine code. GCC has some standard setting that aren't too bad at all - but in most cases not quite optimal. The various flags offered by the compiler (there are about 30 of them) are enigmatic even to gcc developers. Nobody knows exactly which flags influence compile time and runtime or in which way.

With 30 different flags available testing all of them would be impossible. This is where acovea comes in handy. It uses a so called genetic algorithm to find the optimal flags for each individual system.

Genetic Algorithms

For more details of course you should read Scott's page mentioned earlier. If you're really interested in the theory then I must recommend the excellent book "The Blind Watchmaker" by Richard Dawkins. After understanding his book you will understand why a genetic algorithm is suited to this kind of complex problem. Be warned however that just in the same way as evolutions has taken millions of years up to date, running acovea is highly processor intensive. Expect one iteration to take well over 24 hours with an Athlon-XP / Pentium 4.

Acovea created a group of possible flag settings for gcc. These are called a population. The default size for a population is 5, but this is easily changed. Acovea uses all the flag settings in a population to consecutively compile a benchmark and test how fast it runs. The flag settings that do well are kept, the rest are eliminated and replaced by new settings that are again created randomly, but based on the settings that did well in the previous generation. This process is repeated many times (by default 40 times). What we're interested in is which flags will be left at the end of 40 generations. Of course you can't base everything on one benchmark and thus there is a benchmark suite that currently consists of 6 different benchmarks. These are also maintained by Scott.

Getting Acovea

Since Acovea is in the portage tree it has become much easier to get and install. Just emerge -av acovea.

Running Acovea

System state when running

Given the above explanation of how Acovea works, you should consider the system environment you test in. Flags are evaluated by measuring their effect on the performance of tiny programs. This suggests you should run Acovea as the only task on a system, without interference of other programs. However, this is not a realistic situation. The programs you will use in real-world situations will not be the only program running on your system. This suggests you should run Acovea with your favorite always-on programs also running. But, having programs running in the back- or foregrond will seriously invalidate your results, as they randomly use the CPU, and flags might be disqualified because another program was using the CPU. So with or without programs running beside Acovea, your results will not be perfect.

Command-line options

if you specify no options Acovea will show its options:

Code: runacovea
usage: runacovea -config {name} -bench {name} [options]
essential options:
  -config {config file name}              (i.e., -config gcc34_opteron.acovea
  -bench {source base name}               (i.e., -bench almabench.c)
options for tuning the evolutionary algorithm:
  -n {number of populations to create}
  -p {size of each population}
  -g {number of generations to run}
  -sr {survival rate}                     (between 0.0 and 1.0)
  -mr {mutation rate}                     (between 0.0 and 1.0)
  -cr {crossover rate}                    (between 0.0 and 1.0)
  -ir {immigration rate}                  (between 0.0 and 1.0)
  -fn                                     (no fitness scaling)
  -fl                                     (linear fitness scaling)
  -fe                                     (exponential fitness scaling)
  -fq                                     (quadratic fitness scaling)
  -fw                                     (windowed fitness scaling - default)
  -seed {random number seed}

The default installation create the config here at /usr/share/acovea/config/ and the benchmarks at /usr/share/acovea/benchmarks/.

With the following default configs:

And the following benchmarks:

Which would give us the example running of:

runacovea -config gcc34_opteron.acovea -bench huffbench.c

If you pass the wrong processor type, then Acovea will abort.

Automating the testing

This little bash script automagically tests your machine with diffenrent configs and benchmarks. Just edit BENCHES and CONFIGS.

For acovea-4.x:

#!/bin/sh
BENCHES="alma evo fft huff lin mat1 tree"
CONFIGS="g++33_pentium4"

for config in $CONFIGS; do
  for bench in $BENCHES; do
    echo ""
    echo "*** $bench ***"
    time runacovea -config /usr/share/acovea/config/${config}.acovea -bench /usr/share/acovea/benchmarks/${bench}bench.c 1> ${bench}_p4++.run 2> ${bench}_p4++.err
  done
done


For acovea-5.x:

#!/bin/sh
BENCHES="alma evo fft huff lin mat1 tree"
CONFIGS="g++33_pentium4"

for config in $CONFIGS; do
  for bench in $BENCHES; do
    echo ""
    echo "*** $bench ***"
    time runacovea -config /usr/share/libacovea/config/${config}.acovea -input /usr/share/libacovea/benchmarks/${bench}bench.c 1> ${bench}_${config}.run 2> ${bench}_${config}.err
  done
done

Acovea Results

Interpreting the results

Given the explanations above, you should see these results as interesting, but not necessarily the best flags for your system.

To convince you: the author of Acovea writes on his Acovea homepage[1]: "[...] For my Gentoo-based systems, I don't set the value of make.conf's CFLAGS based on Acovea results; [...]".

Pentium M (1.6 GHz)

These results show some benchmark done a while ago.

Troubleshooting

If the building of Acovea-5.x.x fails, install
>=dev-libs/libcoyotl-3.1.0
>=dev-libs/libevocosm-3.1.0

Retrieved from "http://www.gentoo-wiki.info/Acovea"

Last modified: Mon, 08 Sep 2008 04:54:00 +0000 Hits: 24,999