Mojo function
broadcast
broadcast[val_type: DType, simd_width: Int, //](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 (
Int
): The number of elements in the SIMD vector.
Args:
- val (
SIMD[val_type, simd_width]
): The SIMD value to broadcast from lane 0.
Returns:
A SIMD value where all lanes contain a copy of the input value from lane 0.
broadcast(val: Int) -> Int
Broadcasts an integer value from lane 0 to all lanes in the warp.
This function takes an integer value from lane 0 and copies it to all other lanes in the warp. It provides a convenient way to share scalar integer data between threads without using shared memory.
Args:
- val (
Int
): The integer value to broadcast from lane 0.
Returns:
The broadcast integer value, where all lanes receive a copy of the input from lane 0.
broadcast(val: UInt) -> UInt
Broadcasts an unsigned integer value from lane 0 to all lanes in the warp.
This function takes an unsigned integer value from lane 0 and copies it to all other lanes in the warp. It provides a convenient way to share scalar unsigned integer data between threads without using shared memory.
Args:
- val (
UInt
): The unsigned integer value to broadcast from lane 0.
Returns:
The broadcast unsigned integer value, where all lanes receive a copy of the input from lane 0.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!