Commit 58a479d6 authored by Zach Fredin's avatar Zach Fredin

added single-precision calculation, updated readme.md

parent 780a7a33
......@@ -3,4 +3,10 @@ This test follows the standard [CBA pi benchmark](https://gitlab.cba.mit.edu/pub
![pi capture](pi_capture.png)
The measurement shows a total calculation time of 12.91 s, including a [for these purposes] negligible delay to toggle the GPIOs. The FPU is set up with flags `-mfloat-abi=hard -mfpu=fpv4-sp-d16`, while the compiler includes `-O3`. Based on the pi benchmark calculation rate of 5 FLOPS per cycle iteration, this test suggests the STM32F412 is running at (5 * 1E6) / (12.91) = 0.387 MFLOPS. At the current 84 MHz clock speed, this suggests the pi calculation is taking (8.4E7) / (1E6 / 12.91) = 1084 clock cycles per iteration. This is a few orders of magnitude high (based on 1 clock cycle add/subtract/multiply, 14 clock cycle divide), suggesting the FPU isn't cooperating.
The measurement shows a total calculation time of 12.91 s, including a [for these purposes] negligible delay to toggle the GPIOs. The FPU is set up with flags `-mfloat-abi=hard -mfpu=fpv4-sp-d16`, while the compiler includes `-O3`. Based on the pi benchmark calculation rate of 5 FLOPS per cycle iteration, this test suggests the STM32F412 is running at (5 * 1E6) / (12.91) = 0.387 MFLOPS. At the current 84 MHz clock speed, this suggests the pi calculation is taking (8.4E7) / (1E6 / 12.91) = 1084 clock cycles per iteration. This is a few orders of magnitude high (based on 1 clock cycle add/subtract/multiply, 14 clock cycle divide), suggesting the FPU isn't cooperating.
After re-consulting the data sheet, I changed the calculation variables from `double` to `float` since the Cortex M4F FPU only does single-precision math. This gave me a more favorable result; note the changed horizontal scale:
![pi capture2](pi_capture2.png)
Using the above calculations, this suggests the STM32F412 is running at 1.95 MFLOPS, or 33 clock cycles per iteration.
......@@ -55,7 +55,7 @@ int main(void) {
clock_setup();
gpio_setup();
int i;
volatile double a,b,c,pi;
volatile float a,b,c,pi;
a = 0.5;
b = 0.75;
c = 0.25;
......
No preview for this file type
This diff is collapsed.
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment