Page 1 of 1

Speed on STM32F7 disco

Posted: Sat Aug 15, 2015 10:08 am
by hosk
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?

Re: Speed on STM32F7 disco

Posted: Sat Aug 15, 2015 5:32 pm
by dhylands
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.

Re: Speed on STM32F7 disco

Posted: Sat Aug 15, 2015 5:40 pm
by danicampora
Wow! the cache makes quite a difference!

Re: Speed on STM32F7 disco

Posted: Sat Aug 15, 2015 8:18 pm
by hosk
I'ts amazing. Thank you for the explanation. :)