Thaddy
Posts: 174
Joined: Wed Mar 06, 2013 11:28 am

Which is the right FPU to compile for?

Tue Feb 18, 2014 7:56 am

I always thought the FPU in the Pi is a VFPV2, so I optimized for that.
But last night I noticed that some binaries in the Raspbian Wheezy distro are compiled for VFPV3-D16.

Which is the correct one to compile for?
And if VFPV3-D16 is supported, has it any advantages?

In this case Google wasn't my friend it seems, but readelf confirms that some binaries are compiled for VFPV3-D16.

I am running Raspbian Wheezy +rpi-update from two days ago.

Tnx.

User avatar
Paeryn
Posts: 2952
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Which is the right FPU to compile for?

Tue Feb 18, 2014 9:53 pm

Yes, the Pi only has a VFPv2. VFPv3-D16 is for ARMv7 processors without NEON.

The main difference between v2 and v3-D16 is the extra conversion instructions between float and fixed-point, and the ability to load the fp registers with a constant number.
I can't see where gcc would be able to make direct use of the converts, and from testing it appears that gcc will only try to use the constant loading if you compile for VFPv3, when compiling for VFPv3-D16 it still loads the fp registers from a memory location.

So, since gcc isn't making use of the extra fp instructions which the Pi doesn't have, the compiled code will still run fine on the Pi.
She who travels light — forgot something.

Thaddy
Posts: 174
Joined: Wed Mar 06, 2013 11:28 am

Re: Which is the right FPU to compile for?

Tue Feb 25, 2014 1:05 pm

Thank you for your elaborate answer.
So basically when I am tinkering with compiler building /code generation itself, build it for VFPV2 code generation. I will leave my stuff as is, i.e. VFPV2.

Thaddy

Return to “C/C++”