Mojo function
broadcast
broadcast[dtype: DType, width: Int, //, *, block_size: Int](val: SIMD[dtype, width], src_thread: UInt = 0) -> SIMD[dtype, width]
Broadcasts a value from a source thread to all threads in a block.
This function takes a SIMD value from the specified source thread and copies it to all other threads in the block, effectively broadcasting the value across the entire block.
Parameters:
- dtype (
DType): The data type of the SIMD elements. - width (
Int): The number of elements in each SIMD vector. - block_size (
Int): The total number of threads in the block.
Args:
- val (
SIMD): The SIMD value to broadcast from the source thread. - src_thread (
UInt): The thread ID of the source thread (default: 0).
Returns:
SIMD: A SIMD value where all threads contain a copy of the input value from
the source thread.
broadcast[dtype: DType, width: Int, //, *, block_dim_x: Int, block_dim_y: Int, block_dim_z: Int = 1](val: SIMD[dtype, width], src_thread: UInt = 0) -> SIMD[dtype, width]
Broadcasts a value from a source thread to all threads in a multi-dimensional block.
This function takes a SIMD value from the specified source thread (identified
by its linearized thread ID) and copies it to all other threads in the block.
Thread IDs are linearized in row-major order: x + y * dim_x + z * dim_x * dim_y.
Parameters:
- dtype (
DType): The data type of the SIMD elements. - width (
Int): The number of elements in each SIMD vector. - block_dim_x (
Int): The number of threads along the X dimension. - block_dim_y (
Int): The number of threads along the Y dimension. - block_dim_z (
Int): The number of threads along the Z dimension (default: 1).
Args:
- val (
SIMD): The SIMD value to broadcast from the source thread. - src_thread (
UInt): The linearized thread ID of the source thread (default: 0).
Returns:
SIMD: A SIMD value where all threads contain a copy of the input value from
the source thread.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!