mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
035f1b358a
* feat(exp,simd): adding SumAxB helpers * feat(exp,simd): adding MeanAxB and ClampAxB helpers * feat(exp,simd): adding MinAxB and MaxAxB helpers * refactor(exp,simd): group perf helper category + architecture * feat(exp,simd): adding ContainsAxB helpers * perf(exp,simd): cast to unsafe slice once * feat(exp,simd): call the right SIMD helper based on local architecture * chore: internal dependency linking * Update exp/simd/math.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * style: fix linter * style: fix linter * chore: enable simd in makefile * chore(ci): add simd package to test runs * chore(ci): add simd package to test runs only for go 1.26 * fix(simd): fix overflow * fix(simd): fix overflow and apply the same behavior than lo.Mean * doc(exp,simd): adding initial doc * refactor(simd): move intersect_avx2 and intersect_sse code into intersect_avx512 * fix(simd): call SSE fallback instead of lo.Sum for default helpers * feat(simd): cache simd features on package init to avoid repeated checks * perf(exp,simd): precompute length + improve code quality * perf(exp,simd): faster iteration for min/max value * test(exp,simd): adding benchmarks * test(exp,simd): adding benchmarks results * test(exp,simd): adding benchmarks results * doc(exp,simd): adding warning for overflows in SIMD operations * feat(exp,simd): adding more dispatch helpers * feat(exp,simd): adding SumBy variants * feat(exp,simd): adding MeanBy variants * fix(exp,simd): faster clamp * 💄 * doc(exp,simd): adding SumBy + MeanBy * fix(exp,simd): faster SIMD operations * chore(ci): enable the benchmarks temporary * chore(ci): display cpu architecture before running tests * chore(ci): github actions are hidding some useful stuffs * chore(ci): no SIMD VM available at Github during the weekend ??? * test(exp,simd): larger epsilon * oops * perf(exp,simd): faster iterations * doc(exp,simd): report last version of benchmarks * 💄 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1.5 KiB
1.5 KiB
SIMD experiment (Go 1.26+)
This package requires Go 1.26 with GOEXPERIMENT=simd and amd64.
See benchmarks.
CPU compatibility (avoiding SIGILL)
If you see SIGILL: illegal instruction when running tests, the CPU or VM does not support the SIMD instructions used by that code.
Check support on Linux
# List SIMD-related flags
grep -E 'avx|sse' /proc/cpuinfo
# Or with lscpu
lscpu | grep -i avx
Rough mapping:
| Tests / code | Required flag(s) | Typical CPUs |
|---|---|---|
| SSE (128-bit) | sse2 (baseline on amd64) |
All amd64 |
| AVX2 (256-bit) | avx2 |
Intel Haswell+, AMD Excavator+ |
| AVX-512 (512-bit) | avx512f |
Intel Skylake-X+, some Xeons; many AMD/consumer CPUs do not have it |
What the tests do
- AVX2 tests call
requireAVX2(t)and are skipped if the CPU does not support AVX2 (no SIGILL). - AVX-512 tests (when enabled) should call
requireAVX512(t)and skip when AVX-512 is not available.
So on a machine without AVX2, AVX2 tests will show as skipped instead of crashing.
Run only SSE tests
If your environment does not support AVX2/AVX-512, you can still run the SSE tests:
GOEXPERIMENT=simd go test -run SSE ./...