0Pricing
Mojo Academy · Lesson

Element-Wise SIMD Math

Add and multiply whole vectors at once.

Math on Whole Vectors

The best part of SIMD is that arithmetic works on the entire vector at once. One operation touches every lane together.

Adding Two Vectors

Add two SIMD values and each lane is added to its matching lane. This is called element-wise addition.

var a = SIMD[DType.int32, 4](1, 2, 3, 4)
var b = SIMD[DType.int32, 4](10, 20, 30, 40)
var c = a + b

All lessons in this course

  1. Meet the SIMD Type
  2. Element-Wise SIMD Math
  3. Choosing a SIMD Width
  4. Vectorizing a Loop
← Back to Mojo Academy