import (
"flag"
"fmt"
+ "internal/buildcfg"
"slices"
"strings"
"testing"
)
var updateIntrinsics = flag.Bool("update", false, "Print an updated intrinsics table")
+var simd = flag.Bool("simd", buildcfg.Experiment.SIMD, "Also check SIMD intrinsics; defaults to GOEXPERIMENT==simd")
type testIntrinsicKey struct {
archName string
gotIntrinsics[testIntrinsicKey{ik.arch.Name, ik.pkg, ik.fn}] = struct{}{}
}
for ik, _ := range gotIntrinsics {
- if _, found := wantIntrinsics[ik]; !found {
+ if _, found := wantIntrinsics[ik]; !found && (ik.pkg != "simd" || *simd) {
t.Errorf("Got unwanted intrinsic %v %v.%v", ik.archName, ik.pkg, ik.fn)
}
}
for ik, _ := range wantIntrinsics {
- if _, found := gotIntrinsics[ik]; !found {
+ if _, found := gotIntrinsics[ik]; !found && (ik.pkg != "simd" || *simd) {
t.Errorf("Want missing intrinsic %v %v.%v", ik.archName, ik.pkg, ik.fn)
}
}
internal/goarch < internal/abi;
internal/byteorder, internal/cpu, internal/goarch < internal/chacha8rand;
+ internal/cpu < simd;
+
# RUNTIME is the core runtime group of packages, all of them very light-weight.
internal/abi,
internal/chacha8rand,
package comment
import (
+ "internal/buildcfg"
"internal/diff"
"internal/testenv"
"slices"
list = append(list, pkg)
}
}
+ // TODO remove this when simd is the default, for now fake its existence
+ if !buildcfg.Experiment.SIMD {
+ list = append(list, "simd")
+ }
slices.Sort(list)
have := strings.Join(stdPkgs, "\n") + "\n"
--- /dev/null
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build goexperiment.simd
+
+// the build condition == if the experiment is not on, cmd/api TestCheck will see this and complain
+// see also go/doc/comment, where "simd" is inserted to the package list of the experiment is not on.
+
+package simd
+
+import "internal/cpu"
+
+func HasAVX512BW() bool {
+ return cpu.X86.HasAVX512BW
+}
+
+func HasAVX512VL() bool {
+ return cpu.X86.HasAVX512VL
+}