aboutsummaryrefslogtreecommitdiffstats
path: root/research/experiments/040-against-c/matmul.aup
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-05 13:24:59 +0100
committereunhhu <[email protected]>2026-10-05 13:24:59 +0100
commit6b4580607efa698abdc07718f00c6cbdb425c210 (patch)
tree0cad9cddfd332140ecce47d17e439573f32ea11e /research/experiments/040-against-c/matmul.aup
parent5a3466e8ff4d8f3c4271719b90858b7d08697dcd (diff)
downloadpure-6b4580607efa698abdc07718f00c6cbdb425c210.tar.gz
pure-6b4580607efa698abdc07718f00c6cbdb425c210.zip
Research 124's suite: seven kinds of work in one event each (roots, knapsack, sort, join, words, matmul, BFS), each against the C one would write, in one process with the same inputs and answers; PURE_AHEAD=0 to measure the code without reading ahead
Diffstat (limited to 'research/experiments/040-against-c/matmul.aup')
-rw-r--r--research/experiments/040-against-c/matmul.aup37
1 files changed, 37 insertions, 0 deletions
diff --git a/research/experiments/040-against-c/matmul.aup b/research/experiments/040-against-c/matmul.aup
new file mode 100644
index 0000000..ae75aa5
--- /dev/null
+++ b/research/experiments/040-against-c/matmul.aup
@@ -0,0 +1,37 @@
+# Numbers in a grid (research 124's suite): two n by n matrices of whole
+# numbers below 100 drawn by MINSTD from seed 1, kept by row * n + column,
+# multiplied: the sum of the product's cells and its last cell.
+record Cell {
+ at = 0
+ v = 0
+}
+state sum = 0
+state corner = 0
+input go = message {
+ n: u32
+}
+on go {
+ let a: list of Cell by at
+ let b: list of Cell by at
+ let x = 1
+ for i in 0 .. go.n * go.n {
+ x = x * 48271 - floor(x * 48271 / 2147483647) * 2147483647
+ a.add(Cell { at: i, v: x - floor(x / 100) * 100 })
+ x = x * 48271 - floor(x * 48271 / 2147483647) * 2147483647
+ b.add(Cell { at: i, v: x - floor(x / 100) * 100 })
+ }
+ let total = 0
+ let last = 0
+ for i in 0 .. go.n {
+ for j in 0 .. go.n {
+ let s = 0
+ for k in 0 .. go.n {
+ s = s + a[i * go.n + k].v * b[k * go.n + j].v
+ }
+ total = total + s
+ last = s
+ }
+ }
+ sum = total
+ corner = last
+}