For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
block_prefix_sum
def block_prefix_sum[dtype: DType, //, num_elements: Int, thread_base: Int = Int(0), n_scoped_threads: Int = Int(0), barrier_id: Int = Int(-1)](_val: Scalar[dtype]) -> Scalar[dtype]
Performs a prefix sum (scan) operation across all threads in a block.
Parameters:
- dtype (
DType): Element type of the values being scanned (inferred). - num_elements (
Int): Number of active threads in the block that contribute values to the scan. - thread_base (
Int): Absolutethread_idx.xof the first participating thread (0 in the standalone kernels; the FFN thread count when a comm thread-class runs the scan in a fused megakernel). All indices are relative to this base. - n_scoped_threads (
Int): Thread count the scan's block barriers scope to whenbarrier_id >= 0(the comm thread-class size). - barrier_id (
Int): Named-barrier id for the scan's barriers, or negative (the default) for the full-blockbarrier().
Args:
- _val (
Scalar[dtype]): The per-thread value to contribute to the inclusive prefix sum.
Returns: