IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

sum

sum(val: SIMD) -> Scalar[val.dtype]

Computes the sum of values across all lanes in a warp.

This is a convenience wrapper around lane_group_sum that operates on the entire warp. It performs a parallel reduction using warp shuffle operations to find the global sum across all lanes in the warp.

Args:

  • val (SIMD): The SIMD value to reduce. Each lane contributes its value to the sum.

Returns:

Scalar[val.dtype]: The scalar sum of values across all lanes in the warp.