From 6b4580607efa698abdc07718f00c6cbdb425c210 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 5 Oct 2026 13:24:59 +0100 Subject: 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 --- research/experiments/040-against-c/matmul.aup | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 research/experiments/040-against-c/matmul.aup (limited to 'research/experiments/040-against-c/matmul.aup') 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 +} -- cgit v1.2.3