cancel
Showing results for 
Search instead for 
Did you mean: 

Why are floating point operations so slow on my Nucleo

manx
Associate III

I wanted to check speed of trigonometric operations on my Nucleo L432KC. I toggle pin state and look at my oscilloscope. I use Arduino IDE.

The calculations for trigonometric functions turned out to take several hundred of clock cycles. I was disappointed, but I didn't know what to expect. But then I checked 1./x, and it also turned out to be terribly slow, although, according to my understanding, it should be 12 cycles. What could be wrong?

<too big for one post>

It doesn't matter if I use functions ending with 'f' or not and the functions without 'f' become drastically even much slower when I try casting variables to double. So probably the calculations are in floats. Also, according to my understanding or the compilation output, the FPU is being used:

<too big for one post>

Does anyone have any idea what could be wrong?

7 REPLIES 7
manx
Associate III
#include "Arduino.h"
//#include <EEPROM.h>
#include <SPI.h>
#include <Wire.h>
 
HardwareSerial Serial1(PA10, PA9);
 
#if defined STM32L432xx
#define DUMMP GPIOA->ODR// Arduino pin A1
#define DUMMB 1		//
#define DUMMO A1
#define TESTP GPIOA->ODR// Arduino pin A2
#define TESTB 3		//
#define TESTO A2
#endif
 
 
void fastSerialInit() {
	Serial1.begin(1000000);
	Serial2.begin(115200);
}
 
void testSpeedSetup() {
	pinMode(TESTO, OUTPUT);
}
 
void setup() {
	fastSerialInit();
	testSpeedSetup();
}
 
void loop() {
	testSpeed();
}
 
void testSpeed() {
	for (int i = 0; i <= 10000; i++) {
		// some value changing in a loop to make sure the testing calculation is not optimized away
		float a = (1./10000.) * i;
		float b = 1. - a;
		float res;
 
		// timing pin up
		bitSet(TESTP, TESTB);
 
		// Tested operation
		//res = sin(a*6);		// up to 10 micros	-> 800 clocks (@80 MHz)
		//res = sinf(a);
		//res = cos(a*6);		// up to 10 micros	-> 800 clocks
		//res = cosf(a);
		//res = asin(a);		// up to 9.5 micros	-> 760 clocks
		//res = asinf(a);
		//res = atan2(a, b);		// up to 5.8 micros	-> 460 clocks
		//res = atan2f(a, b);
		//res = sqrt(a);		// up to 5.5 micros	-> 440 clocks
		//res = sqrtf(a);
		//res = 1. / a;			// up to 4.5 micros	-> 360 clocks
		res = 1.f / a;
 
		// timing pin down
		bitClear(TESTP, TESTB);
 
		// some dummy output to make sure the testing calculation is not optimized away
		Serial2.println(res);
		delayMicroseconds(100);
	}
}
 
 

manx
Associate III
/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/andrzej/Library/Arduino15/packages -hardware /Users/andrzej/Documents/Arduino/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/andrzej/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/andrzej/Documents/Arduino/libraries -fqbn=STM32:stm32:Nucleo_32:pnum=NUCLEO_L432KC,upload_method=STLink,xserial=generic,usb=none,xusb=FS,opt=oslto,rtlib=nano -vid-pid=0483_374B -ide-version=10809 -build-path /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099 -warnings=default -build-cache /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_cache_594596 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.CMSIS.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0 -prefs=runtime.tools.CMSIS-5.3.0.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0 -prefs=runtime.tools.STM32Tools.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/STM32Tools/1.2.1 -prefs=runtime.tools.STM32Tools-1.2.1.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/STM32Tools/1.2.1 -prefs=runtime.tools.arm-none-eabi-gcc.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update -prefs=runtime.tools.arm-none-eabi-gcc-6-2017-q2-update.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update -verbose /Users/andrzej/Documents/sloeber-workspace/NucleoTest/NucleoTest.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/andrzej/Library/Arduino15/packages -hardware /Users/andrzej/Documents/Arduino/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/andrzej/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/andrzej/Documents/Arduino/libraries -fqbn=STM32:stm32:Nucleo_32:pnum=NUCLEO_L432KC,upload_method=STLink,xserial=generic,usb=none,xusb=FS,opt=oslto,rtlib=nano -vid-pid=0483_374B -ide-version=10809 -build-path /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099 -warnings=default -build-cache /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_cache_594596 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.CMSIS.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0 -prefs=runtime.tools.CMSIS-5.3.0.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0 -prefs=runtime.tools.STM32Tools.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/STM32Tools/1.2.1 -prefs=runtime.tools.STM32Tools-1.2.1.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/STM32Tools/1.2.1 -prefs=runtime.tools.arm-none-eabi-gcc.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update -prefs=runtime.tools.arm-none-eabi-gcc-6-2017-q2-update.path=/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update -verbose /Users/andrzej/Documents/sloeber-workspace/NucleoTest/NucleoTest.ino
Using board 'Nucleo_32' from platform in folder: /Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0
Using core 'arduino' from platform in folder: /Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0
bash -c "[ -f /Users/andrzej/Documents/sloeber-workspace/NucleoTest/build_opt.h ] || (mkdir -p /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch && touch /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/build_opt.h)"
Detecting libraries used...
/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb @/var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/build_opt.h -c -Os -flto -w -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -I/Users/andrzej/Documents/sloeber-workspace/NucleoTest -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/avr -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32 -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/LL -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/hid -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/cdc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Inc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Src/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/STM32L4xx/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -w -x c++ -E -CC -DSTM32L4xx -DARDUINO=10809 -DARDUINO_NUCLEO_L432KC -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"NUCLEO_L432KC\"" -DSTM32L432xx -DHAL_UART_MODULE_ENABLED -I/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0/CMSIS/Core/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/variants/NUCLEO_L432KC /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/NucleoTest.ino.cpp -o /dev/null
/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb @/var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/build_opt.h -c -Os -flto -w -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -I/Users/andrzej/Documents/sloeber-workspace/NucleoTest -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/avr -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32 -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/LL -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/hid -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/cdc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Inc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Src/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/STM32L4xx/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -w -x c++ -E -CC -DSTM32L4xx -DARDUINO=10809 -DARDUINO_NUCLEO_L432KC -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"NUCLEO_L432KC\"" -DSTM32L432xx -DHAL_UART_MODULE_ENABLED -I/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0/CMSIS/Core/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/variants/NUCLEO_L432KC -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/SPI/src /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/NucleoTest.ino.cpp -o /dev/null
/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb @/var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/build_opt.h -c -Os -flto -w -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -

manx
Associate III
I/Users/andrzej/Documents/sloeber-workspace/NucleoTest -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/avr -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32 -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/LL -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/hid -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/cdc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Inc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Src/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/STM32L4xx/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -w -x c++ -E -CC -DSTM32L4xx -DARDUINO=10809 -DARDUINO_NUCLEO_L432KC -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"NUCLEO_L432KC\"" -DSTM32L432xx -DHAL_UART_MODULE_ENABLED -I/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0/CMSIS/Core/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/variants/NUCLEO_L432KC -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/SPI/src -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/Wire/src /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/NucleoTest.ino.cpp -o /dev/null
Using cached library dependencies for file: /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/sloeber.ino.cpp
Using cached library dependencies for file: /Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/SPI/src/SPI.cpp
Using cached library dependencies for file: /Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/Wire/src/Wire.cpp
Generating function prototypes...
/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb @/var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/build_opt.h -c -Os -flto -w -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -I/Users/andrzej/Documents/sloeber-workspace/NucleoTest -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/avr -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32 -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/LL -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/hid -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/cdc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Inc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Src/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/STM32L4xx/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -w -x c++ -E -CC -DSTM32L4xx -DARDUINO=10809 -DARDUINO_NUCLEO_L432KC -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"NUCLEO_L432KC\"" -DSTM32L432xx -DHAL_UART_MODULE_ENABLED -I/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0/CMSIS/Core/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/variants/NUCLEO_L432KC -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/SPI/src -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/Wire/src /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/NucleoTest.ino.cpp -o /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/preproc/ctags_target_for_gcc_minus_e.cpp
/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
Using previously compiled file: /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/sloeber.ino.cpp.o
/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb @/var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/build_opt.h -c -Os -flto -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -I/Users/andrzej/Documents/sloeber-workspace/NucleoTest -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/avr -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32 -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/LL -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/hid -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/cdc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Inc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Src/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/STM32L4xx/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -DSTM32L4xx -DARDUINO=10809 -DARDUINO_NUCLEO_L432KC -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"NUCLEO_L432KC\"" -DSTM32L432xx -DHAL_UART_MODULE_ENABLED -I/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0/CMSIS/Core/Include/ -

manx
Associate III
I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/variants/NUCLEO_L432KC -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/SPI/src -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/Wire/src /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/NucleoTest.ino.cpp -o /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/NucleoTest.ino.cpp.o
Compiling libraries...
Compiling library "SPI"
Using previously compiled file: /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/libraries/SPI/SPI.cpp.o
Compiling library "Wire"
Using previously compiled file: /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/libraries/Wire/Wire.cpp.o
Compiling core...
Using previously compiled file: /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/core/PeripheralPins.c.o
Using previously compiled file: /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/core/variant.cpp.o
Using precompiled core: /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_cache_594596/core/core_0228bd4c0995805c4c5ae2286cef5f8c.a
Linking everything together...
/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update/bin/arm-none-eabi-gcc -x c -E -P -DLD_MAX_SIZE=262144 -DLD_MAX_DATA_SIZE=65536 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb @/var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/build_opt.h -c -Os -flto -w -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD -I/Users/andrzej/Documents/sloeber-workspace/NucleoTest -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/avr -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32 -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/LL -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/hid -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/cores/arduino/stm32/usb/cdc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Inc/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/STM32L4xx_HAL_Driver/Src/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/STM32L4xx/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -DSTM32L4xx -DARDUINO=10809 -DARDUINO_NUCLEO_L432KC -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"NUCLEO_L432KC\"" -DSTM32L432xx -DHAL_UART_MODULE_ENABLED -I/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0/CMSIS/Core/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Include/ -I/Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/system/Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/ /Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/variants/NUCLEO_L432KC/ldscript.ld -o /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/preproc.ld
/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update/bin/arm-none-eabi-gcc -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Os -flto --specs=nano.specs -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -T/var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/preproc.ld -Wl,-Map,/var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/NucleoTest.ino.map -L/Users/andrzej/Library/Arduino15/packages/STM32/tools/CMSIS/5.3.0/CMSIS/Lib/GCC/ -larm_cortexM4l_math -o /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/NucleoTest.ino.elf -L/var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099 -Wl,--start-group /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/NucleoTest.ino.cpp.o /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/sketch/sloeber.ino.cpp.o /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/libraries/SPI/SPI.cpp.o /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/libraries/Wire/Wire.cpp.o /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/core/PeripheralPins.c.o /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/core/variant.cpp.o -Wl,--whole-archive /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_cache_594596/core/core_0228bd4c0995805c4c5ae2286cef5f8c.a -Wl,--no-whole-archive -lc -Wl,--end-group -lm -lgcc -lstdc++
/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update/bin/arm-none-eabi-objcopy -O binary /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/NucleoTest.ino.elf /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/NucleoTest.ino.bin
/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update/bin/arm-none-eabi-objcopy -O ihex /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/NucleoTest.ino.elf /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/NucleoTest.ino.hex
Using library SPI at version 1.0 in folder: /Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/SPI 
Using library Wire at version 1.0 in folder: /Users/andrzej/Library/Arduino15/packages/STM32/hardware/stm32/1.5.0/libraries/Wire 
/Users/andrzej/Library/Arduino15/packages/STM32/tools/arm-none-eabi-gcc/6-2017-q2-update/bin/arm-none-eabi-size -A /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/NucleoTest.ino.elf
Sketch uses 17768 bytes (6%) of program storage space. Maximum is 262144 bytes.
Global variables use 1956 bytes (2%) of dynamic memory, leaving 63580 bytes for local variables. Maximum is 65536 bytes.
/Users/andrzej/Library/Arduino15/packages/STM32/tools/STM32Tools/1.2.1/tools/macosx/stlink_upload cu.usbmodem1423 {upload.altID} {upload.usbID} /var/folders/1d/6_x8cjs50xvg650pc3n5wc8c0000gn/T/arduino_build_809099/NucleoTest.ino.bin 

Looks to be telling GNU/GCC the right things

arm-none-eabi-g++ -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb

Perhaps it is not linking a suitable library, or lacks code enabling the FPU. The FPU is pretty simple, it doesn't do transcendental stuff.

I'm using the L432KB with Keil, not the Arduino IDE nor GNU/GCC

Tips, Buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

Thanks. I really hoped this would be a solution. I thought that maybe one really needs to enable FPU manually (which would be weird with Arduino beginner friendliness, but maybe). But no. SCB->CPACR already reads F00000. So the FPU is already enabled for me.

Ok, I think I've found the culprit: Link Time Optimization.

When I turn it OFF, simple operations are fast: division (reciprocal) in my case is 2 cycles, sqrt is most often 20 cycles. Strangely, sine is 2 (two) cycles as well. But hey, who am I to complain. The output values look fine at a first glance.

atan2 and asin are unfortunately as slow as they were before.