IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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

broadcast

def broadcast[val_type: DType, simd_width: SIMDLength, //](val: SIMD[val_type, simd_width]) -> SIMD[val_type, simd_width]

Broadcasts a SIMD value from lane 0 to all lanes in the warp.

This function takes a SIMD value from lane 0 and copies it to all other lanes in the warp, effectively broadcasting the value across the entire warp. This is useful for sharing data between threads in a warp without using shared memory.

Parameters:

  • โ€‹val_type (DType): The data type of the SIMD elements (e.g. float32, int32).
  • โ€‹simd_width (SIMDLength): The number of elements in the SIMD vector.

Args:

Returns:

SIMD[val_type, simd_width]: A SIMD value where all lanes contain a copy of the input value from lane 0.

Was this page helpful?