Acovea/GTK
A GTK-based User Interface for Acovea
If you find this article useful, please consider supporting the author's free software efforts with a donation, no matter how small.
The Acovea engine ships with a command-line driver named runacovea. I like command-line utilities, and probably spend as much time at the prompt as I do clicking buttons. Still, a graphical interface can provide a certain ease-of-use that is lacking in a command-line application.
As of Acovea-5.0, the underlying engine is interface-agnostic. When something happens — a generation ends, a solution is produced — Acovea sends raw data to an event interface. A driver implements that interface to format information in whatever way it needs to.
Acovea-GTK is a young program, and still reflects Acovea's command-line roots. Future versions will provide more visual information about the statistics collected by the engine. I'm open to suggestions, particularly when it comes to selecting a charting package for GTK applications.
I built Acovea-GTK using the Glade interface designer and gtkmm, a C++ wrapper for GTK. Why GTK? I'm not interested in religious wars, and on a daily basis I run KDE as my Linux desktop. After having built a few UIs in both QT/KDE and GTK/Gnome, I prefer working with the latter, especially when it's wrapped in gtkmm. The QT library feels rather clunky, like working with Microsoft's MFC.
GTK also has the advantage of ubiquity; whereas many Gnome systems do not have QT installed, the popularity of The Gimp leads most KDE users to install the GTK libraries. If I write an Acovea GUI for Windows or OS X, I'll likely use platform-specific tools. I've never been happy with cross-platform tools like wxWindows; the resulting program never quite feels natural anywhere. It's always been my belief that the best programs separate expression from concept, allowing the same engine to be comfortably hosted in a variety of environments.
Running Acoevea-GTK
Once you've configured, made, and installed the program, you can invoke it with the acovea-gtk command. This isn't a very complex application; the Settings menu allows you to change, save, and load settings for running an Acovea test, and the Testing menu drops down simple controls for starting, stopping, and recording a test.
The settings dialog box reflects the same options available with the command-line version. Select configuration and input files based on the type of test you want to run. Acovea installs a set of example configurations in /usr/local/share/libacovea/config and benchmark programs in /usr/local/share/libacovea/benchmarks. For the moment, these are focused on the analysis of GCC; in the future, I'll introduce configuration files for other compilers, development tools, and compression engines.
When you first run acovea-gtk, it creates a $(HOME)/.acovea-gtk directory with a default configuration. It will load this configuration at start-up; you can save new settings as the default, or store separate settings files in the location of your choice.
Beyond the configuration and input files, the other default settings are what I use for my own testing. These create five populations of forty solutions, and evolve them for twenty generations, with a guarantee of crossover, a tiny amount of mutation, and the preservation of a few "best" organisms from one generation to the next.
One confusing curiosity is the randomization seed. By default, the underlying Evocosm engine initializes its random number generator from /dev/urandom or the time. While you can set a specific seed, two runs executed with the same seed may produce slightly different results. Since your computer's environment is always changing subtle differences in run-times will change the "fitness" of various solutions. Setting the randomization seed begins a run with a specific set of random solutions; how those solutions evolve is a matter of random influences.
To start an analysis, click the Run button on the toolbar or select "Run" from the Testing menu. The text area will show the configuration being used, progress, and final analysis, including a simple little text graph that I intend to replace with something fancier in the next version. Clicking the Stop button or menu item will immediately terminate the analysis; a future enhancement will allow runs to be started and stopped, and even saved in-progress.
Once a run is complete, you can save the resulting test to a file from the Testing menu.
Acovea-GTK does not include an editor for application configuration files. These XML files describe a compiler or other program to be analyzed by Acovea. Since configurations can be used by any driver, I'm working on a standalone editor for them. It isn't terribly difficult to write or modify a configuration using a text editor, which is one reason I use an XML format. However, a visual editor will be useful when Acovea 6.0 is finished, and people start optimizing programs that aren't compilers.
What Acovea Tells You
Here is an example Acovea analysis of GCC 3.4.3 on an Opteron system:
test application: benchmarks/huffbench.c
test system: Corwin
config description: gcc 3.4 Opteron (AMD64/x86_64)
test configuration: gcc34_opteron.acovea
acovea version: 5.0.1
evocosm version: 3.0.0
test start time: 2005 Apr 26 15:11:11
# of populations: 5
population size: 40
survival rate: 10% (4)
migration rate: 5% (2)
mutation rate: 1%
crossover rate: 100%
fitness scaling: sigma
generations to run: 20
random number seed: 3720950619
testing mode: speed
generation 1 complete, average fitness: 2.03923
generation 2 complete, average fitness: 2.07835
generation 3 complete, average fitness: 1.97104
generation 4 complete, average fitness: 2.10298
generation 5 complete, average fitness: 2.09282
generation 6 complete, average fitness: 2.13558
generation 7 complete, average fitness: 2.12113
generation 8 complete, average fitness: 2.07957
generation 9 complete, average fitness: 2.08329
generation 10 complete, average fitness: 2.06984
generation 11 complete, average fitness: 2.06444
generation 12 complete, average fitness: 2.08479
generation 13 complete, average fitness: 2.04789
generation 14 complete, average fitness: 1.99366
generation 15 complete, average fitness: 1.97396
generation 16 complete, average fitness: 1.95302
generation 17 complete, average fitness: 1.96293
generation 18 complete, average fitness: 1.98064
generation 19 complete, average fitness: 1.92724
generation 20 complete, average fitness: 1.91759
Acovea completed its analysis at 2005 Apr 26 19:32:31
Optimistic options:
-fno-crossjumping (1.715)
-funroll-all-loops (2.421)
Pessimistic options:
-fno-guess-branch-probability (-2.414)
-fno-if-conversion (-2.523)
-fstrength-reduce (-2.034)
-funroll-loops (-2.36)
-fbranch-target-load-optimize (-1.545)
-mfpmath=sse,387 (-2.251)
Acovea's Best-of-the-Best:
gcc -lrt -lm -std=gnu99 -O1 -march=opteron -fno-defer-pop -fno-cprop-registers
-fno-if-conversion2 -fno-delayed-branch -fno-crossjumping -foptimize-sibling-calls
-fcse-skip-blocks -fgcse -fexpensive-optimizations -frerun-cse-after-loop -fcaller-saves
-fforce-mem -fpeephole2 -fschedule-insns2 -fregmove -fdelete-null-pointer-checks
-freorder-blocks -fsched-interblock -fsched-spec -freorder-functions -falign-loops
-falign-labels -funit-at-a-time -falign-functions -fmove-all-movables -fpeel-loops
-funroll-all-loops -mieee-fp -mno-push-args -maccumulate-outgoing-args -mno-align-stringops
-mfpmath=387 -fno-math-errno -ffinite-math-only -fno-signaling-nans -o /tmp/ACOVEAE47312F4
benchmarks/huffbench.c
Acovea's Common Options:
gcc -lrt -lm -std=gnu99 -O1 -march=opteron -funroll-all-loops -o /tmp/ACOVEA0D09D98E
benchmarks/huffbench.c
-O1:
gcc -lrt -lm -std=gnu99 -O1 -march=opteron -o /tmp/ACOVEAC0CBCDFC benchmarks/huffbench.c
-O2:
gcc -lrt -lm -std=gnu99 -O2 -march=opteron -o /tmp/ACOVEA8F7BE999 benchmarks/huffbench.c
-O3:
gcc -lrt -lm -std=gnu99 -O3 -march=opteron -o /tmp/ACOVEA82916DC5 benchmarks/huffbench.c
-O3 -ffast-math:
gcc -lrt -lm -std=gnu99 -O3 -march=opteron -ffast-math -o /tmp/ACOVEA6CC0EFFF
benchmarks/huffbench.c
-Os:
gcc -lrt -lm -std=gnu99 -Os -march=opteron -o /tmp/ACOVEACE8754B7 benchmarks/huffbench.c
A relative graph of fitnesses:
Acovea's Best-of-the-Best: ************************************** (2.55366)
Acovea's Common Options: ******************************************* (2.86788)
-O1: ********************************************** (3.0752)
-O2: *********************************************** (3.12343)
-O3: *********************************************** (3.1277)
-O3 -ffast-math: ************************************************** (3.31539)
-Os: ************************************************* (3.30573)
Acovea is done.
An "optimistic" option was common in "good" solutions during the entire evolutionary process. A "pessimistic" option, on the other hand, was absent from the "good" solutions, either because it hurt run times or simply made no difference at all and was ignored as a "junk gene". It's important to realize that Acovea's best solution may contain options that had no practical effect on code generation; they didn't hurt, didn't help, and were just "there." Such it is human genes for producing tails; most of us have the genes (option), but it doesn't express itself.
Acovea reports two potentially interesting solutions. The "Common Options" reflect elements shared by the best organisms across all of the final populations. In a few cases, the "Common Options" may perform best—but the usual "winner" is given by the "Best-of-the-Best" solution, which is the most fit organism among all populations. The "Best-of-the-Best" may include "junk genes" in the form of options that had no significant influence (from the standpoint of evolution).
Acovea also reports on "baseline" tests. The configuration file supplies these solutions explicitly, for comparison with Acovea's evolved solutions.
The text graph show the relative fitness of Acovea's solutions and the baselines. A shorter line means a better solution. In the example output, Acovea's "Best-of-the-Best" produces code that is substantially faster than any of the baselines (which use GCC's predefined -On optimization sets).
As always, I look forward to considered comments.
-- Scott

