@@ -7,45 +7,9 @@ import (
77 "simd/archsimd"
88 "sync"
99 "unsafe"
10-
11- "golang.org/x/sys/cpu"
1210)
1311
14- // =============================================================================
15- // AVX-512 CPU Detection and Fallback
16- // =============================================================================
17- //
18- // NOTE: The simd/archsimd package in Go 1.26 is an experimental feature enabled via
19- // GOEXPERIMENT=simd. This package is AMD64-specific, and a higher-level portable
20- // SIMD package is planned for future development.
21- // See: https://github.com/golang/go/issues/73787 (archsimd proposal)
22- // See: https://go.dev/doc/go1.26 (Go 1.26 Release Notes)
23- //
24- // NOTE: The archsimd.Int8x64.Equal().ToBits() method internally uses the VPMOVB2M
25- // instruction (AVX-512BW). This instruction causes SIGILL (illegal instruction) on
26- // CPUs that do not support AVX-512, including GitHub Actions ubuntu-latest runners,
27- // most CI environments, and older CPUs.
28- //
29- // TODO: Revisit this fallback implementation when the simd/archsimd package provides:
30- // - Mandatory runtime CPU feature checks within the archsimd package
31- // (Issue #73787: "It is an open question whether we want to enforce that a CPU
32- // feature check must be performed before using a vector intrinsic.")
33- // - AVX2-only alternative to ToBits() (using VPMOVMSKB instruction)
34- // - A high-level portable SIMD package
35- //
36- // TODO: Replace golang.org/x/sys/cpu usage with official archsimd API (e.g.,
37- // archsimd.HasAVX512()) when such API becomes available. Currently, the archsimd
38- // package does not provide CPU feature detection functions (as of Go 1.26).
39- //
40- // =============================================================================
41-
4212// useAVX512 indicates whether AVX-512 instructions are available at runtime.
43- // This is set once at init time and used to dispatch to the appropriate implementation.
44- //
45- // NOTE: All three feature flags are required:
46- // - AVX512F: Foundation 512-bit vector operations
47- // - AVX512BW: Byte/word granularity operations (ToBits() uses VPMOVB2M)
48- // - AVX512VL: 128/256-bit vector support with AVX-512 instructions
4913var useAVX512 bool
5014
5115// SIMD processing constants.
@@ -58,9 +22,7 @@ const (
5822)
5923
6024func init () {
61- // NOTE: Using golang.org/x/sys/cpu for runtime CPU feature detection.
62- // The archsimd package itself does not provide CPU detection functions (as of Go 1.26).
63- useAVX512 = cpu .X86 .HasAVX512F && cpu .X86 .HasAVX512BW && cpu .X86 .HasAVX512VL
25+ useAVX512 = archsimd .X86 .AVX512 ()
6426}
6527
6628// =============================================================================
0 commit comments