Building CPU optimized packages

If you are owner of a Pentium, an AMD K6, Athlon or Athlon-XP CPU, you might want to use compiler optimizations to compile your version of Kwave that is running some percents faster. The gain in speed will be up to 30% on some systems, whereas the functions dealing with signal manipulation and all functions that do complex time-frequency operations (like FFT and Sonagram) will profit most from it.

You do not need to understand much about programming for using an optimized compiler to compile Kwave, but maybe you will need some time to get the compiler itself working and installed.

RPM optimizations

You can easily compile the RPM package optimized for Athlon, Athlon-XP, Pentium and Pentium Pro (and some other CPUs) by using some defines in your rpmrc file. You can either modify your system's rpmrc file in /usr/lib/rpm or the .rpmrc file in your home directory. There you can specify option lines like these:

optflags: i586 -O2 -march=pentium -DNDEBUG -fomit-frame-pointer
optflags: i686 -O2 -march=pentiumpro -DNDEBUG -fomit-frame-pointer
optflags: athlon -O2 -march=athlon -DNDEBUG -fomit-frame-pointer
optflags: k6 -O3 -march=k6 -DNDEBUG -fomit-frame-pointer
optflags: k7 -O3 -march=athlon-xp -DNDEBUG -fomit-frame-pointer

(I found those nice tricks at Thanks to Matthias Düsterhöft!).

This means that on a k7 architecture the rpm package will be compiled using -O3 -march=athlon-xp -DNDEBUG -fomit-frame-pointer as compiler option and so on, you might extend or adapt these to your own needs. The settings apply to all of the sections before in all places where rpmbuild -ta is used or where a binary RPM is to be created out of a source rpm using rpmbuild --rebuild.


If rpm refuses to install your package because it seems not to fit to your computer's architecture, you can normally just install an optimized package by specifying the additional parameter --ignorearch and don't care.

How to pass optimizer options to the compiler manually

The invocation of the compiler is quite simple. It normally is sufficient to set the environment variables CFLAGS and CXXFLAGS in the correct way and then compile as usual. For the best settings please consult the documentation or homepage of the corresponding compiler.

If you build Kwave from a source tree (unpacked tar.bz2 or from GIT) the flags need to be specified before the call. For example:

% CFLAGS="-O4 -march=athlon-xp -mcpu=athlon-xp -pipe" \
  CXXFLAGS="-O4 -march=athlon-xp -mcpu=athlon-xp -pipe" \
  cmake [source directory]

If you re-build Kwave from a source rpm package, please follow the instruction in the previous section.