Dhrystone and Whetstone Benchmarks for STM32F103

Post here first, or if you can't find a relevant section!
Post Reply
monsonite
Posts: 49
Joined: Tue May 05, 2015 10:34 am

Dhrystone and Whetstone Benchmarks for STM32F103

Post by monsonite » Tue May 05, 2015 10:46 am

Dhrystone and Whetstone Benchmarks on STM32F103xx

Over the weekend I got dhrystone and whetstone benchmarks to run both on a 16MHz ATmega2560 (there's not enough RAM on an ATmega328P) and on my Baite Electronics Maple clone.


First the integer maths Dhrystone:

ATmega2560 16MHz

Dhrystone Benchmark, Version 2.1 (Language: C)
Execution starts, 300000 runs through Dhrystone

Execution ends
Microseconds for one run through Dhrystone: 78.67
Dhrystones per Second: 12711.22
VAX MIPS rating = 7.23


STM32F103 72MHz

Dhrystone Benchmark, Version 2.1 (Language: C)
Execution starts, 300000 runs through Dhrystone

Execution ends
Microseconds for one run through Dhrystone: 11.66
Dhrystones per Second: 85762.68
VAX MIPS rating = 48.81

The STM32F103 is executing Dhrystones at approximately 6.75 times the speed of the ATmega2560. This will mostly be down to the faster clock plus the fact that 16 bit arithmetic is quicker on a 32bit machine than and 8 bit one.


The traditional dhrystone code has been modified to use Arduino's Serial.print() function rather than printf

The code be downloaded from here as a zip file http://www.saanlima.com/download/dhry21a.zip

The Whetstone is the classic floating point benchmark

The Whetstone test code adapted for Arduino by Thomas Kirchner is https://developer.mbed.org/users/kirchn ... peed_Test/

When run on a standard Arduino 16MHz Duemillenove the Whetstone produced the following result

Starting Whetstone benchmark...
Loops: 1000 Iterations: 1 Duration: 81740 millisec.
C Converted Double Precision Whetstones: 1.22 MIPS

On the STM32F103 board with a 72MHz clock

Starting Whetstone benchmark...
Loops: 1000 Iterations: 1 Duration: 19691 millisec.
C Converted Double Precision Whetstones: 5.08 MIPS

So the STM32F103 appears to be running Whetstone at approximately four times the speed of the Arduino.

Dhrystone and Whetstone are the classic benchmarks - but not generally representative of real applications. Take the figures for guidance purposes only.



Ken

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Dhrystone and Whetstone Benchmarks for STM32F103

Post by madias » Tue May 05, 2015 10:58 am

with other words:
Avoid floating points on every costs on both platforms, since you switch to STM32F4xxx ;)
BUT:
This benchmarks would be interesting for all FPU-devices (Cortex M4, like the STM32F4 line), I know this, because on the TIVA-tm4c-123 there were some problems at the beginning of energia support (FPU wasn't enabled per default or something).

User avatar
RogerClark
Posts: 7481
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Dhrystone and Whetstone Benchmarks for STM32F103

Post by RogerClark » Tue May 05, 2015 12:30 pm

I will try it on my 168mhz F407 discovery board tomorrow and post the results, assuming no one beats me to it

User avatar
Rick Kimball
Posts: 1058
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Dhrystone and Whetstone Benchmarks for STM32F103

Post by Rick Kimball » Tue May 05, 2015 2:50 pm

madias wrote:with other words:
Avoid floating points on every costs on both platforms, since you switch to STM32F4xxx ;)
I agree with that statement.
madias wrote:with other words:
This benchmarks would be interesting for all FPU-devices (Cortex M4, like the STM32F4 line), I know this, because on the TIVA-tm4c-123 there were some problems at the beginning of energia support (FPU wasn't enabled per default or something).
Not sure if i agree with that though.

The M4 is faster in general but the single-precision hardware floating point isn't going to help you if you are testing double precision code.

The FPU was enabled in the energia stuff from the start. I know because I put it there.

http://forum.43oh.com/topic/6847-sintab ... t-energia/

The problem most people encounter is using double precision variables * which is the compiler default for floating point constants * and then expecting the compiler to use the single precision hardware instructions. To help avoid that problem with energia, I enabled -fsingle-precision-constant by default. That way when people declare a constant .. someuserfunction(3.14); it becomes a float instead of a double. Most people don't actually need double precision and the hardware floating point instructions won't be used if you blindly use the double precision math functions.

If you think you might want to move to a cortex-m4f sometime in the future to be able to use hardware floating point, you might want to turn on the -fsingle-precision-constant gcc flag. You might also get in the habit of using the floating point math functions like cosf, atanf, etc instead of the default double precision ones.

-rick
-rick

monsonite
Posts: 49
Joined: Tue May 05, 2015 10:34 am

Re: Dhrystone and Whetstone Benchmarks for STM32F103

Post by monsonite » Tue May 05, 2015 3:01 pm

RogerClark wrote:I will try it on my 168mhz F407 discovery board tomorrow and post the results, assuming no one beats me to it
Roger,

I've been away for a couple of weeks.

Does that mean we now have Arduino_STM32 ported to the '407 sufficiently to run this?


Ken

User avatar
RogerClark
Posts: 7481
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Dhrystone and Whetstone Benchmarks for STM32F103

Post by RogerClark » Tue May 05, 2015 10:19 pm

F4 support is based on a old copy of libmaple and is back at Arduino 0022 api

However it does basically work.

I know GPIO works, and if you look in the STM32F4 section of this site, someone is getting on with using their STM32F407 discovery board

Unfortunately I've not had time to do any of the changes / restructuring I did to the F103 folder, in the F4 folder - as its probably one or two days work.

But at least these is something to play at the moment

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Dhrystone and Whetstone Benchmarks for STM32F103

Post by madias » Tue May 05, 2015 10:30 pm

mep mep, is there a nucleo F4 board to prefer? (I've good deals with nucleo boards...and I wanna play with I2S and the taste of honey (floating points) would be really interesting for my projects)

User avatar
RogerClark
Posts: 7481
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Dhrystone and Whetstone Benchmarks for STM32F103

Post by RogerClark » Tue May 05, 2015 11:30 pm

Matthias

I have a STM Discovery F407GVT but I think that the Nucleo boards are probably better than the Discovery ones as the STLink on them has (I presume) Virtual Serial as well as just the STLink thats on the Discovery boards

On an unrelated subject reallly..

Actually, I wonder if anyone has a the Nucleo firmware as a bin file, as it could probably be flashed onto the Discovery. But from what I"ve read STM don't release the firmware for this stuff, except as an encrypted binary via their special uploader program, which is a shame, and pointless really..

Because there is a STLink binary file on a Russian website hat you can download and flash onto any STM32F103 - Note. If you do find it and try it, please take care because apparently, it marks you flash as read only, which is a bit worrying to start with, however you can change the setting via STLInk (and I think also by Serial upload), but of course this erases the flash.

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Dhrystone and Whetstone Benchmarks for STM32F103

Post by madias » Wed May 06, 2015 8:47 am

sadly the ST Link firmware isn't "free" and encrypted in the *.dll's.
http://www.taylorkillian.com/2013/01/re ... -from.html

There are two nucleo boards with Cortex M4:
STM32F401RET6 and STM32F411RET6
I think, I'll wait a little bit, because lack of time for a new toy...

User avatar
RogerClark
Posts: 7481
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Dhrystone and Whetstone Benchmarks for STM32F103

Post by RogerClark » Wed May 06, 2015 9:31 am

Matthias

I had read that article. It does look possible to extract an unencrypted binary, I suspect there are some out on the web somewhere, but they would probably be hard to track down

I agree about the F4, there are so many other things, there is no point in buying one at the moment

I tried my F407 discovery today, and the STM32F4 code is a long way behind the F103

I noticed a mistake in the port, where the mcu was set to cortex-m3 instead of cortex-m4, and also it was missing the pin number enums, so I've fixed that.
Also I think that on the F4 the code is compiling in an OTG USB port on the pins for the HW Serial 1, as HW Serial 1 is not working, and there is an OTG lib being compiled that needs that port.

With F4, its a difficult decision about how to bring it to the level of the F103, I think I have 3 main options

1. Modify the existing F4 code like I did with the F103
2. Duplicate the F103 code and copy over the F4 specific parts
3. Use something else entirely, e.g. another core.

I have looked again at Avik's repo, and compiled a test program for the F373 board (which is the only one he supports), but even the basics don't compile, e.g. digitalWrite(PA0,!digitalRead(PA0)); doesn't compile. digitalWrite is defined, but the argument types don't match with the Arduino data types.
Also Serial is not defined, only Serial1 - so even if we used Aviks code, I think a reasonable amount of work would need to be done to make all the examples compile , like they do with libmaple


BTW. I did try to compile the Dhrystone test on the F4 but its missing a load of functions and also a load of type def's, and its pointless just fixing the repo to run the Dhrysone test. Its better to do a full port when there is enough interest

Post Reply