Mojo function
prefix_sum
prefix_sum[type: DType, //, *, block_size: Int, exclusive: Bool = False](val: SIMD[type, 1]) -> SIMD[type, 1]
Performs a prefix sum (scan) operation across all threads in a block.
This function implements a block-level inclusive or exclusive scan, efficiently computing the cumulative sum for each thread based on thread indices.
Parameters:
- type (
DType
): The data type of the Scalar elements. - block_size (
Int
): The total number of threads in the block. - exclusive (
Bool
): If True, perform exclusive scan instead of inclusive.
Args:
- val (
SIMD[type, 1]
): The Scalar value from each thread to include in the scan.
Returns:
A Scalar value containing the result of the scan operation for each thread.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!