Template Function treeweave::guru::scatter

Function Documentation

template<std::ranges::contiguous_range In, std::ranges::contiguous_range Packed>
void treeweave::guru::scatter(std::span<const std::uint32_t> keys, In &&in, Packed &&packed, std::span<std::uint32_t> counts, std::span<std::uint32_t> rank)

Place each in[i] at packed[counts[keys[i]]++] and record the packed slot rank[i] (the INVERSE permutation — gather consumes it directly). counts must hold bin start offsets (output of exclusive_scan) and is consumed into ending offsets. Stable within a bin (the sweep walks i in order), so per-bin runs keep input order. The name is the literature’s (the counting sort’s placement pass); unlike thrust::scatter, the destination map is computed from keys + counts, not caller-supplied.