subgroupBroadcastFirst
Broadcasts value e from the active invocation with the lowest subgroup_invocation_id to all active invocations in the subgroup. The wrapper enforces two parameters (e, id).
Core Advantages
Shares data within a subgroup with a single instruction. No shared memory or barriers, lower sync cost, simpler and faster parallel code.
Common Uses
Distribute a leader-produced control value to keep all lanes consistent
Align intermediate results in reductions/scans/votes
Avoid redundant sampling/loads by computing once and broadcasting
How to adjust
Function node. Change e to alter what gets shared; id is the source lane index required by the wrapper signature. With the “First” semantics a placeholder like int(0) is typically sufficient. Overall effect depends on where it is placed in your algorithm.
Code Examples
1// Normalize each lane by the first-active lane's value
2const gid = globalId.x;
3const v = inputBuffer.element( gid );
4// Pass a placeholder for id to satisfy the (e, id) signature
5const leaderV = subgroupBroadcastFirst( v, int( 0 ) );
6const outV = v.div( leaderV.add( 1e-6 ) );
7outputBuffer.element( gid ).assign( outV );