diff options
| author | eunhhu <[email protected]> | 2026-10-05 13:24:59 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-05 13:24:59 +0100 |
| commit | 6b4580607efa698abdc07718f00c6cbdb425c210 (patch) | |
| tree | 0cad9cddfd332140ecce47d17e439573f32ea11e /research/experiments/040-against-c/join.aup | |
| parent | 5a3466e8ff4d8f3c4271719b90858b7d08697dcd (diff) | |
| download | pure-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/join.aup')
| -rw-r--r-- | research/experiments/040-against-c/join.aup | 46 |
1 files changed, 46 insertions, 0 deletions
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 +} |
