Platform-independent SIMD in Go
Go 1.27 adds an experimental, size-agnostic `simd` package, loosely modeled on Highway for C++. It hides differences in vector width, masking schemes and instruction sets across AVX/AVX2/AVX512, NEON and wasm, and falls back to emulation on platforms without SIMD support. Vector types such as `simd.Float32s` have no fixed length; they load from and store to slices and expose only operations in the cross-platform intersection, with gaps filled by emulation. When an operation is missing, code can drop into the architecture-specific `archsimd` package via `ToArch()`/`FromArch`, and the compiler specializes away the type switch, as shown with a lookup-table popcount implementation for AVX/AVX2.
Related posts
- Arch-specific SIMD in Go
The Go Blog hardMaster
Go 1.27 extends the experimental architecture-specific SIMD API (simd/archsimd, enabled with GOEXPERIMENT=simd) from amd64 to arm64 NEON and wasm 128-bit SIMD. The design uses typed vector structs, readable method names unified across architectures, opaque mask types that the compiler peepholes into masked instructions, and new zero-cost reinterpretation methods (ToBits, ReshapeToUint<W>s) that replace Go 1.26's As<Type> methods. Worked examples reverse bits with GFNI affine transforms and transpose an 8x8 matrix with AVX2 lane-grouped permutes. Practical advice: guard code with CPU feature checks, which avoid SIGILL and also enable fused AVX-512 lowering; write loop bounds as i < len-n+1 so bounds checks are eliminated; and pass vectors as separate values rather than arrays or structs so they stay in registers.
- fearless_simd v0.6 brings AVX-512 and ways to disable it
Linebender mediumAdept
fearless_simd v0.6 adds AVX-512 support for all operations, including safe invocation of AVX-512 intrinsics through the kernel! macro. AVX-512's main benefits are its new instructions and doubled register count rather than 512-bit width, which gave Vello CPU a 15% end-to-end speedup over AVX2 on Zen 4 with no code changes. AVX-512 is enabled only on Ice Lake and later to avoid Skylake downclocking. Because of hardware quirks like slow Zen 4 scatter/gather and binary-size growth from multiversioning, instruction sets can now be disabled per function or binary-wide via cfg flags (e.g. --cfg=disable_dispatch_avx512) rather than Cargo features, so the final binary builder controls the choice across the whole dependency tree.
- fearless_simd v0.7: 64-bit integers, improved generics, SSE2, and upcoming v1.0
Linebender mediumAdept
fearless_simd v0.7 adds u64/i64 vector types, completing integer and float type coverage, plus dynamic byte shuffles via swizzle_dyn, wrapping/saturating widen-narrow conversions, and element shift/rotate helpers. Every operation is now exposed through traits for generic programming. An explicit SSE2 level replaces autovectorized scalar fallback on x86 when runtime dispatch is disabled. Build-time profiling kept from-scratch compilation at about 2s on x86 instead of 3.4s, and v1.0 is planned for early September with no breaking changes if the community raises no API concerns.
- SIMD Matters
Box2D hardMasterBox2D 3.0 solves contact constraints with SIMD by using greedy graph coloring to group constraints so no body appears twice within a color. Each color is split into 4- or 8-wide blocks for SSE2/Neon/AVX2, with body velocities gathered into wide structs and scattered back afterward. Colors persist across time steps using per-color body bitsets, and static bodies are excluded to keep the color count low. On a 5050-body pyramid benchmark, SSE2 is about 2x faster than scalar and AVX2 about 14% faster than SSE2, while compiler auto-vectorization of a scalar struct-of-floats fallback fails to match hand-written SSE2.
- Fearless SIMD v1.0 is here
Linebender easyNovice
Fearless SIMD v1.0 is a Rust crate for SIMD with no ad-hoc unsafe code. Its safety rests on two small audited building blocks: a kernel! macro that uses target feature v1.1 to call intrinsics without unsafe, and a safe transmute module that covers loads and stores. It provides portable abstractions with precise and fast variants for platform-divergent edge cases, native-width vectors, and zero-overhead safe drop-down to intrinsics. A new #[simd] macro handles function multiversioning without inline(always) tuning. v1.0 comes with three years of security updates and is meant to complement std::simd, not compete with it.