Skip to main content
Log in

Mojo function

shuffle_up

shuffle_up[type: DType, simd_width: Int, //](val: SIMD[type, simd_width], offset: SIMD[uint32, 1]) -> SIMD[type, simd_width]

Copies values from other lanes in the warp.

Exchange a value between threads within a warp by copying from a thread with lower lane id relative to the caller without the use of shared memory.

Parameters:

  • type (DType): The type of the simd value.
  • simd_width (Int): The width of the simd value.

Args:

  • val (SIMD[type, simd_width]): The value to be shuffled.
  • offset (SIMD[uint32, 1]): The offset warp lane ID.

Returns:

The value at the specified offset.

shuffle_up[type: DType, simd_width: Int, //](mask: UInt, val: SIMD[type, simd_width], offset: SIMD[uint32, 1]) -> SIMD[type, simd_width]

Copies values from other lanes in the warp.

Exchange a value between threads within a warp by copying from a thread with lower lane id relative to the caller without the use of shared memory.

Parameters:

  • type (DType): The type of the simd value.
  • simd_width (Int): The width of the simd value.

Args:

  • mask (UInt): The mask of the warp lanes.
  • val (SIMD[type, simd_width]): The value to be shuffled.
  • offset (SIMD[uint32, 1]): The offset warp lane ID.

Returns:

The value at the specified offset.