How can I tell if floating point arithmetic is performed in hardware or software?

I could find the processor's name and Google it, but is there a way to do it in a BASH script? For instance, is there something saved in a system file that I could read?

UPDATE: output of /proc/cpuinfo on Intel:

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 69
model name      : Intel(R) Core(TM) i3-4010U CPU @ 1.70GHz
stepping        : 1
microcode       : 0x17
cpu MHz         : 782.000
cache size      : 3072 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes  <-- !!!
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid
bogomips        : 3392.25
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

output of /proc/cpuinfo on RPi (using Raspian v7):

processor       : 0
model name      : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 2.00
Features        : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2708
Revision        : 000e
Serial          : 000000007b455c14
  • Looking up the processor name doesn't help you, the availability of floating point hardware doesn't mean it is being used, at that depends on the software (if you need predictable results, you better not use the hardware for floating point). – Anthon Jul 16 '14 at 11:34
  • True, I don't know if it will be used, unless I know it's not there. Then I definitely know it is not being used. ;) – MrUser Jul 16 '14 at 12:05

Well, you can tell if your CPU has FPU capabilities with the data stored in /proc/cpuinfo and filter it with grep fpu

$ grep "fpu" /proc/cpuinfo

fpu     : yes
fpu_exception   : yes
flags       : fpu vme de pse ...

And for info, what type of CPU are you playing with? :)

EDIT for ARM proc, look for vector floating point unit (vfp), some info here.


# cat /proc/cpuinfo
Processor       : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 697.95
Features        : ... vfp ...
  • thanks for the quick response. Yes! That works for my laptop (Intel), but it doesn't work on my RaspberryPi (ARM). I'm doing a system profiler, so I want to be able to get this information from many different CPUs with different Linux distributions. – MrUser Jul 16 '14 at 11:01
  • are you saying you do not have the /proc/cpuinfo on your install? which distro have you got on RPi? – fduff Jul 16 '14 at 11:32
  • It's there, but the fpu field is not. I edited the post with the output. – MrUser Jul 16 '14 at 11:50
  • On ARM, vfp is the flag you are looking for. – aquaherd Jul 16 '14 at 12:02

I think that what you want is to do some benchmarks, and compare with other processors. Otherwise, whether floating-point is performed is hardware or software doesn't make much sense. Actually, it can be both. For instance, subnormals are sometimes emulated in software. Some operations may also be implemented in software but still based on some other hardware FP instructions: division and square root on the Itanium (thanks to the FMA); and elementary functions (exp, log, sin, cos...) in general (x86 processors have hardware implementation of such functions, but with limitations concerning the accuracy). In C, the long double type has a mixed hardware-software implementation on PowerPC (the double-double arithmetic).

If you want to get system information that could be related to the floating-point implementation, then get most information from /proc/cpuinfo, but the C library version may be also useful (for math functions).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.