All Forums
 Embedded Linux
 Linux FAQ
 VFP optimizations
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

jhess

135 Posts

Posted - 30 Dec 2008 :  14:05:41  Show Profile  Email Poster
VFP optimizations

VFP (Vector Floating Point) is an ARM hardware floating point coprocessor. Using VFP can potentially significantly increase the speed of software that requires floating point computation. This document will explain how to use VFP on your Eurotech systems. Eurotech provides some prebuilt software optimized to use VFP. We also provide a compiler that can be used to build your own software with VFP optimizations.

Hardware prerequisites
You will need a board that supports VFP, such as the Bitsy G5 (Freescale i.MX31) or Sphere II (Cirrus Logic EP9315). If you follow these instructions only to have programs fail with an "Illegal instruction" error, your board does not support VFP.
Software prerequisites
Your board must be using an EABI kernel and userspace. EABI supports mixing VFP instructions with the regular FPA instructions. You should have either a full (EABI) root filesystem installed on the board, which includes a native compiler, or a suitable cross compiler installed elsewhere.
The VFP apt repository
We provide an apt repository containing versions of some packages built with VFP optimizations. The following commands can be run to configure apt-get to download software from this repository:
echo deb http://support.eurotech-inc.com/developers/linux/debian ads vfp >> /etc/apt/sources.list
apt-get update
The vfp-configure program
This program can be used to configure GCC to emit VFP instructions by default. The program will be included in full root filesystems released by Eurotech in 2009, or you can download it from here.

If you download the program by hand, be sure to make it executable, and put it in a directory in your path. For example:
wget http://support.eurotech-inc.com/developers/linux/files/tools/vfp-configure
chmod +x vfp-configure
mv vfp-configure /usr/sbin/
As root, run "vfp-configure on" to enable use of VFP, and "vfp-configure off" to revert back to normal.

If vfp-configure run on a board with a EABI full root filesystem, it will automatically determine what the current version of GCC is, and how to modify it.

If vfp-configure is run on a system used for cross compiling, it will require you pass it a second parameter, specifying the location of the cross compiler's library directory. For example, if your cross compiler is installed in "/usr/lib/gcc/arm-linux-gnueabi/4.2/", you would run "vfp-configure on /usr/lib/gcc/arm-linux-gnueabi/4.2/"
Building a test program with VFP instructions
Once you have successfully run vfp-configure, GCC will be configured to emit VFP instructions by default. To test this, you can use this test program:
#include 
#include

int
main(void)
{
double twopi=M_PI;
twopi*=2;
printf("2*pi = %.10f\n", twopi);
return 0;
}
Save the program to a file name "test.c" and run "make test" to compile it. Then use "./test" to run the program and verify that it prints "2*pi = 6.2831853072".

To verify that the program was built with VFP instructions, you can use objdump to disassemble it. This will list all uses of the VFP FADDD instruction used:
objdump -S test |grep FADDD
VFP optimized glibc
Glibc's math library (libm) can be built to use VFP instructions. Installing such an optimized build on your board will significantly improve the speed of all programs that are heavy users of libm.

For example, the whetstone benchmark measures floating point performance. The whetstone.c benchmark performs four times as fast when run using a VFP build of libm.
BitsyG5, old abi, non VFP libm: 14.3 MIPS
BitsyG5, EABI, non VFP libm: 25.0 MIPS
BitsyG5, EABI, VFP libm: 100.0 MIPS
A build of glibc is available in the VFP apt repository. After configuring your board to use this repository, as documented above, you can install the VFP optimised glibc with this command:
apt-get install libc6
Or, to build glibc with VFP by hand, run the following set of commands on a board with the full root filesystem:
vfp-configure on
apt-get build-dep glibc
apt-get source -b glibc
dpkg -i libc6*.deb
Note that the same procedure can be used to build VFP versions of other packages as well.
VFP optimized MESA
Mesa is a 3-D graphics library with an API which is very similar to that of OpenGL. An optimised Mesa with VFP instructions can significantly improve the speed of 3-D applications.

The glxgears demo program is frequently used as a simple Mesa performance benchmark. When Mesa is built with VFP, glxgears runs at twice the frame rate as the non-optimised version.
Turbo G5, EABI, non VFP mesa: glxgears 27.120 FPS
Turbo G5, EABI, VFP mesa: glxgears 53.870 FPS
A build of mesa is available in the VFP apt repository. After configuring your board to use this repsotory, as documented above, you can install the VFP optimised mesa with this command:
apt-get install libgl1-mesa-swx11 libglu1-mesa libglw1-mesa mesa-utils
Or, to build mesa with VFP by hand, run the following set of commands on a board with the full root filesystem:
vfp-configure on
apt-get build-dep mesa
apt-get source -b mesa
dpkg -i libgl1-mesa-swx11*.deb libglu1-mesa*.deb libglw1-mesa*.deb mesa-utils*.deb

  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.02 seconds. Snitz Forums 2000