Skip to content

Make plans a tree, and workspaces a plan with its buffers - #183

Merged
maleadt merged 1 commit into
tb/dedup-scanfrom
tb/dedup-workspace
Oct 25, 2026
Merged

maleadt merged 1 commit into
tb/dedup-scanfrom
tb/dedup-workspace

Conversation

@maleadt

@maleadt maleadt commented Oct 25, 2026

Copy link
Copy Markdown
Member

A plan (an operation's backend, resolved algorithm and scratch buffers) and a workspace repeated each other's fields, and both carried a second structure, nested, holding the resolved algorithms of the operations an operation calls (the scan inside the radix sort and findall, the reduction inside ViaReduce), so that every nesting site built two parallel NamedTuples.

Now plans form a tree: a plan's sizes hold its buffer requirements or the plans of the operations it calls, and a Workspace is a plan, the device it was made for and the buffers. A workspace is accepted when its plan equals the call's (backend, algorithms and buffer sizes, all the way down), which is the same rule as before; the only difference is that a ViaReduce predicate now also compares its reduction's algorithm, as the contract says, where it compared only its buffers. Mismatch errors say which part differs and show both sides. workspace_size, workspace and the display of a workspace are unchanged.

Per-call overhead is unchanged (RTX 5080, e.g. sum of 100 elements 11.8 µs, findall of 1000 23.2 µs, with or without a workspace; all within 2.5%). Tested on CPU threads, PoCL, CUDA (Julia 1.12 and 1.10).

@maleadt
maleadt added this pull request to stack #178 October 25, 2026 04:12
A plan recorded the resolved algorithms of the operations it calls (the
scan in radix sort and findall, the key range reduction) in a separate
`nested` NamedTuple next to their sizes, and a workspace copied every
field of the plan. A plan's sizes now hold the plans of the operations
it calls, and a workspace holds its plan, device and buffers.

A workspace serves a call whose plan is structurally equal to its own
(`same_plan`): the same backend, algorithms and sizes down the tree,
which is what was compared before. The nested reduction of `ViaReduce`
predicates now also has its algorithm compared; it was the only nested
operation recorded by its sizes alone. A mismatch says which algorithms
or which buffers differ, as before.
@maleadt
maleadt force-pushed the tb/dedup-workspace branch from 5588367 to 7ae9619 Compare October 25, 2026 06:47
@maleadt
maleadt merged commit a980217 into main Oct 25, 2026
34 of 69 checks passed
@maleadt
maleadt deleted the tb/dedup-workspace branch October 25, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant