Martin Guy <martinwguy@gmail.com> 8 September 2009
Contents
We have "no known bugs" again. Yay. |
Image found on the "Gears of War" site during a web search for "Maverick 9312" |
This follows on from Hasjim Williams' earlier work with gcc-4.1.2 and 4.2.0, a bundle of his more recent ideas and more hacks from me.
If you want to understand the patches themselves, there is an article about the MaverickCrunch FPU and GCC's problems with it on the Debian wiki and I have added commentary at the top of the individual patch files for gcc-4.3.4 or for gcc-4.2.4.
Discussion about this (and other issues with these chips) happens on
the linux-cirrus mailing list.
What it does
The 20090908 version
make check-gcc RUNTESTFLAGS="ieee.exp --target_board=unix/-mcpu=ep9312/-mfpu=maverick/-mfloat-abi=softfp/-mieee"
gcc-4.3-crunch -mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -mieee -o paranoia2 paranoia2.c ./paranoia2
# double precision floating point ./configure CC=gcc-4.3-crunch CFLAGS="-mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -ffast-math -O2" make && make -C tests check # single precision floating point make clean ./configure --enable-float CC=gcc-4.3-crunch CFLAGS="-mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -ffast-math -O2" make && make -C tests check
# double precision floating point ./configure CC=gcc-4.3-crunch CFLAGS="-mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -ffast-math -O2" make; cd tests; perl check.pl -a # single precision floating point make clean ./configure --enable-single CC=gcc-4.3-crunch CFLAGS="-mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -ffast-math -O2" make; cd tests; perl check.pl -a
./configure CC=gcc-4.3-crunch CFLAGS="-mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -ffast-math -O2" make check
./configure CC=gcc-4.3-crunch CFLAGS="-mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -ffast-math -O2" make test
svn co http://svn.xiph.org/trunk/vorbis cd vorbis; ./autogen.sh ./configure CC=gcc-4.3-crunch CFLAGS="-mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp" make; test/test
./config vi Makefile :/^CC= gcc/s/$/-4.3-crunch/ :/^CFLAG= /s/$/ -mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp/ :wq make make test
CC=gcc-4.3-crunch CCFLAGS=" ... -mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -ffast-math" MULHACK=-DUSE_FLOAT_MUL make time bin/toast < intro.l > /dev/null
The results, on a 200MHz Cirrus Logic EP9307 revision E1 under Debian "armel":
| Compiler/options | FFTW mflops | LAME seconds | libgsm(*) seconds |
|---|---|---|---|
| gcc-4.3-crunch -mcpu=ep9312 -O2 -ffast-math (softfloat) | 3.59 | 365 | 23.5 |
| gcc-4.3-crunch -mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -O2 -ffast-math -mieee | 3.83 | 276 | - |
| gcc-4.3-crunch -mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -O2 -ffast-math | 5.94 | 145 | 5.72 |
| gcc-4.2-crunch -mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -O2 -ffast-math | 6.13 | 138 | 5.72 |
In other words, using the full Maverick instruction set, LAME is 2.5 times faster than with softfloat, and when just using the -mieee subset, it runs 25% faster or about half the speed of the full set, and gcc-4.2 produces significantly faster code than gcc-4.3.
(*) Although crunch libgsm is 4 times faster than softfloat, libgsm also has a
fixed-point encoder, selected with MULHACK='', which is faster still
(the same is true of the speex encoder).
Download
The installable binary tarballs,
Debian packages and patches
are kindly hosted by SimpleMachines
who also funded me to do some of this work.
There is also a repository of prebuilt crunch-accelerated Debian packages
for the "armel lenny" release. See
simplemachines.it/debian
Using it
To get MaverickCrunch instructions you always have to use:
gcc-4.3-crunch -mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfpOther relevant options are:
./configure CC=gcc-4.3-crunch CFLAGS="-mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -ffast-math -O2"However it's usually less trouble to make a directory of wrapper scripts replacing all of GCC's command names with the crunch version:
mkdir ~/crunch cat > ~/crunch/gcc << EOF #! /bin/sh exec gcc-4.3-crunch -mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp -fno-signed-zeros "$@" EOF chmod 755 ~/crunch/gcc ln -s gcc ~/crunch/cc ln -s gcc ~/crunch/gcc-4.3 ln -s gcc ~/crunch/arm-linux-gnueabi-gccand fool the build system into using them
PATH=~/crunch:$PATH ./configure PATH=~/crunch:$PATH make PATH=~/crunch:$PATH make installor, to build accelerated Debian packages:
apt-get source foobar sudo apt-get build-dep foobar cd foobar-* PATH=~/crunch:$PATH dpkg-buildpackage -rfakeroot -B cd .. dpkg -i foobar*.deb
Memory: If you have less than 160MB of physical RAM plus 64MB swap, you will need to stop the compilation, compile that one file without optimisation by saying make CFLAGS=-g and then interrupt it and carry on as usual when that one file has been done.
Disk space: The full sources unpack to 500MB (360MB for gcc-4.2) and a further 200MB (140MB for gcc-4.2) are needed to build the C compiler. If you have less space, you can fetch a "gcc-core" source tarball instead, which only contains the C compiler and unpacks to about 200MB, for a total of 400MB when built.
wget ftp://sourceware.org/pub/gcc/releases/gcc-4.3.4/gcc-4.3.4.tar.bz2
tar xjf gcc-4.3.4.tar.bz2
cd gcc-4.3.4
for a in `cat ../gcc-4.3.4-patches/series`
do
patch -p1 < ../gcc-4.3.4-patches/$a
done
cd ..
mkdir gcc-4.3.4-build
cd gcc-4.3.4-build
# The same basic configuration as Debian
../gcc-4.3.4/configure --disable-nls --enable-shared --with-system-zlib \
--without-included-gettext --enable-threads=posix \
--enable-clocale=gnu --enable-mpfr --disable-libssp \
--disable-bootstrap --enable-languages=c --with-arch=armv4t \
--program-suffix=-4.3-crunch armv4tl-crunch-linux-gnueabi
make
../s/install
../s/tarball gcc-4.3-crunch
The tarball script dumps a .tar.gz
of the essential installed files and another of the source patchset in the
../packages directory.
There is also a test directory here with some program
fragments that I used to probe hardware bug presence and characteristics.
Thanks
Thanks to Hasjim Williams for the work that this is based on,
to David Herring for prompting me to start working on this again and to
simplemachines.it
for funding the completion of these patches and for hosting the tarballs.
| Martin Guy <martinwguy@gmail.com> | Useful? Donate! |