I'm trying to benchmark some simple applications with uPY, my configuration is based on the STM32F411 Nucleo board.
I would like to compare the three code emitters (i.e. bytecode, native and viper), with a simple integer matrix multiplication.
I already tested the code suggested here: https://www.kickstarter.com/projects/21 ... sts/665145, achieving very similar results.
Unfortunately I have two kinds of issues with my MatMul test:
1. if I use the MP_EMIT_OPT_VIPER in the mp_compile function:
Code: Select all
mp_obj_t module_fun = mp_compile(pn, source_name, MP_EMIT_OPT_VIPER, false);
Code: Select all
assertion "vtype_fromlist == VTYPE_PYOBJ" failed: file "py/emitnative.c", line 1236, function: emit_native_import_name
2. Then, even using the MP_EMIT_OPT_ASM_THUMB or MP_EMIT_OPT_NONE parameter, when I test the matrix multiplication I get this error:
Code: Select all
assertion "vtype_index == VTYPE_PYOBJ" failed: file "py/emitnative.c", line 1434, function: emit_native_load_subscr
Just for completeness the Matrix Multiplication I tested is the following:
Code: Select all
import pyb
@micropython.viper
def matmul(first, second, multiply):
row = 10
col = 10
sum = 0
for i in range(0, row):
for j in range(0, col):
for k in range(0, row):
sum = sum + first[i][k]*second[k][j];
multiply[i][j] = sum;
sum = 0;
first = [0 for x in range(10)]
second = [0 for x in range(10)]
multiply = [[0 for x in range(10)] for x in range(10)]
first[0] = [1,2,3,4,5,6,7,8,9,10]
first[1] = [11,12,13,14,15,16,17,18,19,20]
first[2] = [21,22,23,24,25,26,27,28,29,30]
first[3] = [31,32,33,34,35,36,37,38,39,40]
first[4] = [41,42,43,44,45,46,47,48,49,50]
first[5] = [51,52,53,54,55,56,57,58,59,60]
first[6] = [61,62,63,64,65,66,67,68,69,70]
first[7] = [71,72,73,74,75,76,77,78,79,80]
first[8] = [81,82,83,84,85,86,87,88,89,90]
first[9] = [91,92,93,94,95,96,97,98,99,100]
second[0] = [1,2,3,4,5,6,7,8,9,10]
second[1] = [1,2,3,4,5,6,7,8,9,10]
second[2] = [1,2,3,4,5,6,7,8,9,10]
second[3] = [1,2,3,4,5,6,7,8,9,10]
second[4] = [1,2,3,4,5,6,7,8,9,10]
second[5] = [1,2,3,4,5,6,7,8,9,10]
second[6] = [1,2,3,4,5,6,7,8,9,10]
second[7] = [1,2,3,4,5,6,7,8,9,10]
second[8] = [1,2,3,4,5,6,7,8,9,10]
second[9] = [1,2,3,4,5,6,7,8,9,10]
while True:
matmul(first, second, multiply)
pyb.delay(1000)
If someone could give me some tips, it would be very appreciated.
Many Thanks in advance.
Best,
D