mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.simd] simd: make OpMasked machine ops only
Right now we can expect the `Op(...).Masked` idiom to lack many parts that will make the API incomplete. But to make the API sizes smaller, we are removing these ops' frontend types and interfaces for now. We will have the peepholes and a new pass checking the CPU features check domination relations to make these ops picked for the right `Op(...).Masked` idiom. Change-Id: I77f72a198b3d8b1880dcb911470db5e0089ac1ca Reviewed-on: https://go-review.googlesource.com/c/go/+/697155 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Bypass: Junyang Shao <shaojunyang@google.com>
This commit is contained in:
parent
a034826e26
commit
0f660d675f
9 changed files with 10 additions and 32944 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
|
||||||
"simd/_gen/unify"
|
"simd/_gen/unify"
|
||||||
)
|
)
|
||||||
|
|
@ -100,6 +101,11 @@ func (o *Operation) DecodeUnified(v *unify.Value) error {
|
||||||
o.Documentation = regexp.MustCompile(`\bNAME\b`).ReplaceAllString(o.Documentation, o.Go)
|
o.Documentation = regexp.MustCompile(`\bNAME\b`).ReplaceAllString(o.Documentation, o.Go)
|
||||||
if isMasked {
|
if isMasked {
|
||||||
o.Documentation += "\n//\n// This operation is applied selectively under a write mask."
|
o.Documentation += "\n//\n// This operation is applied selectively under a write mask."
|
||||||
|
if unicode.IsUpper([]rune(o.Go)[0]) {
|
||||||
|
trueVal := "true"
|
||||||
|
o.NoGenericOps = &trueVal
|
||||||
|
o.NoTypes = &trueVal
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
o.In = append(o.rawOperation.In, o.rawOperation.InVariant...)
|
o.In = append(o.rawOperation.In, o.rawOperation.InVariant...)
|
||||||
|
|
|
||||||
|
|
@ -15,44 +15,6 @@ import (
|
||||||
// from > and =
|
// from > and =
|
||||||
var comparisonFixed bool = simd.HasAVX512()
|
var comparisonFixed bool = simd.HasAVX512()
|
||||||
|
|
||||||
func TestLessMasked(t *testing.T) {
|
|
||||||
if simd.HasAVX512() {
|
|
||||||
testFloat32x4CompareMasked(t, simd.Float32x4.LessMasked, lessSlice[float32])
|
|
||||||
testFloat32x8CompareMasked(t, simd.Float32x8.LessMasked, lessSlice[float32])
|
|
||||||
testFloat64x2CompareMasked(t, simd.Float64x2.LessMasked, lessSlice[float64])
|
|
||||||
testFloat64x4CompareMasked(t, simd.Float64x4.LessMasked, lessSlice[float64])
|
|
||||||
|
|
||||||
testInt16x16CompareMasked(t, simd.Int16x16.LessMasked, lessSlice[int16])
|
|
||||||
testInt16x8CompareMasked(t, simd.Int16x8.LessMasked, lessSlice[int16])
|
|
||||||
testInt32x4CompareMasked(t, simd.Int32x4.LessMasked, lessSlice[int32])
|
|
||||||
testInt32x8CompareMasked(t, simd.Int32x8.LessMasked, lessSlice[int32])
|
|
||||||
testInt64x2CompareMasked(t, simd.Int64x2.LessMasked, lessSlice[int64])
|
|
||||||
testInt64x4CompareMasked(t, simd.Int64x4.LessMasked, lessSlice[int64])
|
|
||||||
testInt8x16CompareMasked(t, simd.Int8x16.LessMasked, lessSlice[int8])
|
|
||||||
testInt8x32CompareMasked(t, simd.Int8x32.LessMasked, lessSlice[int8])
|
|
||||||
|
|
||||||
testUint16x16CompareMasked(t, simd.Uint16x16.LessMasked, lessSlice[uint16])
|
|
||||||
testUint16x8CompareMasked(t, simd.Uint16x8.LessMasked, lessSlice[uint16])
|
|
||||||
testUint32x4CompareMasked(t, simd.Uint32x4.LessMasked, lessSlice[uint32])
|
|
||||||
testUint32x8CompareMasked(t, simd.Uint32x8.LessMasked, lessSlice[uint32])
|
|
||||||
testUint64x2CompareMasked(t, simd.Uint64x2.LessMasked, lessSlice[uint64])
|
|
||||||
testUint64x4CompareMasked(t, simd.Uint64x4.LessMasked, lessSlice[uint64])
|
|
||||||
testUint8x16CompareMasked(t, simd.Uint8x16.LessMasked, lessSlice[uint8])
|
|
||||||
testUint8x32CompareMasked(t, simd.Uint8x32.LessMasked, lessSlice[uint8])
|
|
||||||
|
|
||||||
testFloat32x16CompareMasked(t, simd.Float32x16.LessMasked, lessSlice[float32])
|
|
||||||
testFloat64x8CompareMasked(t, simd.Float64x8.LessMasked, lessSlice[float64])
|
|
||||||
testInt8x64CompareMasked(t, simd.Int8x64.LessMasked, lessSlice[int8])
|
|
||||||
testInt16x32CompareMasked(t, simd.Int16x32.LessMasked, lessSlice[int16])
|
|
||||||
testInt32x16CompareMasked(t, simd.Int32x16.LessMasked, lessSlice[int32])
|
|
||||||
testInt64x8CompareMasked(t, simd.Int64x8.LessMasked, lessSlice[int64])
|
|
||||||
testUint8x64CompareMasked(t, simd.Uint8x64.LessMasked, lessSlice[uint8])
|
|
||||||
testUint16x32CompareMasked(t, simd.Uint16x32.LessMasked, lessSlice[uint16])
|
|
||||||
testUint32x16CompareMasked(t, simd.Uint32x16.LessMasked, lessSlice[uint32])
|
|
||||||
testUint64x8CompareMasked(t, simd.Uint64x8.LessMasked, lessSlice[uint64])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLess(t *testing.T) {
|
func TestLess(t *testing.T) {
|
||||||
testFloat32x4Compare(t, simd.Float32x4.Less, lessSlice[float32])
|
testFloat32x4Compare(t, simd.Float32x4.Less, lessSlice[float32])
|
||||||
testFloat32x8Compare(t, simd.Float32x8.Less, lessSlice[float32])
|
testFloat32x8Compare(t, simd.Float32x8.Less, lessSlice[float32])
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -43,7 +43,7 @@ func TestType(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v.z = maskT(simd.Mask32x4FromBits(0b0011))
|
v.z = maskT(simd.Mask32x4FromBits(0b0011))
|
||||||
*v.y = v.y.AddMasked(v.x, simd.Mask32x4(v.z))
|
*v.y = v.y.Add(v.x).Masked(simd.Mask32x4(v.z))
|
||||||
|
|
||||||
got := [4]int32{}
|
got := [4]int32{}
|
||||||
v.y.Store(&got)
|
v.y.Store(&got)
|
||||||
|
|
@ -121,7 +121,7 @@ func TestMaskConversion(t *testing.T) {
|
||||||
}
|
}
|
||||||
x := simd.LoadInt32x4Slice([]int32{5, 0, 7, 0})
|
x := simd.LoadInt32x4Slice([]int32{5, 0, 7, 0})
|
||||||
mask := simd.Int32x4{}.Sub(x).ToMask()
|
mask := simd.Int32x4{}.Sub(x).ToMask()
|
||||||
y := simd.LoadInt32x4Slice([]int32{1, 2, 3, 4}).AddMasked(x, mask)
|
y := simd.LoadInt32x4Slice([]int32{1, 2, 3, 4}).Add(x).Masked(mask)
|
||||||
want := [4]int32{6, 0, 10, 0}
|
want := [4]int32{6, 0, 10, 0}
|
||||||
got := make([]int32, 4)
|
got := make([]int32, 4)
|
||||||
y.StoreSlice(got)
|
y.StoreSlice(got)
|
||||||
|
|
@ -327,7 +327,7 @@ func TestBitMaskLoad(t *testing.T) {
|
||||||
results := [2]int64{}
|
results := [2]int64{}
|
||||||
want := [2]int64{0, 6}
|
want := [2]int64{0, 6}
|
||||||
m := simd.LoadMask64x2FromBits(&bits)
|
m := simd.LoadMask64x2FromBits(&bits)
|
||||||
simd.LoadInt64x2Slice([]int64{1, 2}).AddMasked(simd.LoadInt64x2Slice([]int64{3, 4}), m).Store(&results)
|
simd.LoadInt64x2Slice([]int64{1, 2}).Add(simd.LoadInt64x2Slice([]int64{3, 4})).Masked(m).Store(&results)
|
||||||
for i := range 2 {
|
for i := range 2 {
|
||||||
if results[i] != want[i] {
|
if results[i] != want[i] {
|
||||||
t.Errorf("Result at %d incorrect: want %v, got %v", i, want[i], results[i])
|
t.Errorf("Result at %d incorrect: want %v, got %v", i, want[i], results[i])
|
||||||
|
|
@ -359,7 +359,7 @@ func TestBitMaskFromBits(t *testing.T) {
|
||||||
results := [2]int64{}
|
results := [2]int64{}
|
||||||
want := [2]int64{0, 6}
|
want := [2]int64{0, 6}
|
||||||
m := simd.Mask64x2FromBits(0b10)
|
m := simd.Mask64x2FromBits(0b10)
|
||||||
simd.LoadInt64x2Slice([]int64{1, 2}).AddMasked(simd.LoadInt64x2Slice([]int64{3, 4}), m).Store(&results)
|
simd.LoadInt64x2Slice([]int64{1, 2}).Add(simd.LoadInt64x2Slice([]int64{3, 4})).Masked(m).Store(&results)
|
||||||
for i := range 2 {
|
for i := range 2 {
|
||||||
if results[i] != want[i] {
|
if results[i] != want[i] {
|
||||||
t.Errorf("Result at %d incorrect: want %v, got %v", i, want[i], results[i])
|
t.Errorf("Result at %d incorrect: want %v, got %v", i, want[i], results[i])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue