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/join.aup | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 research/experiments/040-against-c/join.aup (limited to 'research/experiments/040-against-c/join.aup') diff --git a/research/experiments/040-against-c/join.aup b/research/experiments/040-against-c/join.aup new file mode 100644 index 0000000..bddda80 --- /dev/null +++ b/research/experiments/040-against-c/join.aup @@ -0,0 +1,46 @@ +# A join (research 124's suite): customers with ids drawn by MINSTD from +# seed 1 (sparse, distinct), each in one of 16 regions; orders each of a +# customer drawn by index and an amount; the amounts summed by the region of +# each order's customer, found by its id. +record Customer { + id = 0 + region = 0 +} +record Total { + region = 0 + amount = 0 +} +state top = 0 +state sum = 0 +input go = message { + customers: u32 + orders: u32 +} +on go { + let all: list of Customer + let byid: list of Customer by id + let x = 1 + for i in 0 .. go.customers { + x = x * 48271 - floor(x * 48271 / 2147483647) * 2147483647 + all.append(Customer { id: x, region: i - floor(i / 16) * 16 }) + byid.add(Customer { id: x, region: i - floor(i / 16) * 16 }) + } + let totals: list of Total by region + for r in 0 .. 16 { + totals.add(Total { region: r }) + } + for o in 0 .. go.orders { + x = x * 48271 - floor(x * 48271 / 2147483647) * 2147483647 + let c = all.first + (x - floor(x / go.customers) * go.customers) + let region = byid[c.id].region + totals[region].amount = totals[region].amount + (x - floor(x / 1000) * 1000) + } + let most = 0 + let all_amounts = 0 + for t in totals { + most = max(most, t.amount) + all_amounts = all_amounts + t.amount + } + top = most + sum = all_amounts +} -- cgit v1.2.3