mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.simd] simd, cmd/compile, go build, go/doc: test tweaks
these are for CL 675618 simd package exists and imports internal/cpu tweak tests to deal with goexperiment/not Change-Id: I2de99d048f0a228d5f3cd750c39ee5925107556e Reviewed-on: https://go-review.googlesource.com/c/go/+/677260 Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Junyang Shao <shaojunyang@google.com>
This commit is contained in:
parent
71c0e550cd
commit
eba2430c16
5 changed files with 32 additions and 2 deletions
|
|
@ -7,6 +7,7 @@ package ssagen
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"internal/buildcfg"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -15,6 +16,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var updateIntrinsics = flag.Bool("update", false, "Print an updated intrinsics table")
|
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 {
|
type testIntrinsicKey struct {
|
||||||
archName string
|
archName string
|
||||||
|
|
@ -1375,13 +1377,13 @@ func TestIntrinsics(t *testing.T) {
|
||||||
gotIntrinsics[testIntrinsicKey{ik.arch.Name, ik.pkg, ik.fn}] = struct{}{}
|
gotIntrinsics[testIntrinsicKey{ik.arch.Name, ik.pkg, ik.fn}] = struct{}{}
|
||||||
}
|
}
|
||||||
for ik, _ := range gotIntrinsics {
|
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)
|
t.Errorf("Got unwanted intrinsic %v %v.%v", ik.archName, ik.pkg, ik.fn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ik, _ := range wantIntrinsics {
|
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)
|
t.Errorf("Want missing intrinsic %v %v.%v", ik.archName, ik.pkg, ik.fn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,8 @@ var depsRules = `
|
||||||
internal/goarch < internal/abi;
|
internal/goarch < internal/abi;
|
||||||
internal/byteorder, internal/cpu, internal/goarch < internal/chacha8rand;
|
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.
|
# RUNTIME is the core runtime group of packages, all of them very light-weight.
|
||||||
internal/abi,
|
internal/abi,
|
||||||
internal/chacha8rand,
|
internal/chacha8rand,
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ var stdPkgs = []string{
|
||||||
"reflect",
|
"reflect",
|
||||||
"regexp",
|
"regexp",
|
||||||
"runtime",
|
"runtime",
|
||||||
|
"simd",
|
||||||
"slices",
|
"slices",
|
||||||
"sort",
|
"sort",
|
||||||
"strconv",
|
"strconv",
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
package comment
|
package comment
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"internal/buildcfg"
|
||||||
"internal/diff"
|
"internal/diff"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
@ -24,6 +25,10 @@ func TestStd(t *testing.T) {
|
||||||
list = append(list, pkg)
|
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)
|
slices.Sort(list)
|
||||||
|
|
||||||
have := strings.Join(stdPkgs, "\n") + "\n"
|
have := strings.Join(stdPkgs, "\n") + "\n"
|
||||||
|
|
|
||||||
20
src/simd/cpu.go
Normal file
20
src/simd/cpu.go
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
// 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
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue