12 hours ago · Tech · hide · 0 comments

Take a really boring loop: walk two []float32 slices and add them together, element by element. Written the normal way in Go, the CPU handles one pair per step. The funny thing is that the same CPU has hardware that could handle eight pairs at once, and a plain Go loop never uses it. That hardware is SIMD. Until recently, the only way to use it from Go was hand-written assembly. Now Go has an experimental simd/archsimd package (Go 1.26) and a portable simd package on top of it (Go 1.27), so you can write normal Go that turns into SIMD instructions.

No comments yet. Log in to reply on the Fediverse. Comments will appear here.