Sarek_warpSarek_warp - the one definition of warp shuffle semantics.
The four shuffle primitives (warp_shuffle, warp_shuffle_down, warp_shuffle_up, warp_shuffle_xor) and the two warp introspection constants (warp_size, lane_id) reach the IR as EIntrinsic nodes. The shuffles are TYPED in the IR: the front end appends the value type to the name (warp_shuffle_down_f32) so a backend never has to infer the type of an expression to choose a spelling.
Contract (docs/plans/warp-shuffle-intake-2026-10-17.md, section 4.3), for lane i of a warp of width W (a power of two) and operand x read as a two's-complement int32:
warp_shuffle v x: source lane x land (W-1);warp_shuffle_down v d: i + d, or i when d < 0 or i + d >= W;warp_shuffle_up v d: i - d, or i when d < 0 or i - d < 0;warp_shuffle_xor v m: i lxor m, or i when m < 0 or i lxor m >= W.source_lane is that table, executable. Native and the interpreter use it directly; the source backends emit equivalent guards, and the parity tests compare every backend with it.
val op_base : op -> stringval type_suffix : value_type -> stringval all_ops : op listval all_types : value_type listval ir_name : op -> value_type -> stringThe IR name of a typed shuffle, e.g. "warp_shuffle_down_f32".
val typed_names : (string * call) listval classify : string -> call optionClassify an IR intrinsic name. None for anything that is not a warp shuffle or a warp introspection constant.
val op_of_user_name : string -> op optionThe op of a user-facing shuffle name.
Does this IR intrinsic name denote a shuffle (a warp collective)?
Does this IR intrinsic name depend on the warp structure (shuffle, warp_size, lane_id)? Passes that change which threads run, or the block shape, must leave such a kernel alone.
val source_lane : op -> width:int -> lane:int -> int -> intIndex of the lane read by lane lane for operand x in a warp of width lanes. The result is always in 0, width). [x] is the int32 operand sign-extended to an OCaml int.
Native and the interpreter have no hardware warp. They simulate one of simulated_width () lanes (default 32, the width of the CUDA and Apple devices and of RDNA). The width is a launch-time parameter in the sense that it is read at each launch; with_width is the test hook that lets the parity tests run the simulation at a GPU's width.
Run f with the simulated width set to w, restoring the previous width afterwards. Raises Invalid_argument when w is not a power of two in 1, 1024. Not re-entrant across domains: it is a test hook.
Linear thread id of (tx, ty, tz) in a block of (bx, by, _) (x fastest).