Speed on STM32F7 disco

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
hosk
Posts: 6
Joined: Sat Aug 15, 2015 9:49 am
Location: Ostrava

Speed on STM32F7 disco

Post by hosk » Sat Aug 15, 2015 10:08 am

I tried this code online on MPweb and on STM32F7 disco.

Code: Select all

import pyb
import micropython
def sk():
  count = 0
  millis = pyb.millis
  kon = millis() + 1000
  while millis() < kon:
    count += 1
  print (count)

@micropython.native
def skn():
  count = 0
  millis = pyb.millis
  kon = millis() + 1000
  while millis() < kon:
    count += 1
  print ("native",count)

sk()
skn()
I was surprised by the difference in the results

on web
normal: 268647
native: 408437

on STM32F7 (Micro Python v1.4.5-5-g3179d23 on 2015-08-15; F7DISC with STM32F746)
normal: 120744
native: 197518

Can someone explain this huge difference?
Honza Sklenář

User avatar
dhylands
Posts: 3204
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Speed on STM32F7 disco

Post by dhylands » Sat Aug 15, 2015 5:32 pm

It seems that I didn't enable the CPU Cache.

With the CPU Cache enabled, I get:

Code: Select all

>>> import counter_perf
start
normal 362123
start
native 614349
I opened a PR: https://github.com/micropython/micropython/pull/1429

I seem to recall that the DMA goes through the cache, but I need to double check. If that's the case then we won't have any cache coherency issues when using DMA (on the larger processors, like the Cortex A9) the DMA doesn't go through the cache, so you need to ensure that the caches are flushed/invalidated before/after DMA operations.

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Speed on STM32F7 disco

Post by danicampora » Sat Aug 15, 2015 5:40 pm

Wow! the cache makes quite a difference!

hosk
Posts: 6
Joined: Sat Aug 15, 2015 9:49 am
Location: Ostrava

Re: Speed on STM32F7 disco

Post by hosk » Sat Aug 15, 2015 8:18 pm

I'ts amazing. Thank you for the explanation. :)
Honza Sklenář

Post Reply