Skip to content

kernel.subgroup.reduce

← kernel dialect

Reduce a scalar or rank-1 vector value across the current subgroup. Each active contribution participates once per component; association is unspecified. Floating sums and products default to native target arithmetic, which may change signed zeros, flush subnormals, or relax nonfinite handling. The optional preserve requirement instead evaluates each combine with the source format's arithmetic semantics. Neither mode promises serial-reference bits, reproducibility, or a correctly rounded real-number sum. Integer arithmetic and the selected floating-extremum kind keep their exact semantics.

Operation contract

Property Value
Semantic phase executable
Traits Convergent, HasAnyAncestor(kernel.def, pipeline.strand)
Target contracts kernel.synchronization

Signature

Kind Name Type Cardinality Description
Operand value any required Per-invocation value to reduce.
Result result any required Reduced value.
Attribute kind enum CombiningKind required Combining operation.
Attribute math flags CollectiveMathFlags optional Optional floating-point preservation requirement; omission selects native arithmetic.
Attribute cluster_size i64 optional Optional clustered subgroup size.
Attribute cluster_stride i64 optional Optional clustered subgroup stride.

Verification constraints

  • SameType(value, result)

Examples

%sum = kernel.subgroup.reduce<addf> %v : f32