subgroupShuffleUp
Returns v from the active invocation whose subgroup_invocation_id equals this_id − delta, i.e., fetches from a lower-numbered lane within the subgroup.
Core Advantages
Single-instruction intra‑subgroup data exchange without shared memory or barriers; ideal for building prefix scans, neighborhood ops, and warp‑level communication.
Common Uses
One step of prefix sum/product (iterate with delta = 1, 2, 4, …)
Neighborhood differencing or filtering: v − left neighbor
Shift‑register style data movement inside a subgroup
Building block for broadcast/shuffle primitives
How to adjust
Takes exactly two parameters: v and delta. Increase delta to read farther neighbors. If this_id < delta or the source lane is inactive, the result is undefined; guard with invocationSubgroupIndex or fallback logic. Subgroup size and availability are platform‑dependent and only where subgroup ops are supported.
Code Examples
1// Shuffle up inside the subgroup: each lane reads from lane − delta
2const delta = int( 1 );
3const left = subgroupShuffleUp( value, delta );
4
5// Example: first‑order difference (lane 0 must be handled explicitly)
6const diff = value.sub( left );