Skip to content

simd/archsimd: X86.AVX512() always false on darwin/amd64 #78772

Description

@vsivsi

Go version

go version go1.26.2 darwin/amd64

Output of go env in your module/workspace:

go env output (click to expand)
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE='on'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users//Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users//Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/cb/2vx9ptwx6qq3ghc6jgcsr1m80000gn/T/go-build3487313098=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users//avx512test/go.mod'
GOMODCACHE='/Users//go/pkg/mod'
GONOPROXY='github.com/vsivsi'
GONOSUMDB='github.com/vsivsi'
GOOS='darwin'
GOPATH='/Users//go'
GOPRIVATE='github.com/vsivsi'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/Cellar/go/1.26.2/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users//Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/Cellar/go/1.26.2/libexec/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.26.2'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

On an Intel iMac Pro with an Intel(R) Xeon(R) W-2150B CPU @ 3.00GHz processor running MacOS version 15.7.5 (24G624), I attempted to use the new simd/archsimd experiment to implement a test function using AVX-512 intrinsics. The first step is to ensure the machine at runtime supports AVX-512 using the provided archsimd.X86.AVX512() call, which should always return true on a machine with AVX-512.

The following file tests whether that condition is met by comparing output with the golang.org/x/sys/cpu package cpu.X86.HasAVX512 flag.

//go:build goexperiment.simd && amd64

package archsimd_parity_test

import (
        "testing"

        "simd/archsimd"
        "golang.org/x/sys/cpu"
)

// TestAVX512Parity verifies that archsimd.X86.AVX512() and
// cpu.X86.HasAVX512 always agree. The two APIs are expected to reflect
// the same underlying CPU capability; any divergence would indicate a
// bug in one of the implementations.
func TestAVX512Parity(t *testing.T) {
        archsimdResult := archsimd.X86.AVX512()
        sysResult := cpu.X86.HasAVX512

        if archsimdResult != sysResult {
                t.Fatalf(
                        "AVX512 parity check FAILED: "+
                                "archsimd.X86.AVX512() = %v, "+
                                "cpu.X86.HasAVX512 = %v. "+
                                "\nThese two values should always be equal. ",
                        archsimdResult, sysResult,
                )
        }

        t.Logf("AVX512 parity OK: archsimd.X86.AVX512() == cpu.X86.HasAVX512 == %v", archsimdResult)
}

What did you see happen?

My test machine (iMac Pro) supports AVX-512, as reported by the darwin sysctl command:

echo "macOS $(sw_vers -productVersion)$(sysctl -n machdep.cpu.brand_string)" && \
echo "AVX-512 features present:" && \
sysctl machdep.cpu.leaf7_features 2>/dev/null | \
     grep -o 'AVX512[A-Z]*' || \
echo "No AVX-512 support detected"

Outputs:

macOS 15.7.5 — Intel(R) Xeon(R) W-2150B CPU @ 3.00GHz
AVX-512 features present:
AVX512F
AVX512DQ
AVX512CD
AVX512BW
AVX512VL

Running the test script from the previous section:

Save the file above in an new directory as e.g. avx512_test.go. Then:

go mod init avx512-parity
go get golang.org/x/sys/cpu
GOEXPERIMENT=simd go test -v -run TestAVX512Parity .

Outputs:

go: creating new go.mod: module avx512-parity
go: to add module requirements and sums:
	go mod tidy
go: added golang.org/x/sys v0.43.0
=== RUN   TestAVX512Parity
    avx512_test.go:21: AVX512 parity check FAILED: archsimd.X86.AVX512() = false, cpu.X86.HasAVX512 = true. 
        These two values should always be equal. 
--- FAIL: TestAVX512Parity (0.00s)
FAIL
FAIL	avx512-parity	0.270s
FAIL

Repeating the above tests on my MacBook Pro:

macOS 26.4 — Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
AVX-512 features present:
AVX512F
AVX512DQ
AVX512IFMA
AVX512CD
AVX512BW
AVX512VL
AVX512VBMI
AVX512VNNI
AVX512BITALG
AVX512VPOPCNTDQ

And:

go: creating new go.mod: module avx512-parity
go: to add module requirements and sums:
	go mod tidy
go: added golang.org/x/sys v0.43.0
=== RUN   TestAVX512Parity
    avx512_test.go:21: AVX512 parity check FAILED: archsimd.X86.AVX512() = false, cpu.X86.HasAVX512 = true. 
        These two values should always be equal. 
--- FAIL: TestAVX512Parity (0.00s)
FAIL
FAIL	avx512-parity	0.360s
FAIL

What did you expect to see?

I expect archsimd.X86.AVX512() return value to reflect the true AVX-512 capabilities of the hardware, and to be consistent with the output of cpu.X86.HasAVX512 from golang.org/x/sys/cpu.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions