Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting appropriate ARM -mfpu option in gcc based on CPU features

My CPU has following CPU features

cat /proc/cpuinfo 
Processor       : ARMv7 Processor rev 4 (v7l)
processor       : 0
BogoMIPS        : 1192.96

processor       : 1
BogoMIPS        : 1197.05

Features        : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 4

Hardware        : sun7i
Revision        : 0000

And gcc sets

-march=armv7ve -mfloat-abi=hard -mfpu=vfpv3-d16 -meabi=5

options for

cat main.c
#include <stdio.h>

void main()
{
    printf("Hello World!\n");
}

compiled with

gcc -march=native -mtune=native -Q -v main.c

Isn't neon-vfpv4, which seems to be supported by CPU features, is superior to vfpv3-d16, which gcc sets?

I got only vague explanation of what vfpv3-d16 is from ARM's documentation and nothing on neon-vfpv4.

I'm using gcc 4.9.1

like image 761
Vanilla Gorilla Avatar asked Apr 03 '15 08:04

Vanilla Gorilla


1 Answers

-march and -mtune (or -mcpu as a shorthand for both) only control the CPU options for instruction selection and scheduling. As an example, with a GCC 4.8-based cross-toolchain, when I do this:

 arm-linux-gnueabihf-gcc -mcpu=arm250 -v -c test.c

I get this:

...
COLLECT_GCC_OPTIONS='-mcpu=arm250' '-v' '-c' '-mfloat-abi=hard'
  '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu'
...

which is clearly nonsense - the ARM250 predates VFP (and even Thumb) by a long way - because for any unspecified options it's just passing through whatever was configured as the default:

...
Configured with:
  ... --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 ...
    ... --with-mode=thumb --with-float=hard

Your Cortex-A7 indeed supports full VFPv4 and NEON, so passing -mfpu=neon-vfpv4 to override the default would be the right thing to do. Unfortunately there doesn't seem to be an equivalent -mfpu=native option (at least documented - I don't have a native toolchain handy to check).

like image 196
Notlikethat Avatar answered Oct 05 '22 00:10

Notlikethat