Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commita26cdab9a3

README.md

sort

A stable radix sort of a column's keys into a permutation: place s of perm holds the index of the element that sorts s-th, so a gather by perm puts any column in key order.

SpecializeOptionsMeaning
KEYf32, i32the scalar a key holds

Elements with equal keys keep their run order, in both directions (params.descending 1 sorts from the greatest key down), and -0 and +0 are one key. The sort works 4 bits of the key at a time from the least significant up, and a pass whose digit is the same in every key is skipped, so a run of keys inside a narrow range takes fewer passes. work is the sort's second permutation; its contents after a dispatch are not an answer.

The dispatch size n is the number of keys. One workgroup of 128 works the whole run; the other workgroups of a larger dispatch return.

Exact: the sort is a function of the keys and their order, so the same keys give the same permutation on every dispatch.

Over a live count (COUNT=device, see the abi README) n is the capacity and the first domain_count keys are live: they are sorted, and a slot at or past the live count holds its own index in perm. A live count of 0 sorts nothing and perm is the identity. It binds 4 storage buffers (3 in the plain variant).

Nodes that order or group elements run it, among them attribute.order, elements.sort, core.edges, core.adjacency, core.spatial, geometry.bvh, geometry.boolean, geometry.decimate and geometry.shared.