From 1d265f0dd60797748d310ad84b2c4aef5ac22d3f Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Thu, 14 Jan 2021 11:03:28 +0100 Subject: generate a matrix product with many temporaries --- test/monniaux/many_temporaries/matrix_product.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/monniaux/many_temporaries/matrix_product.py (limited to 'test') diff --git a/test/monniaux/many_temporaries/matrix_product.py b/test/monniaux/many_temporaries/matrix_product.py new file mode 100644 index 00000000..911ca92c --- /dev/null +++ b/test/monniaux/many_temporaries/matrix_product.py @@ -0,0 +1,20 @@ +m=4 +n=5 +p=6 +number_type='double' +with open('matrix_product.c', 'w') as cfile: + cfile.write(f'void matrix_product({number_type} c[{m}][{p}], const {number_type} a[{m}][{n}], const {number_type} b[{n}][{p}]) {{\n') + for i in range(m): + for j in range(n): + for k in range(p): + cfile.write(f' const {number_type} p_{i}_{j}_{k} = a[{i}][{j}] * b[{j}][{k}];\n') + for i in range(m): + for k in range(p): + cfile.write(f' c[{i}][{k}] = ') + for j in range(n): + if j>0: + cfile.write(' + ') + cfile.write(f'p_{i}_{j}_{k}') + cfile.write(';\n') + cfile.write('}\n') + -- cgit