Ok, it seems this is the fix:
In rules.mk:
Code: Select all
MCFLAGS = -mcpu=$(MCU) -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
in Makefile:
Code: Select all
# End of user defines
##############################################################################
ifeq ($(USE_FPU),yes)
USE_OPT += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
DDEFS += -DCORTEX_USE_FPU=TRUE
else
DDEFS += -DCORTEX_USE_FPU=FALSE
endif
Now the above test demo with
hard shows:
Code: Select all
THIS IS THE START
Elapsed time 1000x : 9 millis
Elapsed time : 0.00899 millis
Result : 9.00001
THIS IS THE END
The same results with
softfp.Code: Select all
THIS IS THE START
Elapsed time 1000x : 9 millis
Elapsed time : 0.00899 millis
Result : 9.00001
THIS IS THE END
The results with FPU off (in Makefile) and with the original rules.mk, single precision ( q32= asinf(acosf(atanf(tanf(cosf(sinf(q32)))))); ):
Code: Select all
THIS IS THE START
Elapsed time 1000x : 59 millis
Elapsed time : 0.05900 millis
Result : 9.00001
THIS IS THE END
The results with FPU off (in Makefile) and with the original rules.mk, but double precision ( q32= asin(acos(atan(tan(cos(sin(q32)))))); ) :
Code: Select all
THIS IS THE START
Elapsed time 1000x : 114 millis
Elapsed time : 0.11400 millis
Result : 9.00000
THIS IS THE END
So 9 ms against 114ms (13x faster than double precision), and 9ms against 59ms (6.5x faster than single precision) - unbelievable, there still must be an issue somewhere
