Mojo function
scatter
scatter[dtype: DType, size: Int, //](value: SIMD[dtype, size], var base: SIMD[DType.index, size], mask: SIMD[DType.bool, size], alignment: Int = 0)
Takes scalar values from a SIMD vector and scatters them into a vector of pointers.
The scatter operation stores scalar values from a SIMD vector of memory
locations and scatters them into a vector of pointers. The memory locations
are provided in the vector of pointers base as addresses. The memory is
stored according to the provided mask. The mask holds a bit for each vector
lane, and is used to prevent memory accesses to the masked-off lanes.
The value operand is a vector value to be written to memory. The base
operand is a vector of pointers, pointing to where the value elements
should be stored. It has the same underlying type as the value operand. The
mask operand, mask, is a vector of boolean values. The types of the
mask and the value operand must have the same number of vector
elements.
Scatter with overlapping addresses is guaranteed to be ordered from least-significant to most-significant element.
In general, for some vector value, vector of pointers base, and mask
mask a call of the form:
scatter(value, base, mask)is equivalent to the following sequence of scalar stores in C++:
for (int i = 0; i < N; i++)
if (mask[i])
base[i] = value[i];Parameters:
- dtype (
DType): DType ofvalue, the result SIMD buffer. - size (
Int): Size ofvalue, the result SIMD buffer.
Args:
- value (
SIMD): The vector that will contain the result of the scatter operation. - base (
SIMD): The vector containing memory addresses that scatter will access. - mask (
SIMD): A binary vector which prevents memory access to certain lanes of the base vector. - alignment (
Int): The alignment of the source addresses. Must be 0 or a power of two constant integer value.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!