From: David Chase Date: Tue, 22 Jul 2025 19:34:55 +0000 (-0400) Subject: [dev.simd] simd: modify test generation to make it more flexible X-Git-Tag: go1.26rc1~147^2~159 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a24ffe337946ff2142baa772c0be27f28c3cdf98;p=gostls13.git [dev.simd] simd: modify test generation to make it more flexible This is to support conversions, which are not T -> T. Change-Id: I323887b116eee8133770a899ed82363bba38a9c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/689717 Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI --- diff --git a/src/simd/binary_helpers_test.go b/src/simd/binary_helpers_test.go index b505598058..fbf31beb7c 100644 --- a/src/simd/binary_helpers_test.go +++ b/src/simd/binary_helpers_test.go @@ -28,90 +28,90 @@ func testInt8x16Binary(t *testing.T, f func(_, _ simd.Int8x16) simd.Int8x16, wan }) } -// testUint8x16Binary tests the simd binary method f against the expected behavior generated by want -func testUint8x16Binary(t *testing.T, f func(_, _ simd.Uint8x16) simd.Uint8x16, want func(_, _ []uint8) []uint8) { - n := 16 +// testInt16x8Binary tests the simd binary method f against the expected behavior generated by want +func testInt16x8Binary(t *testing.T, f func(_, _ simd.Int16x8) simd.Int16x8, want func(_, _ []int16) []int16) { + n := 8 t.Helper() - forSlicePair(t, uint8s, n, func(x, y []uint8) bool { + forSlicePair(t, int16s, n, func(x, y []int16) bool { t.Helper() - a := simd.LoadUint8x16Slice(x) - b := simd.LoadUint8x16Slice(y) - g := make([]uint8, n) + a := simd.LoadInt16x8Slice(x) + b := simd.LoadInt16x8Slice(y) + g := make([]int16, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testInt16x8Binary tests the simd binary method f against the expected behavior generated by want -func testInt16x8Binary(t *testing.T, f func(_, _ simd.Int16x8) simd.Int16x8, want func(_, _ []int16) []int16) { - n := 8 +// testInt32x4Binary tests the simd binary method f against the expected behavior generated by want +func testInt32x4Binary(t *testing.T, f func(_, _ simd.Int32x4) simd.Int32x4, want func(_, _ []int32) []int32) { + n := 4 t.Helper() - forSlicePair(t, int16s, n, func(x, y []int16) bool { + forSlicePair(t, int32s, n, func(x, y []int32) bool { t.Helper() - a := simd.LoadInt16x8Slice(x) - b := simd.LoadInt16x8Slice(y) - g := make([]int16, n) + a := simd.LoadInt32x4Slice(x) + b := simd.LoadInt32x4Slice(y) + g := make([]int32, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testUint16x8Binary tests the simd binary method f against the expected behavior generated by want -func testUint16x8Binary(t *testing.T, f func(_, _ simd.Uint16x8) simd.Uint16x8, want func(_, _ []uint16) []uint16) { - n := 8 +// testInt64x2Binary tests the simd binary method f against the expected behavior generated by want +func testInt64x2Binary(t *testing.T, f func(_, _ simd.Int64x2) simd.Int64x2, want func(_, _ []int64) []int64) { + n := 2 t.Helper() - forSlicePair(t, uint16s, n, func(x, y []uint16) bool { + forSlicePair(t, int64s, n, func(x, y []int64) bool { t.Helper() - a := simd.LoadUint16x8Slice(x) - b := simd.LoadUint16x8Slice(y) - g := make([]uint16, n) + a := simd.LoadInt64x2Slice(x) + b := simd.LoadInt64x2Slice(y) + g := make([]int64, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testInt32x4Binary tests the simd binary method f against the expected behavior generated by want -func testInt32x4Binary(t *testing.T, f func(_, _ simd.Int32x4) simd.Int32x4, want func(_, _ []int32) []int32) { - n := 4 +// testUint8x16Binary tests the simd binary method f against the expected behavior generated by want +func testUint8x16Binary(t *testing.T, f func(_, _ simd.Uint8x16) simd.Uint8x16, want func(_, _ []uint8) []uint8) { + n := 16 t.Helper() - forSlicePair(t, int32s, n, func(x, y []int32) bool { + forSlicePair(t, uint8s, n, func(x, y []uint8) bool { t.Helper() - a := simd.LoadInt32x4Slice(x) - b := simd.LoadInt32x4Slice(y) - g := make([]int32, n) + a := simd.LoadUint8x16Slice(x) + b := simd.LoadUint8x16Slice(y) + g := make([]uint8, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testUint32x4Binary tests the simd binary method f against the expected behavior generated by want -func testUint32x4Binary(t *testing.T, f func(_, _ simd.Uint32x4) simd.Uint32x4, want func(_, _ []uint32) []uint32) { - n := 4 +// testUint16x8Binary tests the simd binary method f against the expected behavior generated by want +func testUint16x8Binary(t *testing.T, f func(_, _ simd.Uint16x8) simd.Uint16x8, want func(_, _ []uint16) []uint16) { + n := 8 t.Helper() - forSlicePair(t, uint32s, n, func(x, y []uint32) bool { + forSlicePair(t, uint16s, n, func(x, y []uint16) bool { t.Helper() - a := simd.LoadUint32x4Slice(x) - b := simd.LoadUint32x4Slice(y) - g := make([]uint32, n) + a := simd.LoadUint16x8Slice(x) + b := simd.LoadUint16x8Slice(y) + g := make([]uint16, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testInt64x2Binary tests the simd binary method f against the expected behavior generated by want -func testInt64x2Binary(t *testing.T, f func(_, _ simd.Int64x2) simd.Int64x2, want func(_, _ []int64) []int64) { - n := 2 +// testUint32x4Binary tests the simd binary method f against the expected behavior generated by want +func testUint32x4Binary(t *testing.T, f func(_, _ simd.Uint32x4) simd.Uint32x4, want func(_, _ []uint32) []uint32) { + n := 4 t.Helper() - forSlicePair(t, int64s, n, func(x, y []int64) bool { + forSlicePair(t, uint32s, n, func(x, y []uint32) bool { t.Helper() - a := simd.LoadInt64x2Slice(x) - b := simd.LoadInt64x2Slice(y) - g := make([]int64, n) + a := simd.LoadUint32x4Slice(x) + b := simd.LoadUint32x4Slice(y) + g := make([]uint32, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) @@ -178,90 +178,90 @@ func testInt8x32Binary(t *testing.T, f func(_, _ simd.Int8x32) simd.Int8x32, wan }) } -// testUint8x32Binary tests the simd binary method f against the expected behavior generated by want -func testUint8x32Binary(t *testing.T, f func(_, _ simd.Uint8x32) simd.Uint8x32, want func(_, _ []uint8) []uint8) { - n := 32 +// testInt16x16Binary tests the simd binary method f against the expected behavior generated by want +func testInt16x16Binary(t *testing.T, f func(_, _ simd.Int16x16) simd.Int16x16, want func(_, _ []int16) []int16) { + n := 16 t.Helper() - forSlicePair(t, uint8s, n, func(x, y []uint8) bool { + forSlicePair(t, int16s, n, func(x, y []int16) bool { t.Helper() - a := simd.LoadUint8x32Slice(x) - b := simd.LoadUint8x32Slice(y) - g := make([]uint8, n) + a := simd.LoadInt16x16Slice(x) + b := simd.LoadInt16x16Slice(y) + g := make([]int16, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testInt16x16Binary tests the simd binary method f against the expected behavior generated by want -func testInt16x16Binary(t *testing.T, f func(_, _ simd.Int16x16) simd.Int16x16, want func(_, _ []int16) []int16) { - n := 16 +// testInt32x8Binary tests the simd binary method f against the expected behavior generated by want +func testInt32x8Binary(t *testing.T, f func(_, _ simd.Int32x8) simd.Int32x8, want func(_, _ []int32) []int32) { + n := 8 t.Helper() - forSlicePair(t, int16s, n, func(x, y []int16) bool { + forSlicePair(t, int32s, n, func(x, y []int32) bool { t.Helper() - a := simd.LoadInt16x16Slice(x) - b := simd.LoadInt16x16Slice(y) - g := make([]int16, n) + a := simd.LoadInt32x8Slice(x) + b := simd.LoadInt32x8Slice(y) + g := make([]int32, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testUint16x16Binary tests the simd binary method f against the expected behavior generated by want -func testUint16x16Binary(t *testing.T, f func(_, _ simd.Uint16x16) simd.Uint16x16, want func(_, _ []uint16) []uint16) { - n := 16 +// testInt64x4Binary tests the simd binary method f against the expected behavior generated by want +func testInt64x4Binary(t *testing.T, f func(_, _ simd.Int64x4) simd.Int64x4, want func(_, _ []int64) []int64) { + n := 4 t.Helper() - forSlicePair(t, uint16s, n, func(x, y []uint16) bool { + forSlicePair(t, int64s, n, func(x, y []int64) bool { t.Helper() - a := simd.LoadUint16x16Slice(x) - b := simd.LoadUint16x16Slice(y) - g := make([]uint16, n) + a := simd.LoadInt64x4Slice(x) + b := simd.LoadInt64x4Slice(y) + g := make([]int64, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testInt32x8Binary tests the simd binary method f against the expected behavior generated by want -func testInt32x8Binary(t *testing.T, f func(_, _ simd.Int32x8) simd.Int32x8, want func(_, _ []int32) []int32) { - n := 8 +// testUint8x32Binary tests the simd binary method f against the expected behavior generated by want +func testUint8x32Binary(t *testing.T, f func(_, _ simd.Uint8x32) simd.Uint8x32, want func(_, _ []uint8) []uint8) { + n := 32 t.Helper() - forSlicePair(t, int32s, n, func(x, y []int32) bool { + forSlicePair(t, uint8s, n, func(x, y []uint8) bool { t.Helper() - a := simd.LoadInt32x8Slice(x) - b := simd.LoadInt32x8Slice(y) - g := make([]int32, n) + a := simd.LoadUint8x32Slice(x) + b := simd.LoadUint8x32Slice(y) + g := make([]uint8, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testUint32x8Binary tests the simd binary method f against the expected behavior generated by want -func testUint32x8Binary(t *testing.T, f func(_, _ simd.Uint32x8) simd.Uint32x8, want func(_, _ []uint32) []uint32) { - n := 8 +// testUint16x16Binary tests the simd binary method f against the expected behavior generated by want +func testUint16x16Binary(t *testing.T, f func(_, _ simd.Uint16x16) simd.Uint16x16, want func(_, _ []uint16) []uint16) { + n := 16 t.Helper() - forSlicePair(t, uint32s, n, func(x, y []uint32) bool { + forSlicePair(t, uint16s, n, func(x, y []uint16) bool { t.Helper() - a := simd.LoadUint32x8Slice(x) - b := simd.LoadUint32x8Slice(y) - g := make([]uint32, n) + a := simd.LoadUint16x16Slice(x) + b := simd.LoadUint16x16Slice(y) + g := make([]uint16, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testInt64x4Binary tests the simd binary method f against the expected behavior generated by want -func testInt64x4Binary(t *testing.T, f func(_, _ simd.Int64x4) simd.Int64x4, want func(_, _ []int64) []int64) { - n := 4 +// testUint32x8Binary tests the simd binary method f against the expected behavior generated by want +func testUint32x8Binary(t *testing.T, f func(_, _ simd.Uint32x8) simd.Uint32x8, want func(_, _ []uint32) []uint32) { + n := 8 t.Helper() - forSlicePair(t, int64s, n, func(x, y []int64) bool { + forSlicePair(t, uint32s, n, func(x, y []uint32) bool { t.Helper() - a := simd.LoadInt64x4Slice(x) - b := simd.LoadInt64x4Slice(y) - g := make([]int64, n) + a := simd.LoadUint32x8Slice(x) + b := simd.LoadUint32x8Slice(y) + g := make([]uint32, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) @@ -328,90 +328,90 @@ func testInt8x64Binary(t *testing.T, f func(_, _ simd.Int8x64) simd.Int8x64, wan }) } -// testUint8x64Binary tests the simd binary method f against the expected behavior generated by want -func testUint8x64Binary(t *testing.T, f func(_, _ simd.Uint8x64) simd.Uint8x64, want func(_, _ []uint8) []uint8) { - n := 64 +// testInt16x32Binary tests the simd binary method f against the expected behavior generated by want +func testInt16x32Binary(t *testing.T, f func(_, _ simd.Int16x32) simd.Int16x32, want func(_, _ []int16) []int16) { + n := 32 t.Helper() - forSlicePair(t, uint8s, n, func(x, y []uint8) bool { + forSlicePair(t, int16s, n, func(x, y []int16) bool { t.Helper() - a := simd.LoadUint8x64Slice(x) - b := simd.LoadUint8x64Slice(y) - g := make([]uint8, n) + a := simd.LoadInt16x32Slice(x) + b := simd.LoadInt16x32Slice(y) + g := make([]int16, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testInt16x32Binary tests the simd binary method f against the expected behavior generated by want -func testInt16x32Binary(t *testing.T, f func(_, _ simd.Int16x32) simd.Int16x32, want func(_, _ []int16) []int16) { - n := 32 +// testInt32x16Binary tests the simd binary method f against the expected behavior generated by want +func testInt32x16Binary(t *testing.T, f func(_, _ simd.Int32x16) simd.Int32x16, want func(_, _ []int32) []int32) { + n := 16 t.Helper() - forSlicePair(t, int16s, n, func(x, y []int16) bool { + forSlicePair(t, int32s, n, func(x, y []int32) bool { t.Helper() - a := simd.LoadInt16x32Slice(x) - b := simd.LoadInt16x32Slice(y) - g := make([]int16, n) + a := simd.LoadInt32x16Slice(x) + b := simd.LoadInt32x16Slice(y) + g := make([]int32, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testUint16x32Binary tests the simd binary method f against the expected behavior generated by want -func testUint16x32Binary(t *testing.T, f func(_, _ simd.Uint16x32) simd.Uint16x32, want func(_, _ []uint16) []uint16) { - n := 32 +// testInt64x8Binary tests the simd binary method f against the expected behavior generated by want +func testInt64x8Binary(t *testing.T, f func(_, _ simd.Int64x8) simd.Int64x8, want func(_, _ []int64) []int64) { + n := 8 t.Helper() - forSlicePair(t, uint16s, n, func(x, y []uint16) bool { + forSlicePair(t, int64s, n, func(x, y []int64) bool { t.Helper() - a := simd.LoadUint16x32Slice(x) - b := simd.LoadUint16x32Slice(y) - g := make([]uint16, n) + a := simd.LoadInt64x8Slice(x) + b := simd.LoadInt64x8Slice(y) + g := make([]int64, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testInt32x16Binary tests the simd binary method f against the expected behavior generated by want -func testInt32x16Binary(t *testing.T, f func(_, _ simd.Int32x16) simd.Int32x16, want func(_, _ []int32) []int32) { - n := 16 +// testUint8x64Binary tests the simd binary method f against the expected behavior generated by want +func testUint8x64Binary(t *testing.T, f func(_, _ simd.Uint8x64) simd.Uint8x64, want func(_, _ []uint8) []uint8) { + n := 64 t.Helper() - forSlicePair(t, int32s, n, func(x, y []int32) bool { + forSlicePair(t, uint8s, n, func(x, y []uint8) bool { t.Helper() - a := simd.LoadInt32x16Slice(x) - b := simd.LoadInt32x16Slice(y) - g := make([]int32, n) + a := simd.LoadUint8x64Slice(x) + b := simd.LoadUint8x64Slice(y) + g := make([]uint8, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testUint32x16Binary tests the simd binary method f against the expected behavior generated by want -func testUint32x16Binary(t *testing.T, f func(_, _ simd.Uint32x16) simd.Uint32x16, want func(_, _ []uint32) []uint32) { - n := 16 +// testUint16x32Binary tests the simd binary method f against the expected behavior generated by want +func testUint16x32Binary(t *testing.T, f func(_, _ simd.Uint16x32) simd.Uint16x32, want func(_, _ []uint16) []uint16) { + n := 32 t.Helper() - forSlicePair(t, uint32s, n, func(x, y []uint32) bool { + forSlicePair(t, uint16s, n, func(x, y []uint16) bool { t.Helper() - a := simd.LoadUint32x16Slice(x) - b := simd.LoadUint32x16Slice(y) - g := make([]uint32, n) + a := simd.LoadUint16x32Slice(x) + b := simd.LoadUint16x32Slice(y) + g := make([]uint16, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) }) } -// testInt64x8Binary tests the simd binary method f against the expected behavior generated by want -func testInt64x8Binary(t *testing.T, f func(_, _ simd.Int64x8) simd.Int64x8, want func(_, _ []int64) []int64) { - n := 8 +// testUint32x16Binary tests the simd binary method f against the expected behavior generated by want +func testUint32x16Binary(t *testing.T, f func(_, _ simd.Uint32x16) simd.Uint32x16, want func(_, _ []uint32) []uint32) { + n := 16 t.Helper() - forSlicePair(t, int64s, n, func(x, y []int64) bool { + forSlicePair(t, uint32s, n, func(x, y []uint32) bool { t.Helper() - a := simd.LoadInt64x8Slice(x) - b := simd.LoadInt64x8Slice(y) - g := make([]int64, n) + a := simd.LoadUint32x16Slice(x) + b := simd.LoadUint32x16Slice(y) + g := make([]uint32, n) f(a, b).StoreSlice(g) w := want(x, y) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) diff --git a/src/simd/compare_helpers_test.go b/src/simd/compare_helpers_test.go index 948386307c..e6d7c82c8f 100644 --- a/src/simd/compare_helpers_test.go +++ b/src/simd/compare_helpers_test.go @@ -28,21 +28,6 @@ func testInt8x16Compare(t *testing.T, f func(_, _ simd.Int8x16) simd.Mask8x16, w }) } -// testUint8x16Compare tests the simd comparison method f against the expected behavior generated by want -func testUint8x16Compare(t *testing.T, f func(_, _ simd.Uint8x16) simd.Mask8x16, want func(_, _ []uint8) []int64) { - n := 16 - t.Helper() - forSlicePair(t, uint8s, n, func(x, y []uint8) bool { - t.Helper() - a := simd.LoadUint8x16Slice(x) - b := simd.LoadUint8x16Slice(y) - g := make([]int8, n) - f(a, b).AsInt8x16().StoreSlice(g) - w := want(x, y) - return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) - }) -} - // testInt16x8Compare tests the simd comparison method f against the expected behavior generated by want func testInt16x8Compare(t *testing.T, f func(_, _ simd.Int16x8) simd.Mask16x8, want func(_, _ []int16) []int64) { n := 8 @@ -58,21 +43,6 @@ func testInt16x8Compare(t *testing.T, f func(_, _ simd.Int16x8) simd.Mask16x8, w }) } -// testUint16x8Compare tests the simd comparison method f against the expected behavior generated by want -func testUint16x8Compare(t *testing.T, f func(_, _ simd.Uint16x8) simd.Mask16x8, want func(_, _ []uint16) []int64) { - n := 8 - t.Helper() - forSlicePair(t, uint16s, n, func(x, y []uint16) bool { - t.Helper() - a := simd.LoadUint16x8Slice(x) - b := simd.LoadUint16x8Slice(y) - g := make([]int16, n) - f(a, b).AsInt16x8().StoreSlice(g) - w := want(x, y) - return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) - }) -} - // testInt32x4Compare tests the simd comparison method f against the expected behavior generated by want func testInt32x4Compare(t *testing.T, f func(_, _ simd.Int32x4) simd.Mask32x4, want func(_, _ []int32) []int64) { n := 4 @@ -88,21 +58,6 @@ func testInt32x4Compare(t *testing.T, f func(_, _ simd.Int32x4) simd.Mask32x4, w }) } -// testUint32x4Compare tests the simd comparison method f against the expected behavior generated by want -func testUint32x4Compare(t *testing.T, f func(_, _ simd.Uint32x4) simd.Mask32x4, want func(_, _ []uint32) []int64) { - n := 4 - t.Helper() - forSlicePair(t, uint32s, n, func(x, y []uint32) bool { - t.Helper() - a := simd.LoadUint32x4Slice(x) - b := simd.LoadUint32x4Slice(y) - g := make([]int32, n) - f(a, b).AsInt32x4().StoreSlice(g) - w := want(x, y) - return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) - }) -} - // testInt64x2Compare tests the simd comparison method f against the expected behavior generated by want func testInt64x2Compare(t *testing.T, f func(_, _ simd.Int64x2) simd.Mask64x2, want func(_, _ []int64) []int64) { n := 2 @@ -118,6 +73,51 @@ func testInt64x2Compare(t *testing.T, f func(_, _ simd.Int64x2) simd.Mask64x2, w }) } +// testUint8x16Compare tests the simd comparison method f against the expected behavior generated by want +func testUint8x16Compare(t *testing.T, f func(_, _ simd.Uint8x16) simd.Mask8x16, want func(_, _ []uint8) []int64) { + n := 16 + t.Helper() + forSlicePair(t, uint8s, n, func(x, y []uint8) bool { + t.Helper() + a := simd.LoadUint8x16Slice(x) + b := simd.LoadUint8x16Slice(y) + g := make([]int8, n) + f(a, b).AsInt8x16().StoreSlice(g) + w := want(x, y) + return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) + }) +} + +// testUint16x8Compare tests the simd comparison method f against the expected behavior generated by want +func testUint16x8Compare(t *testing.T, f func(_, _ simd.Uint16x8) simd.Mask16x8, want func(_, _ []uint16) []int64) { + n := 8 + t.Helper() + forSlicePair(t, uint16s, n, func(x, y []uint16) bool { + t.Helper() + a := simd.LoadUint16x8Slice(x) + b := simd.LoadUint16x8Slice(y) + g := make([]int16, n) + f(a, b).AsInt16x8().StoreSlice(g) + w := want(x, y) + return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) + }) +} + +// testUint32x4Compare tests the simd comparison method f against the expected behavior generated by want +func testUint32x4Compare(t *testing.T, f func(_, _ simd.Uint32x4) simd.Mask32x4, want func(_, _ []uint32) []int64) { + n := 4 + t.Helper() + forSlicePair(t, uint32s, n, func(x, y []uint32) bool { + t.Helper() + a := simd.LoadUint32x4Slice(x) + b := simd.LoadUint32x4Slice(y) + g := make([]int32, n) + f(a, b).AsInt32x4().StoreSlice(g) + w := want(x, y) + return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) + }) +} + // testUint64x2Compare tests the simd comparison method f against the expected behavior generated by want func testUint64x2Compare(t *testing.T, f func(_, _ simd.Uint64x2) simd.Mask64x2, want func(_, _ []uint64) []int64) { n := 2 @@ -178,21 +178,6 @@ func testInt8x32Compare(t *testing.T, f func(_, _ simd.Int8x32) simd.Mask8x32, w }) } -// testUint8x32Compare tests the simd comparison method f against the expected behavior generated by want -func testUint8x32Compare(t *testing.T, f func(_, _ simd.Uint8x32) simd.Mask8x32, want func(_, _ []uint8) []int64) { - n := 32 - t.Helper() - forSlicePair(t, uint8s, n, func(x, y []uint8) bool { - t.Helper() - a := simd.LoadUint8x32Slice(x) - b := simd.LoadUint8x32Slice(y) - g := make([]int8, n) - f(a, b).AsInt8x32().StoreSlice(g) - w := want(x, y) - return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) - }) -} - // testInt16x16Compare tests the simd comparison method f against the expected behavior generated by want func testInt16x16Compare(t *testing.T, f func(_, _ simd.Int16x16) simd.Mask16x16, want func(_, _ []int16) []int64) { n := 16 @@ -208,21 +193,6 @@ func testInt16x16Compare(t *testing.T, f func(_, _ simd.Int16x16) simd.Mask16x16 }) } -// testUint16x16Compare tests the simd comparison method f against the expected behavior generated by want -func testUint16x16Compare(t *testing.T, f func(_, _ simd.Uint16x16) simd.Mask16x16, want func(_, _ []uint16) []int64) { - n := 16 - t.Helper() - forSlicePair(t, uint16s, n, func(x, y []uint16) bool { - t.Helper() - a := simd.LoadUint16x16Slice(x) - b := simd.LoadUint16x16Slice(y) - g := make([]int16, n) - f(a, b).AsInt16x16().StoreSlice(g) - w := want(x, y) - return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) - }) -} - // testInt32x8Compare tests the simd comparison method f against the expected behavior generated by want func testInt32x8Compare(t *testing.T, f func(_, _ simd.Int32x8) simd.Mask32x8, want func(_, _ []int32) []int64) { n := 8 @@ -238,21 +208,6 @@ func testInt32x8Compare(t *testing.T, f func(_, _ simd.Int32x8) simd.Mask32x8, w }) } -// testUint32x8Compare tests the simd comparison method f against the expected behavior generated by want -func testUint32x8Compare(t *testing.T, f func(_, _ simd.Uint32x8) simd.Mask32x8, want func(_, _ []uint32) []int64) { - n := 8 - t.Helper() - forSlicePair(t, uint32s, n, func(x, y []uint32) bool { - t.Helper() - a := simd.LoadUint32x8Slice(x) - b := simd.LoadUint32x8Slice(y) - g := make([]int32, n) - f(a, b).AsInt32x8().StoreSlice(g) - w := want(x, y) - return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) - }) -} - // testInt64x4Compare tests the simd comparison method f against the expected behavior generated by want func testInt64x4Compare(t *testing.T, f func(_, _ simd.Int64x4) simd.Mask64x4, want func(_, _ []int64) []int64) { n := 4 @@ -268,6 +223,51 @@ func testInt64x4Compare(t *testing.T, f func(_, _ simd.Int64x4) simd.Mask64x4, w }) } +// testUint8x32Compare tests the simd comparison method f against the expected behavior generated by want +func testUint8x32Compare(t *testing.T, f func(_, _ simd.Uint8x32) simd.Mask8x32, want func(_, _ []uint8) []int64) { + n := 32 + t.Helper() + forSlicePair(t, uint8s, n, func(x, y []uint8) bool { + t.Helper() + a := simd.LoadUint8x32Slice(x) + b := simd.LoadUint8x32Slice(y) + g := make([]int8, n) + f(a, b).AsInt8x32().StoreSlice(g) + w := want(x, y) + return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) + }) +} + +// testUint16x16Compare tests the simd comparison method f against the expected behavior generated by want +func testUint16x16Compare(t *testing.T, f func(_, _ simd.Uint16x16) simd.Mask16x16, want func(_, _ []uint16) []int64) { + n := 16 + t.Helper() + forSlicePair(t, uint16s, n, func(x, y []uint16) bool { + t.Helper() + a := simd.LoadUint16x16Slice(x) + b := simd.LoadUint16x16Slice(y) + g := make([]int16, n) + f(a, b).AsInt16x16().StoreSlice(g) + w := want(x, y) + return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) + }) +} + +// testUint32x8Compare tests the simd comparison method f against the expected behavior generated by want +func testUint32x8Compare(t *testing.T, f func(_, _ simd.Uint32x8) simd.Mask32x8, want func(_, _ []uint32) []int64) { + n := 8 + t.Helper() + forSlicePair(t, uint32s, n, func(x, y []uint32) bool { + t.Helper() + a := simd.LoadUint32x8Slice(x) + b := simd.LoadUint32x8Slice(y) + g := make([]int32, n) + f(a, b).AsInt32x8().StoreSlice(g) + w := want(x, y) + return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) + }) +} + // testUint64x4Compare tests the simd comparison method f against the expected behavior generated by want func testUint64x4Compare(t *testing.T, f func(_, _ simd.Uint64x4) simd.Mask64x4, want func(_, _ []uint64) []int64) { n := 4 @@ -328,21 +328,6 @@ func testInt8x64Compare(t *testing.T, f func(_, _ simd.Int8x64) simd.Mask8x64, w }) } -// testUint8x64Compare tests the simd comparison method f against the expected behavior generated by want -func testUint8x64Compare(t *testing.T, f func(_, _ simd.Uint8x64) simd.Mask8x64, want func(_, _ []uint8) []int64) { - n := 64 - t.Helper() - forSlicePair(t, uint8s, n, func(x, y []uint8) bool { - t.Helper() - a := simd.LoadUint8x64Slice(x) - b := simd.LoadUint8x64Slice(y) - g := make([]int8, n) - f(a, b).AsInt8x64().StoreSlice(g) - w := want(x, y) - return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) - }) -} - // testInt16x32Compare tests the simd comparison method f against the expected behavior generated by want func testInt16x32Compare(t *testing.T, f func(_, _ simd.Int16x32) simd.Mask16x32, want func(_, _ []int16) []int64) { n := 32 @@ -358,21 +343,6 @@ func testInt16x32Compare(t *testing.T, f func(_, _ simd.Int16x32) simd.Mask16x32 }) } -// testUint16x32Compare tests the simd comparison method f against the expected behavior generated by want -func testUint16x32Compare(t *testing.T, f func(_, _ simd.Uint16x32) simd.Mask16x32, want func(_, _ []uint16) []int64) { - n := 32 - t.Helper() - forSlicePair(t, uint16s, n, func(x, y []uint16) bool { - t.Helper() - a := simd.LoadUint16x32Slice(x) - b := simd.LoadUint16x32Slice(y) - g := make([]int16, n) - f(a, b).AsInt16x32().StoreSlice(g) - w := want(x, y) - return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) - }) -} - // testInt32x16Compare tests the simd comparison method f against the expected behavior generated by want func testInt32x16Compare(t *testing.T, f func(_, _ simd.Int32x16) simd.Mask32x16, want func(_, _ []int32) []int64) { n := 16 @@ -388,21 +358,6 @@ func testInt32x16Compare(t *testing.T, f func(_, _ simd.Int32x16) simd.Mask32x16 }) } -// testUint32x16Compare tests the simd comparison method f against the expected behavior generated by want -func testUint32x16Compare(t *testing.T, f func(_, _ simd.Uint32x16) simd.Mask32x16, want func(_, _ []uint32) []int64) { - n := 16 - t.Helper() - forSlicePair(t, uint32s, n, func(x, y []uint32) bool { - t.Helper() - a := simd.LoadUint32x16Slice(x) - b := simd.LoadUint32x16Slice(y) - g := make([]int32, n) - f(a, b).AsInt32x16().StoreSlice(g) - w := want(x, y) - return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) - }) -} - // testInt64x8Compare tests the simd comparison method f against the expected behavior generated by want func testInt64x8Compare(t *testing.T, f func(_, _ simd.Int64x8) simd.Mask64x8, want func(_, _ []int64) []int64) { n := 8 @@ -418,6 +373,51 @@ func testInt64x8Compare(t *testing.T, f func(_, _ simd.Int64x8) simd.Mask64x8, w }) } +// testUint8x64Compare tests the simd comparison method f against the expected behavior generated by want +func testUint8x64Compare(t *testing.T, f func(_, _ simd.Uint8x64) simd.Mask8x64, want func(_, _ []uint8) []int64) { + n := 64 + t.Helper() + forSlicePair(t, uint8s, n, func(x, y []uint8) bool { + t.Helper() + a := simd.LoadUint8x64Slice(x) + b := simd.LoadUint8x64Slice(y) + g := make([]int8, n) + f(a, b).AsInt8x64().StoreSlice(g) + w := want(x, y) + return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) + }) +} + +// testUint16x32Compare tests the simd comparison method f against the expected behavior generated by want +func testUint16x32Compare(t *testing.T, f func(_, _ simd.Uint16x32) simd.Mask16x32, want func(_, _ []uint16) []int64) { + n := 32 + t.Helper() + forSlicePair(t, uint16s, n, func(x, y []uint16) bool { + t.Helper() + a := simd.LoadUint16x32Slice(x) + b := simd.LoadUint16x32Slice(y) + g := make([]int16, n) + f(a, b).AsInt16x32().StoreSlice(g) + w := want(x, y) + return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) + }) +} + +// testUint32x16Compare tests the simd comparison method f against the expected behavior generated by want +func testUint32x16Compare(t *testing.T, f func(_, _ simd.Uint32x16) simd.Mask32x16, want func(_, _ []uint32) []int64) { + n := 16 + t.Helper() + forSlicePair(t, uint32s, n, func(x, y []uint32) bool { + t.Helper() + a := simd.LoadUint32x16Slice(x) + b := simd.LoadUint32x16Slice(y) + g := make([]int32, n) + f(a, b).AsInt32x16().StoreSlice(g) + w := want(x, y) + return checkSlicesLogInput(t, s64(g), w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y) }) + }) +} + // testUint64x8Compare tests the simd comparison method f against the expected behavior generated by want func testUint64x8Compare(t *testing.T, f func(_, _ simd.Uint64x8) simd.Mask64x8, want func(_, _ []uint64) []int64) { n := 8 diff --git a/src/simd/comparemasked_helpers_test.go b/src/simd/comparemasked_helpers_test.go index 5a70f92f26..0baba27e54 100644 --- a/src/simd/comparemasked_helpers_test.go +++ b/src/simd/comparemasked_helpers_test.go @@ -37,20 +37,20 @@ func testInt8x16CompareMasked(t *testing.T, }) } -// testUint8x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testInt16x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testUint8x16CompareMasked(t *testing.T, - f func(_, _ simd.Uint8x16, m simd.Mask8x16) simd.Mask8x16, - want func(_, _ []uint8) []int64) { - n := 16 +func testInt16x8CompareMasked(t *testing.T, + f func(_, _ simd.Int16x8, m simd.Mask16x8) simd.Mask16x8, + want func(_, _ []int16) []int64) { + n := 8 t.Helper() - forSlicePairMasked(t, uint8s, n, func(x, y []uint8, m []bool) bool { + forSlicePairMasked(t, int16s, n, func(x, y []int16, m []bool) bool { t.Helper() - a := simd.LoadUint8x16Slice(x) - b := simd.LoadUint8x16Slice(y) - k := simd.LoadInt8x16Slice(toVect[int8](m)).AsMask8x16() - g := make([]int8, n) - f(a, b, k).AsInt8x16().StoreSlice(g) + a := simd.LoadInt16x8Slice(x) + b := simd.LoadInt16x8Slice(y) + k := simd.LoadInt16x8Slice(toVect[int16](m)).AsMask16x8() + g := make([]int16, n) + f(a, b, k).AsInt16x8().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -61,20 +61,20 @@ func testUint8x16CompareMasked(t *testing.T, }) } -// testInt16x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testInt32x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testInt16x8CompareMasked(t *testing.T, - f func(_, _ simd.Int16x8, m simd.Mask16x8) simd.Mask16x8, - want func(_, _ []int16) []int64) { - n := 8 +func testInt32x4CompareMasked(t *testing.T, + f func(_, _ simd.Int32x4, m simd.Mask32x4) simd.Mask32x4, + want func(_, _ []int32) []int64) { + n := 4 t.Helper() - forSlicePairMasked(t, int16s, n, func(x, y []int16, m []bool) bool { + forSlicePairMasked(t, int32s, n, func(x, y []int32, m []bool) bool { t.Helper() - a := simd.LoadInt16x8Slice(x) - b := simd.LoadInt16x8Slice(y) - k := simd.LoadInt16x8Slice(toVect[int16](m)).AsMask16x8() - g := make([]int16, n) - f(a, b, k).AsInt16x8().StoreSlice(g) + a := simd.LoadInt32x4Slice(x) + b := simd.LoadInt32x4Slice(y) + k := simd.LoadInt32x4Slice(toVect[int32](m)).AsMask32x4() + g := make([]int32, n) + f(a, b, k).AsInt32x4().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -85,20 +85,20 @@ func testInt16x8CompareMasked(t *testing.T, }) } -// testUint16x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testInt64x2CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testUint16x8CompareMasked(t *testing.T, - f func(_, _ simd.Uint16x8, m simd.Mask16x8) simd.Mask16x8, - want func(_, _ []uint16) []int64) { - n := 8 +func testInt64x2CompareMasked(t *testing.T, + f func(_, _ simd.Int64x2, m simd.Mask64x2) simd.Mask64x2, + want func(_, _ []int64) []int64) { + n := 2 t.Helper() - forSlicePairMasked(t, uint16s, n, func(x, y []uint16, m []bool) bool { + forSlicePairMasked(t, int64s, n, func(x, y []int64, m []bool) bool { t.Helper() - a := simd.LoadUint16x8Slice(x) - b := simd.LoadUint16x8Slice(y) - k := simd.LoadInt16x8Slice(toVect[int16](m)).AsMask16x8() - g := make([]int16, n) - f(a, b, k).AsInt16x8().StoreSlice(g) + a := simd.LoadInt64x2Slice(x) + b := simd.LoadInt64x2Slice(y) + k := simd.LoadInt64x2Slice(toVect[int64](m)).AsMask64x2() + g := make([]int64, n) + f(a, b, k).AsInt64x2().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -109,20 +109,20 @@ func testUint16x8CompareMasked(t *testing.T, }) } -// testInt32x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testUint8x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testInt32x4CompareMasked(t *testing.T, - f func(_, _ simd.Int32x4, m simd.Mask32x4) simd.Mask32x4, - want func(_, _ []int32) []int64) { - n := 4 +func testUint8x16CompareMasked(t *testing.T, + f func(_, _ simd.Uint8x16, m simd.Mask8x16) simd.Mask8x16, + want func(_, _ []uint8) []int64) { + n := 16 t.Helper() - forSlicePairMasked(t, int32s, n, func(x, y []int32, m []bool) bool { + forSlicePairMasked(t, uint8s, n, func(x, y []uint8, m []bool) bool { t.Helper() - a := simd.LoadInt32x4Slice(x) - b := simd.LoadInt32x4Slice(y) - k := simd.LoadInt32x4Slice(toVect[int32](m)).AsMask32x4() - g := make([]int32, n) - f(a, b, k).AsInt32x4().StoreSlice(g) + a := simd.LoadUint8x16Slice(x) + b := simd.LoadUint8x16Slice(y) + k := simd.LoadInt8x16Slice(toVect[int8](m)).AsMask8x16() + g := make([]int8, n) + f(a, b, k).AsInt8x16().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -133,20 +133,20 @@ func testInt32x4CompareMasked(t *testing.T, }) } -// testUint32x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testUint16x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testUint32x4CompareMasked(t *testing.T, - f func(_, _ simd.Uint32x4, m simd.Mask32x4) simd.Mask32x4, - want func(_, _ []uint32) []int64) { - n := 4 +func testUint16x8CompareMasked(t *testing.T, + f func(_, _ simd.Uint16x8, m simd.Mask16x8) simd.Mask16x8, + want func(_, _ []uint16) []int64) { + n := 8 t.Helper() - forSlicePairMasked(t, uint32s, n, func(x, y []uint32, m []bool) bool { + forSlicePairMasked(t, uint16s, n, func(x, y []uint16, m []bool) bool { t.Helper() - a := simd.LoadUint32x4Slice(x) - b := simd.LoadUint32x4Slice(y) - k := simd.LoadInt32x4Slice(toVect[int32](m)).AsMask32x4() - g := make([]int32, n) - f(a, b, k).AsInt32x4().StoreSlice(g) + a := simd.LoadUint16x8Slice(x) + b := simd.LoadUint16x8Slice(y) + k := simd.LoadInt16x8Slice(toVect[int16](m)).AsMask16x8() + g := make([]int16, n) + f(a, b, k).AsInt16x8().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -157,20 +157,20 @@ func testUint32x4CompareMasked(t *testing.T, }) } -// testInt64x2CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testUint32x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testInt64x2CompareMasked(t *testing.T, - f func(_, _ simd.Int64x2, m simd.Mask64x2) simd.Mask64x2, - want func(_, _ []int64) []int64) { - n := 2 +func testUint32x4CompareMasked(t *testing.T, + f func(_, _ simd.Uint32x4, m simd.Mask32x4) simd.Mask32x4, + want func(_, _ []uint32) []int64) { + n := 4 t.Helper() - forSlicePairMasked(t, int64s, n, func(x, y []int64, m []bool) bool { + forSlicePairMasked(t, uint32s, n, func(x, y []uint32, m []bool) bool { t.Helper() - a := simd.LoadInt64x2Slice(x) - b := simd.LoadInt64x2Slice(y) - k := simd.LoadInt64x2Slice(toVect[int64](m)).AsMask64x2() - g := make([]int64, n) - f(a, b, k).AsInt64x2().StoreSlice(g) + a := simd.LoadUint32x4Slice(x) + b := simd.LoadUint32x4Slice(y) + k := simd.LoadInt32x4Slice(toVect[int32](m)).AsMask32x4() + g := make([]int32, n) + f(a, b, k).AsInt32x4().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -277,20 +277,20 @@ func testInt8x32CompareMasked(t *testing.T, }) } -// testUint8x32CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testInt16x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testUint8x32CompareMasked(t *testing.T, - f func(_, _ simd.Uint8x32, m simd.Mask8x32) simd.Mask8x32, - want func(_, _ []uint8) []int64) { - n := 32 +func testInt16x16CompareMasked(t *testing.T, + f func(_, _ simd.Int16x16, m simd.Mask16x16) simd.Mask16x16, + want func(_, _ []int16) []int64) { + n := 16 t.Helper() - forSlicePairMasked(t, uint8s, n, func(x, y []uint8, m []bool) bool { + forSlicePairMasked(t, int16s, n, func(x, y []int16, m []bool) bool { t.Helper() - a := simd.LoadUint8x32Slice(x) - b := simd.LoadUint8x32Slice(y) - k := simd.LoadInt8x32Slice(toVect[int8](m)).AsMask8x32() - g := make([]int8, n) - f(a, b, k).AsInt8x32().StoreSlice(g) + a := simd.LoadInt16x16Slice(x) + b := simd.LoadInt16x16Slice(y) + k := simd.LoadInt16x16Slice(toVect[int16](m)).AsMask16x16() + g := make([]int16, n) + f(a, b, k).AsInt16x16().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -301,20 +301,20 @@ func testUint8x32CompareMasked(t *testing.T, }) } -// testInt16x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testInt32x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testInt16x16CompareMasked(t *testing.T, - f func(_, _ simd.Int16x16, m simd.Mask16x16) simd.Mask16x16, - want func(_, _ []int16) []int64) { - n := 16 +func testInt32x8CompareMasked(t *testing.T, + f func(_, _ simd.Int32x8, m simd.Mask32x8) simd.Mask32x8, + want func(_, _ []int32) []int64) { + n := 8 t.Helper() - forSlicePairMasked(t, int16s, n, func(x, y []int16, m []bool) bool { + forSlicePairMasked(t, int32s, n, func(x, y []int32, m []bool) bool { t.Helper() - a := simd.LoadInt16x16Slice(x) - b := simd.LoadInt16x16Slice(y) - k := simd.LoadInt16x16Slice(toVect[int16](m)).AsMask16x16() - g := make([]int16, n) - f(a, b, k).AsInt16x16().StoreSlice(g) + a := simd.LoadInt32x8Slice(x) + b := simd.LoadInt32x8Slice(y) + k := simd.LoadInt32x8Slice(toVect[int32](m)).AsMask32x8() + g := make([]int32, n) + f(a, b, k).AsInt32x8().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -325,20 +325,20 @@ func testInt16x16CompareMasked(t *testing.T, }) } -// testUint16x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testInt64x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testUint16x16CompareMasked(t *testing.T, - f func(_, _ simd.Uint16x16, m simd.Mask16x16) simd.Mask16x16, - want func(_, _ []uint16) []int64) { - n := 16 +func testInt64x4CompareMasked(t *testing.T, + f func(_, _ simd.Int64x4, m simd.Mask64x4) simd.Mask64x4, + want func(_, _ []int64) []int64) { + n := 4 t.Helper() - forSlicePairMasked(t, uint16s, n, func(x, y []uint16, m []bool) bool { + forSlicePairMasked(t, int64s, n, func(x, y []int64, m []bool) bool { t.Helper() - a := simd.LoadUint16x16Slice(x) - b := simd.LoadUint16x16Slice(y) - k := simd.LoadInt16x16Slice(toVect[int16](m)).AsMask16x16() - g := make([]int16, n) - f(a, b, k).AsInt16x16().StoreSlice(g) + a := simd.LoadInt64x4Slice(x) + b := simd.LoadInt64x4Slice(y) + k := simd.LoadInt64x4Slice(toVect[int64](m)).AsMask64x4() + g := make([]int64, n) + f(a, b, k).AsInt64x4().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -349,20 +349,20 @@ func testUint16x16CompareMasked(t *testing.T, }) } -// testInt32x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testUint8x32CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testInt32x8CompareMasked(t *testing.T, - f func(_, _ simd.Int32x8, m simd.Mask32x8) simd.Mask32x8, - want func(_, _ []int32) []int64) { - n := 8 +func testUint8x32CompareMasked(t *testing.T, + f func(_, _ simd.Uint8x32, m simd.Mask8x32) simd.Mask8x32, + want func(_, _ []uint8) []int64) { + n := 32 t.Helper() - forSlicePairMasked(t, int32s, n, func(x, y []int32, m []bool) bool { + forSlicePairMasked(t, uint8s, n, func(x, y []uint8, m []bool) bool { t.Helper() - a := simd.LoadInt32x8Slice(x) - b := simd.LoadInt32x8Slice(y) - k := simd.LoadInt32x8Slice(toVect[int32](m)).AsMask32x8() - g := make([]int32, n) - f(a, b, k).AsInt32x8().StoreSlice(g) + a := simd.LoadUint8x32Slice(x) + b := simd.LoadUint8x32Slice(y) + k := simd.LoadInt8x32Slice(toVect[int8](m)).AsMask8x32() + g := make([]int8, n) + f(a, b, k).AsInt8x32().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -373,20 +373,20 @@ func testInt32x8CompareMasked(t *testing.T, }) } -// testUint32x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testUint16x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testUint32x8CompareMasked(t *testing.T, - f func(_, _ simd.Uint32x8, m simd.Mask32x8) simd.Mask32x8, - want func(_, _ []uint32) []int64) { - n := 8 +func testUint16x16CompareMasked(t *testing.T, + f func(_, _ simd.Uint16x16, m simd.Mask16x16) simd.Mask16x16, + want func(_, _ []uint16) []int64) { + n := 16 t.Helper() - forSlicePairMasked(t, uint32s, n, func(x, y []uint32, m []bool) bool { + forSlicePairMasked(t, uint16s, n, func(x, y []uint16, m []bool) bool { t.Helper() - a := simd.LoadUint32x8Slice(x) - b := simd.LoadUint32x8Slice(y) - k := simd.LoadInt32x8Slice(toVect[int32](m)).AsMask32x8() - g := make([]int32, n) - f(a, b, k).AsInt32x8().StoreSlice(g) + a := simd.LoadUint16x16Slice(x) + b := simd.LoadUint16x16Slice(y) + k := simd.LoadInt16x16Slice(toVect[int16](m)).AsMask16x16() + g := make([]int16, n) + f(a, b, k).AsInt16x16().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -397,20 +397,20 @@ func testUint32x8CompareMasked(t *testing.T, }) } -// testInt64x4CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testUint32x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testInt64x4CompareMasked(t *testing.T, - f func(_, _ simd.Int64x4, m simd.Mask64x4) simd.Mask64x4, - want func(_, _ []int64) []int64) { - n := 4 +func testUint32x8CompareMasked(t *testing.T, + f func(_, _ simd.Uint32x8, m simd.Mask32x8) simd.Mask32x8, + want func(_, _ []uint32) []int64) { + n := 8 t.Helper() - forSlicePairMasked(t, int64s, n, func(x, y []int64, m []bool) bool { + forSlicePairMasked(t, uint32s, n, func(x, y []uint32, m []bool) bool { t.Helper() - a := simd.LoadInt64x4Slice(x) - b := simd.LoadInt64x4Slice(y) - k := simd.LoadInt64x4Slice(toVect[int64](m)).AsMask64x4() - g := make([]int64, n) - f(a, b, k).AsInt64x4().StoreSlice(g) + a := simd.LoadUint32x8Slice(x) + b := simd.LoadUint32x8Slice(y) + k := simd.LoadInt32x8Slice(toVect[int32](m)).AsMask32x8() + g := make([]int32, n) + f(a, b, k).AsInt32x8().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -517,20 +517,20 @@ func testInt8x64CompareMasked(t *testing.T, }) } -// testUint8x64CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testInt16x32CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testUint8x64CompareMasked(t *testing.T, - f func(_, _ simd.Uint8x64, m simd.Mask8x64) simd.Mask8x64, - want func(_, _ []uint8) []int64) { - n := 64 +func testInt16x32CompareMasked(t *testing.T, + f func(_, _ simd.Int16x32, m simd.Mask16x32) simd.Mask16x32, + want func(_, _ []int16) []int64) { + n := 32 t.Helper() - forSlicePairMasked(t, uint8s, n, func(x, y []uint8, m []bool) bool { + forSlicePairMasked(t, int16s, n, func(x, y []int16, m []bool) bool { t.Helper() - a := simd.LoadUint8x64Slice(x) - b := simd.LoadUint8x64Slice(y) - k := simd.LoadInt8x64Slice(toVect[int8](m)).AsMask8x64() - g := make([]int8, n) - f(a, b, k).AsInt8x64().StoreSlice(g) + a := simd.LoadInt16x32Slice(x) + b := simd.LoadInt16x32Slice(y) + k := simd.LoadInt16x32Slice(toVect[int16](m)).AsMask16x32() + g := make([]int16, n) + f(a, b, k).AsInt16x32().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -541,20 +541,20 @@ func testUint8x64CompareMasked(t *testing.T, }) } -// testInt16x32CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testInt32x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testInt16x32CompareMasked(t *testing.T, - f func(_, _ simd.Int16x32, m simd.Mask16x32) simd.Mask16x32, - want func(_, _ []int16) []int64) { - n := 32 +func testInt32x16CompareMasked(t *testing.T, + f func(_, _ simd.Int32x16, m simd.Mask32x16) simd.Mask32x16, + want func(_, _ []int32) []int64) { + n := 16 t.Helper() - forSlicePairMasked(t, int16s, n, func(x, y []int16, m []bool) bool { + forSlicePairMasked(t, int32s, n, func(x, y []int32, m []bool) bool { t.Helper() - a := simd.LoadInt16x32Slice(x) - b := simd.LoadInt16x32Slice(y) - k := simd.LoadInt16x32Slice(toVect[int16](m)).AsMask16x32() - g := make([]int16, n) - f(a, b, k).AsInt16x32().StoreSlice(g) + a := simd.LoadInt32x16Slice(x) + b := simd.LoadInt32x16Slice(y) + k := simd.LoadInt32x16Slice(toVect[int32](m)).AsMask32x16() + g := make([]int32, n) + f(a, b, k).AsInt32x16().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -565,20 +565,20 @@ func testInt16x32CompareMasked(t *testing.T, }) } -// testUint16x32CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testInt64x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testUint16x32CompareMasked(t *testing.T, - f func(_, _ simd.Uint16x32, m simd.Mask16x32) simd.Mask16x32, - want func(_, _ []uint16) []int64) { - n := 32 +func testInt64x8CompareMasked(t *testing.T, + f func(_, _ simd.Int64x8, m simd.Mask64x8) simd.Mask64x8, + want func(_, _ []int64) []int64) { + n := 8 t.Helper() - forSlicePairMasked(t, uint16s, n, func(x, y []uint16, m []bool) bool { + forSlicePairMasked(t, int64s, n, func(x, y []int64, m []bool) bool { t.Helper() - a := simd.LoadUint16x32Slice(x) - b := simd.LoadUint16x32Slice(y) - k := simd.LoadInt16x32Slice(toVect[int16](m)).AsMask16x32() - g := make([]int16, n) - f(a, b, k).AsInt16x32().StoreSlice(g) + a := simd.LoadInt64x8Slice(x) + b := simd.LoadInt64x8Slice(y) + k := simd.LoadInt64x8Slice(toVect[int64](m)).AsMask64x8() + g := make([]int64, n) + f(a, b, k).AsInt64x8().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -589,20 +589,20 @@ func testUint16x32CompareMasked(t *testing.T, }) } -// testInt32x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testUint8x64CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testInt32x16CompareMasked(t *testing.T, - f func(_, _ simd.Int32x16, m simd.Mask32x16) simd.Mask32x16, - want func(_, _ []int32) []int64) { - n := 16 +func testUint8x64CompareMasked(t *testing.T, + f func(_, _ simd.Uint8x64, m simd.Mask8x64) simd.Mask8x64, + want func(_, _ []uint8) []int64) { + n := 64 t.Helper() - forSlicePairMasked(t, int32s, n, func(x, y []int32, m []bool) bool { + forSlicePairMasked(t, uint8s, n, func(x, y []uint8, m []bool) bool { t.Helper() - a := simd.LoadInt32x16Slice(x) - b := simd.LoadInt32x16Slice(y) - k := simd.LoadInt32x16Slice(toVect[int32](m)).AsMask32x16() - g := make([]int32, n) - f(a, b, k).AsInt32x16().StoreSlice(g) + a := simd.LoadUint8x64Slice(x) + b := simd.LoadUint8x64Slice(y) + k := simd.LoadInt8x64Slice(toVect[int8](m)).AsMask8x64() + g := make([]int8, n) + f(a, b, k).AsInt8x64().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -613,20 +613,20 @@ func testInt32x16CompareMasked(t *testing.T, }) } -// testUint32x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testUint16x32CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testUint32x16CompareMasked(t *testing.T, - f func(_, _ simd.Uint32x16, m simd.Mask32x16) simd.Mask32x16, - want func(_, _ []uint32) []int64) { - n := 16 +func testUint16x32CompareMasked(t *testing.T, + f func(_, _ simd.Uint16x32, m simd.Mask16x32) simd.Mask16x32, + want func(_, _ []uint16) []int64) { + n := 32 t.Helper() - forSlicePairMasked(t, uint32s, n, func(x, y []uint32, m []bool) bool { + forSlicePairMasked(t, uint16s, n, func(x, y []uint16, m []bool) bool { t.Helper() - a := simd.LoadUint32x16Slice(x) - b := simd.LoadUint32x16Slice(y) - k := simd.LoadInt32x16Slice(toVect[int32](m)).AsMask32x16() - g := make([]int32, n) - f(a, b, k).AsInt32x16().StoreSlice(g) + a := simd.LoadUint16x32Slice(x) + b := simd.LoadUint16x32Slice(y) + k := simd.LoadInt16x32Slice(toVect[int16](m)).AsMask16x32() + g := make([]int16, n) + f(a, b, k).AsInt16x32().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { @@ -637,20 +637,20 @@ func testUint32x16CompareMasked(t *testing.T, }) } -// testInt64x8CompareMasked tests the simd masked comparison method f against the expected behavior generated by want +// testUint32x16CompareMasked tests the simd masked comparison method f against the expected behavior generated by want // The mask is applied to the output of want; anything not in the mask, is zeroed. -func testInt64x8CompareMasked(t *testing.T, - f func(_, _ simd.Int64x8, m simd.Mask64x8) simd.Mask64x8, - want func(_, _ []int64) []int64) { - n := 8 +func testUint32x16CompareMasked(t *testing.T, + f func(_, _ simd.Uint32x16, m simd.Mask32x16) simd.Mask32x16, + want func(_, _ []uint32) []int64) { + n := 16 t.Helper() - forSlicePairMasked(t, int64s, n, func(x, y []int64, m []bool) bool { + forSlicePairMasked(t, uint32s, n, func(x, y []uint32, m []bool) bool { t.Helper() - a := simd.LoadInt64x8Slice(x) - b := simd.LoadInt64x8Slice(y) - k := simd.LoadInt64x8Slice(toVect[int64](m)).AsMask64x8() - g := make([]int64, n) - f(a, b, k).AsInt64x8().StoreSlice(g) + a := simd.LoadUint32x16Slice(x) + b := simd.LoadUint32x16Slice(y) + k := simd.LoadInt32x16Slice(toVect[int32](m)).AsMask32x16() + g := make([]int32, n) + f(a, b, k).AsInt32x16().StoreSlice(g) w := want(x, y) for i := range m { if !m[i] { diff --git a/src/simd/genfiles.go b/src/simd/genfiles.go index 8dac158fe4..7106db2d31 100644 --- a/src/simd/genfiles.go +++ b/src/simd/genfiles.go @@ -20,6 +20,34 @@ import ( "text/template" ) +// shapes describes a combination of vector widths and various element types +type shapes struct { + vecs []int // Vector bit width for this shape. + ints []int // Int element bit width(s) for this shape + uints []int // Unsigned int element bit width(s) for this shape + floats []int // Float element bit width(s) for this shape +} + +// shapeAndTemplate is a template and the set of shapes on which it will be expanded +type shapeAndTemplate struct { + s *shapes + t *template.Template +} + +var allShapes = &shapes{ + vecs: []int{128, 256, 512}, + ints: []int{8, 16, 32, 64}, + uints: []int{8, 16, 32, 64}, + floats: []int{32, 64}, +} + +// these are the shapes that are currently converted to int32 +// (not all conversions are available, yet) +var toInt32Shapes = &shapes{ + vecs: []int{128, 256, 512}, + floats: []int{32}, +} + func oneTemplate(t *template.Template, baseType string, width, count int, out io.Writer) { b := width * count if b < 128 || b > 512 { @@ -34,12 +62,12 @@ func oneTemplate(t *template.Template, baseType string, width, count int, out io aOrAn = "an" } t.Execute(out, struct { - Vec string - AOrAn string - Width int - Count int - WxC string - Type string + Vec string // the type of the vector, e.g. Float32x4 + AOrAn string // for documentation, the article "a" or "an" + Width int // the bit width of the element type, e.g. 32 + Count int // the number of elements, e.g. 4 + WxC string // the width-by-type string, e.g., "32x4" + Type string // the element type, e.g. "float32" }{ Vec: vType, AOrAn: aOrAn, @@ -50,14 +78,21 @@ func oneTemplate(t *template.Template, baseType string, width, count int, out io }) } -func forTemplates(t *template.Template, out io.Writer) { - vecs := []int{128, 256, 512} - ints := []int{8, 16, 32, 64} - floats := []int{32, 64} +// forTemplates expands the template sat.t for each shape +// in sat.s, writing to out. +func (sat shapeAndTemplate) forTemplates(out io.Writer) { + t, s := sat.t, sat.s + vecs := s.vecs + ints := s.ints + uints := s.uints + floats := s.floats for _, v := range vecs { for _, w := range ints { c := v / w oneTemplate(t, "int", w, c, out) + } + for _, w := range uints { + c := v / w oneTemplate(t, "uint", w, c, out) } for _, w := range floats { @@ -114,8 +149,14 @@ func curryTestPrologue(t string) func(s string, out io.Writer) { // x.Store((*[16]uint8)(s[:16])) // } -func templateOf(name, temp string) *template.Template { - return template.Must(template.New(name).Parse(temp)) +func templateOf(name, temp string) shapeAndTemplate { + return shapeAndTemplate{s: allShapes, + t: template.Must(template.New(name).Parse(temp))} +} + +func shapedTemplateOf(s *shapes, name, temp string) shapeAndTemplate { + return shapeAndTemplate{s: s, + t: template.Must(template.New(name).Parse(temp))} } var sliceTemplate = templateOf("slice", ` @@ -146,6 +187,22 @@ func test{{.Vec}}Unary(t *testing.T, f func(_ simd.{{.Vec}}) simd.{{.Vec}}, want } `) +var unaryTemplateToInt32 = shapedTemplateOf(toInt32Shapes, "unary_int32_helpers", ` +// test{{.Vec}}Unary tests the simd unary method f against the expected behavior generated by want +func test{{.Vec}}UnaryToInt32(t *testing.T, f func(x simd.{{.Vec}}) simd.Int32x{{.Count}}, want func(x []{{.Type}}) []int32) { + n := {{.Count}} + t.Helper() + forSlice(t, {{.Type}}s, n, func(x []{{.Type}}) bool { + t.Helper() + a := simd.Load{{.Vec}}Slice(x) + g := make([]int32, n) + f(a).StoreSlice(g) + w := want(x) + return checkSlicesLogInput(t, g, w, func() {t.Helper(); t.Logf("x=%v", x)}) + }) +} +`) + var binaryTemplate = templateOf("binary_helpers", ` // test{{.Vec}}Binary tests the simd binary method f against the expected behavior generated by want func test{{.Vec}}Binary(t *testing.T, f func(_, _ simd.{{.Vec}}) simd.{{.Vec}}, want func(_, _ []{{.Type}}) []{{.Type}}) { @@ -254,7 +311,7 @@ func main() { } } -func one(filename string, prologue func(s string, out io.Writer), t *template.Template) { +func one(filename string, prologue func(s string, out io.Writer), sats ...shapeAndTemplate) { if filename == "" { return } @@ -273,7 +330,9 @@ func one(filename string, prologue func(s string, out io.Writer), t *template.Te out := new(bytes.Buffer) prologue("go run genfiles.go", out) - forTemplates(t, out) + for _, sat := range sats { + sat.forTemplates(out) + } b, err := format.Source(out.Bytes()) if err != nil { diff --git a/src/simd/slice_amd64.go b/src/simd/slice_amd64.go index 62564e44a2..ad7bce8964 100644 --- a/src/simd/slice_amd64.go +++ b/src/simd/slice_amd64.go @@ -14,16 +14,6 @@ func (x Int8x16) StoreSlice(s []int8) { x.Store((*[16]int8)(s)) } -// LoadUint8x16Slice loads an Uint8x16 from a slice of at least 16 uint8s -func LoadUint8x16Slice(s []uint8) Uint8x16 { - return LoadUint8x16((*[16]uint8)(s)) -} - -// StoreSlice stores x into a slice of at least 16 uint8s -func (x Uint8x16) StoreSlice(s []uint8) { - x.Store((*[16]uint8)(s)) -} - // LoadInt16x8Slice loads an Int16x8 from a slice of at least 8 int16s func LoadInt16x8Slice(s []int16) Int16x8 { return LoadInt16x8((*[8]int16)(s)) @@ -34,16 +24,6 @@ func (x Int16x8) StoreSlice(s []int16) { x.Store((*[8]int16)(s)) } -// LoadUint16x8Slice loads an Uint16x8 from a slice of at least 8 uint16s -func LoadUint16x8Slice(s []uint16) Uint16x8 { - return LoadUint16x8((*[8]uint16)(s)) -} - -// StoreSlice stores x into a slice of at least 8 uint16s -func (x Uint16x8) StoreSlice(s []uint16) { - x.Store((*[8]uint16)(s)) -} - // LoadInt32x4Slice loads an Int32x4 from a slice of at least 4 int32s func LoadInt32x4Slice(s []int32) Int32x4 { return LoadInt32x4((*[4]int32)(s)) @@ -54,16 +34,6 @@ func (x Int32x4) StoreSlice(s []int32) { x.Store((*[4]int32)(s)) } -// LoadUint32x4Slice loads an Uint32x4 from a slice of at least 4 uint32s -func LoadUint32x4Slice(s []uint32) Uint32x4 { - return LoadUint32x4((*[4]uint32)(s)) -} - -// StoreSlice stores x into a slice of at least 4 uint32s -func (x Uint32x4) StoreSlice(s []uint32) { - x.Store((*[4]uint32)(s)) -} - // LoadInt64x2Slice loads an Int64x2 from a slice of at least 2 int64s func LoadInt64x2Slice(s []int64) Int64x2 { return LoadInt64x2((*[2]int64)(s)) @@ -74,6 +44,36 @@ func (x Int64x2) StoreSlice(s []int64) { x.Store((*[2]int64)(s)) } +// LoadUint8x16Slice loads an Uint8x16 from a slice of at least 16 uint8s +func LoadUint8x16Slice(s []uint8) Uint8x16 { + return LoadUint8x16((*[16]uint8)(s)) +} + +// StoreSlice stores x into a slice of at least 16 uint8s +func (x Uint8x16) StoreSlice(s []uint8) { + x.Store((*[16]uint8)(s)) +} + +// LoadUint16x8Slice loads an Uint16x8 from a slice of at least 8 uint16s +func LoadUint16x8Slice(s []uint16) Uint16x8 { + return LoadUint16x8((*[8]uint16)(s)) +} + +// StoreSlice stores x into a slice of at least 8 uint16s +func (x Uint16x8) StoreSlice(s []uint16) { + x.Store((*[8]uint16)(s)) +} + +// LoadUint32x4Slice loads an Uint32x4 from a slice of at least 4 uint32s +func LoadUint32x4Slice(s []uint32) Uint32x4 { + return LoadUint32x4((*[4]uint32)(s)) +} + +// StoreSlice stores x into a slice of at least 4 uint32s +func (x Uint32x4) StoreSlice(s []uint32) { + x.Store((*[4]uint32)(s)) +} + // LoadUint64x2Slice loads an Uint64x2 from a slice of at least 2 uint64s func LoadUint64x2Slice(s []uint64) Uint64x2 { return LoadUint64x2((*[2]uint64)(s)) @@ -114,16 +114,6 @@ func (x Int8x32) StoreSlice(s []int8) { x.Store((*[32]int8)(s)) } -// LoadUint8x32Slice loads an Uint8x32 from a slice of at least 32 uint8s -func LoadUint8x32Slice(s []uint8) Uint8x32 { - return LoadUint8x32((*[32]uint8)(s)) -} - -// StoreSlice stores x into a slice of at least 32 uint8s -func (x Uint8x32) StoreSlice(s []uint8) { - x.Store((*[32]uint8)(s)) -} - // LoadInt16x16Slice loads an Int16x16 from a slice of at least 16 int16s func LoadInt16x16Slice(s []int16) Int16x16 { return LoadInt16x16((*[16]int16)(s)) @@ -134,16 +124,6 @@ func (x Int16x16) StoreSlice(s []int16) { x.Store((*[16]int16)(s)) } -// LoadUint16x16Slice loads an Uint16x16 from a slice of at least 16 uint16s -func LoadUint16x16Slice(s []uint16) Uint16x16 { - return LoadUint16x16((*[16]uint16)(s)) -} - -// StoreSlice stores x into a slice of at least 16 uint16s -func (x Uint16x16) StoreSlice(s []uint16) { - x.Store((*[16]uint16)(s)) -} - // LoadInt32x8Slice loads an Int32x8 from a slice of at least 8 int32s func LoadInt32x8Slice(s []int32) Int32x8 { return LoadInt32x8((*[8]int32)(s)) @@ -154,16 +134,6 @@ func (x Int32x8) StoreSlice(s []int32) { x.Store((*[8]int32)(s)) } -// LoadUint32x8Slice loads an Uint32x8 from a slice of at least 8 uint32s -func LoadUint32x8Slice(s []uint32) Uint32x8 { - return LoadUint32x8((*[8]uint32)(s)) -} - -// StoreSlice stores x into a slice of at least 8 uint32s -func (x Uint32x8) StoreSlice(s []uint32) { - x.Store((*[8]uint32)(s)) -} - // LoadInt64x4Slice loads an Int64x4 from a slice of at least 4 int64s func LoadInt64x4Slice(s []int64) Int64x4 { return LoadInt64x4((*[4]int64)(s)) @@ -174,6 +144,36 @@ func (x Int64x4) StoreSlice(s []int64) { x.Store((*[4]int64)(s)) } +// LoadUint8x32Slice loads an Uint8x32 from a slice of at least 32 uint8s +func LoadUint8x32Slice(s []uint8) Uint8x32 { + return LoadUint8x32((*[32]uint8)(s)) +} + +// StoreSlice stores x into a slice of at least 32 uint8s +func (x Uint8x32) StoreSlice(s []uint8) { + x.Store((*[32]uint8)(s)) +} + +// LoadUint16x16Slice loads an Uint16x16 from a slice of at least 16 uint16s +func LoadUint16x16Slice(s []uint16) Uint16x16 { + return LoadUint16x16((*[16]uint16)(s)) +} + +// StoreSlice stores x into a slice of at least 16 uint16s +func (x Uint16x16) StoreSlice(s []uint16) { + x.Store((*[16]uint16)(s)) +} + +// LoadUint32x8Slice loads an Uint32x8 from a slice of at least 8 uint32s +func LoadUint32x8Slice(s []uint32) Uint32x8 { + return LoadUint32x8((*[8]uint32)(s)) +} + +// StoreSlice stores x into a slice of at least 8 uint32s +func (x Uint32x8) StoreSlice(s []uint32) { + x.Store((*[8]uint32)(s)) +} + // LoadUint64x4Slice loads an Uint64x4 from a slice of at least 4 uint64s func LoadUint64x4Slice(s []uint64) Uint64x4 { return LoadUint64x4((*[4]uint64)(s)) @@ -214,16 +214,6 @@ func (x Int8x64) StoreSlice(s []int8) { x.Store((*[64]int8)(s)) } -// LoadUint8x64Slice loads an Uint8x64 from a slice of at least 64 uint8s -func LoadUint8x64Slice(s []uint8) Uint8x64 { - return LoadUint8x64((*[64]uint8)(s)) -} - -// StoreSlice stores x into a slice of at least 64 uint8s -func (x Uint8x64) StoreSlice(s []uint8) { - x.Store((*[64]uint8)(s)) -} - // LoadInt16x32Slice loads an Int16x32 from a slice of at least 32 int16s func LoadInt16x32Slice(s []int16) Int16x32 { return LoadInt16x32((*[32]int16)(s)) @@ -234,16 +224,6 @@ func (x Int16x32) StoreSlice(s []int16) { x.Store((*[32]int16)(s)) } -// LoadUint16x32Slice loads an Uint16x32 from a slice of at least 32 uint16s -func LoadUint16x32Slice(s []uint16) Uint16x32 { - return LoadUint16x32((*[32]uint16)(s)) -} - -// StoreSlice stores x into a slice of at least 32 uint16s -func (x Uint16x32) StoreSlice(s []uint16) { - x.Store((*[32]uint16)(s)) -} - // LoadInt32x16Slice loads an Int32x16 from a slice of at least 16 int32s func LoadInt32x16Slice(s []int32) Int32x16 { return LoadInt32x16((*[16]int32)(s)) @@ -254,16 +234,6 @@ func (x Int32x16) StoreSlice(s []int32) { x.Store((*[16]int32)(s)) } -// LoadUint32x16Slice loads an Uint32x16 from a slice of at least 16 uint32s -func LoadUint32x16Slice(s []uint32) Uint32x16 { - return LoadUint32x16((*[16]uint32)(s)) -} - -// StoreSlice stores x into a slice of at least 16 uint32s -func (x Uint32x16) StoreSlice(s []uint32) { - x.Store((*[16]uint32)(s)) -} - // LoadInt64x8Slice loads an Int64x8 from a slice of at least 8 int64s func LoadInt64x8Slice(s []int64) Int64x8 { return LoadInt64x8((*[8]int64)(s)) @@ -274,6 +244,36 @@ func (x Int64x8) StoreSlice(s []int64) { x.Store((*[8]int64)(s)) } +// LoadUint8x64Slice loads an Uint8x64 from a slice of at least 64 uint8s +func LoadUint8x64Slice(s []uint8) Uint8x64 { + return LoadUint8x64((*[64]uint8)(s)) +} + +// StoreSlice stores x into a slice of at least 64 uint8s +func (x Uint8x64) StoreSlice(s []uint8) { + x.Store((*[64]uint8)(s)) +} + +// LoadUint16x32Slice loads an Uint16x32 from a slice of at least 32 uint16s +func LoadUint16x32Slice(s []uint16) Uint16x32 { + return LoadUint16x32((*[32]uint16)(s)) +} + +// StoreSlice stores x into a slice of at least 32 uint16s +func (x Uint16x32) StoreSlice(s []uint16) { + x.Store((*[32]uint16)(s)) +} + +// LoadUint32x16Slice loads an Uint32x16 from a slice of at least 16 uint32s +func LoadUint32x16Slice(s []uint32) Uint32x16 { + return LoadUint32x16((*[16]uint32)(s)) +} + +// StoreSlice stores x into a slice of at least 16 uint32s +func (x Uint32x16) StoreSlice(s []uint32) { + x.Store((*[16]uint32)(s)) +} + // LoadUint64x8Slice loads an Uint64x8 from a slice of at least 8 uint64s func LoadUint64x8Slice(s []uint64) Uint64x8 { return LoadUint64x8((*[8]uint64)(s)) diff --git a/src/simd/ternary_helpers_test.go b/src/simd/ternary_helpers_test.go index 5a7503860f..e48ec2409c 100644 --- a/src/simd/ternary_helpers_test.go +++ b/src/simd/ternary_helpers_test.go @@ -29,22 +29,6 @@ func testInt8x16Ternary(t *testing.T, f func(_, _, _ simd.Int8x16) simd.Int8x16, }) } -// testUint8x16Ternary tests the simd ternary method f against the expected behavior generated by want -func testUint8x16Ternary(t *testing.T, f func(_, _, _ simd.Uint8x16) simd.Uint8x16, want func(_, _, _ []uint8) []uint8) { - n := 16 - t.Helper() - forSliceTriple(t, uint8s, n, func(x, y, z []uint8) bool { - t.Helper() - a := simd.LoadUint8x16Slice(x) - b := simd.LoadUint8x16Slice(y) - c := simd.LoadUint8x16Slice(z) - g := make([]uint8, n) - f(a, b, c).StoreSlice(g) - w := want(x, y, z) - return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) - }) -} - // testInt16x8Ternary tests the simd ternary method f against the expected behavior generated by want func testInt16x8Ternary(t *testing.T, f func(_, _, _ simd.Int16x8) simd.Int16x8, want func(_, _, _ []int16) []int16) { n := 8 @@ -61,22 +45,6 @@ func testInt16x8Ternary(t *testing.T, f func(_, _, _ simd.Int16x8) simd.Int16x8, }) } -// testUint16x8Ternary tests the simd ternary method f against the expected behavior generated by want -func testUint16x8Ternary(t *testing.T, f func(_, _, _ simd.Uint16x8) simd.Uint16x8, want func(_, _, _ []uint16) []uint16) { - n := 8 - t.Helper() - forSliceTriple(t, uint16s, n, func(x, y, z []uint16) bool { - t.Helper() - a := simd.LoadUint16x8Slice(x) - b := simd.LoadUint16x8Slice(y) - c := simd.LoadUint16x8Slice(z) - g := make([]uint16, n) - f(a, b, c).StoreSlice(g) - w := want(x, y, z) - return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) - }) -} - // testInt32x4Ternary tests the simd ternary method f against the expected behavior generated by want func testInt32x4Ternary(t *testing.T, f func(_, _, _ simd.Int32x4) simd.Int32x4, want func(_, _, _ []int32) []int32) { n := 4 @@ -93,22 +61,6 @@ func testInt32x4Ternary(t *testing.T, f func(_, _, _ simd.Int32x4) simd.Int32x4, }) } -// testUint32x4Ternary tests the simd ternary method f against the expected behavior generated by want -func testUint32x4Ternary(t *testing.T, f func(_, _, _ simd.Uint32x4) simd.Uint32x4, want func(_, _, _ []uint32) []uint32) { - n := 4 - t.Helper() - forSliceTriple(t, uint32s, n, func(x, y, z []uint32) bool { - t.Helper() - a := simd.LoadUint32x4Slice(x) - b := simd.LoadUint32x4Slice(y) - c := simd.LoadUint32x4Slice(z) - g := make([]uint32, n) - f(a, b, c).StoreSlice(g) - w := want(x, y, z) - return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) - }) -} - // testInt64x2Ternary tests the simd ternary method f against the expected behavior generated by want func testInt64x2Ternary(t *testing.T, f func(_, _, _ simd.Int64x2) simd.Int64x2, want func(_, _, _ []int64) []int64) { n := 2 @@ -125,6 +77,54 @@ func testInt64x2Ternary(t *testing.T, f func(_, _, _ simd.Int64x2) simd.Int64x2, }) } +// testUint8x16Ternary tests the simd ternary method f against the expected behavior generated by want +func testUint8x16Ternary(t *testing.T, f func(_, _, _ simd.Uint8x16) simd.Uint8x16, want func(_, _, _ []uint8) []uint8) { + n := 16 + t.Helper() + forSliceTriple(t, uint8s, n, func(x, y, z []uint8) bool { + t.Helper() + a := simd.LoadUint8x16Slice(x) + b := simd.LoadUint8x16Slice(y) + c := simd.LoadUint8x16Slice(z) + g := make([]uint8, n) + f(a, b, c).StoreSlice(g) + w := want(x, y, z) + return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) + }) +} + +// testUint16x8Ternary tests the simd ternary method f against the expected behavior generated by want +func testUint16x8Ternary(t *testing.T, f func(_, _, _ simd.Uint16x8) simd.Uint16x8, want func(_, _, _ []uint16) []uint16) { + n := 8 + t.Helper() + forSliceTriple(t, uint16s, n, func(x, y, z []uint16) bool { + t.Helper() + a := simd.LoadUint16x8Slice(x) + b := simd.LoadUint16x8Slice(y) + c := simd.LoadUint16x8Slice(z) + g := make([]uint16, n) + f(a, b, c).StoreSlice(g) + w := want(x, y, z) + return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) + }) +} + +// testUint32x4Ternary tests the simd ternary method f against the expected behavior generated by want +func testUint32x4Ternary(t *testing.T, f func(_, _, _ simd.Uint32x4) simd.Uint32x4, want func(_, _, _ []uint32) []uint32) { + n := 4 + t.Helper() + forSliceTriple(t, uint32s, n, func(x, y, z []uint32) bool { + t.Helper() + a := simd.LoadUint32x4Slice(x) + b := simd.LoadUint32x4Slice(y) + c := simd.LoadUint32x4Slice(z) + g := make([]uint32, n) + f(a, b, c).StoreSlice(g) + w := want(x, y, z) + return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) + }) +} + // testUint64x2Ternary tests the simd ternary method f against the expected behavior generated by want func testUint64x2Ternary(t *testing.T, f func(_, _, _ simd.Uint64x2) simd.Uint64x2, want func(_, _, _ []uint64) []uint64) { n := 2 @@ -189,22 +189,6 @@ func testInt8x32Ternary(t *testing.T, f func(_, _, _ simd.Int8x32) simd.Int8x32, }) } -// testUint8x32Ternary tests the simd ternary method f against the expected behavior generated by want -func testUint8x32Ternary(t *testing.T, f func(_, _, _ simd.Uint8x32) simd.Uint8x32, want func(_, _, _ []uint8) []uint8) { - n := 32 - t.Helper() - forSliceTriple(t, uint8s, n, func(x, y, z []uint8) bool { - t.Helper() - a := simd.LoadUint8x32Slice(x) - b := simd.LoadUint8x32Slice(y) - c := simd.LoadUint8x32Slice(z) - g := make([]uint8, n) - f(a, b, c).StoreSlice(g) - w := want(x, y, z) - return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) - }) -} - // testInt16x16Ternary tests the simd ternary method f against the expected behavior generated by want func testInt16x16Ternary(t *testing.T, f func(_, _, _ simd.Int16x16) simd.Int16x16, want func(_, _, _ []int16) []int16) { n := 16 @@ -221,22 +205,6 @@ func testInt16x16Ternary(t *testing.T, f func(_, _, _ simd.Int16x16) simd.Int16x }) } -// testUint16x16Ternary tests the simd ternary method f against the expected behavior generated by want -func testUint16x16Ternary(t *testing.T, f func(_, _, _ simd.Uint16x16) simd.Uint16x16, want func(_, _, _ []uint16) []uint16) { - n := 16 - t.Helper() - forSliceTriple(t, uint16s, n, func(x, y, z []uint16) bool { - t.Helper() - a := simd.LoadUint16x16Slice(x) - b := simd.LoadUint16x16Slice(y) - c := simd.LoadUint16x16Slice(z) - g := make([]uint16, n) - f(a, b, c).StoreSlice(g) - w := want(x, y, z) - return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) - }) -} - // testInt32x8Ternary tests the simd ternary method f against the expected behavior generated by want func testInt32x8Ternary(t *testing.T, f func(_, _, _ simd.Int32x8) simd.Int32x8, want func(_, _, _ []int32) []int32) { n := 8 @@ -253,22 +221,6 @@ func testInt32x8Ternary(t *testing.T, f func(_, _, _ simd.Int32x8) simd.Int32x8, }) } -// testUint32x8Ternary tests the simd ternary method f against the expected behavior generated by want -func testUint32x8Ternary(t *testing.T, f func(_, _, _ simd.Uint32x8) simd.Uint32x8, want func(_, _, _ []uint32) []uint32) { - n := 8 - t.Helper() - forSliceTriple(t, uint32s, n, func(x, y, z []uint32) bool { - t.Helper() - a := simd.LoadUint32x8Slice(x) - b := simd.LoadUint32x8Slice(y) - c := simd.LoadUint32x8Slice(z) - g := make([]uint32, n) - f(a, b, c).StoreSlice(g) - w := want(x, y, z) - return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) - }) -} - // testInt64x4Ternary tests the simd ternary method f against the expected behavior generated by want func testInt64x4Ternary(t *testing.T, f func(_, _, _ simd.Int64x4) simd.Int64x4, want func(_, _, _ []int64) []int64) { n := 4 @@ -285,6 +237,54 @@ func testInt64x4Ternary(t *testing.T, f func(_, _, _ simd.Int64x4) simd.Int64x4, }) } +// testUint8x32Ternary tests the simd ternary method f against the expected behavior generated by want +func testUint8x32Ternary(t *testing.T, f func(_, _, _ simd.Uint8x32) simd.Uint8x32, want func(_, _, _ []uint8) []uint8) { + n := 32 + t.Helper() + forSliceTriple(t, uint8s, n, func(x, y, z []uint8) bool { + t.Helper() + a := simd.LoadUint8x32Slice(x) + b := simd.LoadUint8x32Slice(y) + c := simd.LoadUint8x32Slice(z) + g := make([]uint8, n) + f(a, b, c).StoreSlice(g) + w := want(x, y, z) + return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) + }) +} + +// testUint16x16Ternary tests the simd ternary method f against the expected behavior generated by want +func testUint16x16Ternary(t *testing.T, f func(_, _, _ simd.Uint16x16) simd.Uint16x16, want func(_, _, _ []uint16) []uint16) { + n := 16 + t.Helper() + forSliceTriple(t, uint16s, n, func(x, y, z []uint16) bool { + t.Helper() + a := simd.LoadUint16x16Slice(x) + b := simd.LoadUint16x16Slice(y) + c := simd.LoadUint16x16Slice(z) + g := make([]uint16, n) + f(a, b, c).StoreSlice(g) + w := want(x, y, z) + return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) + }) +} + +// testUint32x8Ternary tests the simd ternary method f against the expected behavior generated by want +func testUint32x8Ternary(t *testing.T, f func(_, _, _ simd.Uint32x8) simd.Uint32x8, want func(_, _, _ []uint32) []uint32) { + n := 8 + t.Helper() + forSliceTriple(t, uint32s, n, func(x, y, z []uint32) bool { + t.Helper() + a := simd.LoadUint32x8Slice(x) + b := simd.LoadUint32x8Slice(y) + c := simd.LoadUint32x8Slice(z) + g := make([]uint32, n) + f(a, b, c).StoreSlice(g) + w := want(x, y, z) + return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) + }) +} + // testUint64x4Ternary tests the simd ternary method f against the expected behavior generated by want func testUint64x4Ternary(t *testing.T, f func(_, _, _ simd.Uint64x4) simd.Uint64x4, want func(_, _, _ []uint64) []uint64) { n := 4 @@ -349,22 +349,6 @@ func testInt8x64Ternary(t *testing.T, f func(_, _, _ simd.Int8x64) simd.Int8x64, }) } -// testUint8x64Ternary tests the simd ternary method f against the expected behavior generated by want -func testUint8x64Ternary(t *testing.T, f func(_, _, _ simd.Uint8x64) simd.Uint8x64, want func(_, _, _ []uint8) []uint8) { - n := 64 - t.Helper() - forSliceTriple(t, uint8s, n, func(x, y, z []uint8) bool { - t.Helper() - a := simd.LoadUint8x64Slice(x) - b := simd.LoadUint8x64Slice(y) - c := simd.LoadUint8x64Slice(z) - g := make([]uint8, n) - f(a, b, c).StoreSlice(g) - w := want(x, y, z) - return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) - }) -} - // testInt16x32Ternary tests the simd ternary method f against the expected behavior generated by want func testInt16x32Ternary(t *testing.T, f func(_, _, _ simd.Int16x32) simd.Int16x32, want func(_, _, _ []int16) []int16) { n := 32 @@ -381,22 +365,6 @@ func testInt16x32Ternary(t *testing.T, f func(_, _, _ simd.Int16x32) simd.Int16x }) } -// testUint16x32Ternary tests the simd ternary method f against the expected behavior generated by want -func testUint16x32Ternary(t *testing.T, f func(_, _, _ simd.Uint16x32) simd.Uint16x32, want func(_, _, _ []uint16) []uint16) { - n := 32 - t.Helper() - forSliceTriple(t, uint16s, n, func(x, y, z []uint16) bool { - t.Helper() - a := simd.LoadUint16x32Slice(x) - b := simd.LoadUint16x32Slice(y) - c := simd.LoadUint16x32Slice(z) - g := make([]uint16, n) - f(a, b, c).StoreSlice(g) - w := want(x, y, z) - return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) - }) -} - // testInt32x16Ternary tests the simd ternary method f against the expected behavior generated by want func testInt32x16Ternary(t *testing.T, f func(_, _, _ simd.Int32x16) simd.Int32x16, want func(_, _, _ []int32) []int32) { n := 16 @@ -413,22 +381,6 @@ func testInt32x16Ternary(t *testing.T, f func(_, _, _ simd.Int32x16) simd.Int32x }) } -// testUint32x16Ternary tests the simd ternary method f against the expected behavior generated by want -func testUint32x16Ternary(t *testing.T, f func(_, _, _ simd.Uint32x16) simd.Uint32x16, want func(_, _, _ []uint32) []uint32) { - n := 16 - t.Helper() - forSliceTriple(t, uint32s, n, func(x, y, z []uint32) bool { - t.Helper() - a := simd.LoadUint32x16Slice(x) - b := simd.LoadUint32x16Slice(y) - c := simd.LoadUint32x16Slice(z) - g := make([]uint32, n) - f(a, b, c).StoreSlice(g) - w := want(x, y, z) - return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) - }) -} - // testInt64x8Ternary tests the simd ternary method f against the expected behavior generated by want func testInt64x8Ternary(t *testing.T, f func(_, _, _ simd.Int64x8) simd.Int64x8, want func(_, _, _ []int64) []int64) { n := 8 @@ -445,6 +397,54 @@ func testInt64x8Ternary(t *testing.T, f func(_, _, _ simd.Int64x8) simd.Int64x8, }) } +// testUint8x64Ternary tests the simd ternary method f against the expected behavior generated by want +func testUint8x64Ternary(t *testing.T, f func(_, _, _ simd.Uint8x64) simd.Uint8x64, want func(_, _, _ []uint8) []uint8) { + n := 64 + t.Helper() + forSliceTriple(t, uint8s, n, func(x, y, z []uint8) bool { + t.Helper() + a := simd.LoadUint8x64Slice(x) + b := simd.LoadUint8x64Slice(y) + c := simd.LoadUint8x64Slice(z) + g := make([]uint8, n) + f(a, b, c).StoreSlice(g) + w := want(x, y, z) + return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) + }) +} + +// testUint16x32Ternary tests the simd ternary method f against the expected behavior generated by want +func testUint16x32Ternary(t *testing.T, f func(_, _, _ simd.Uint16x32) simd.Uint16x32, want func(_, _, _ []uint16) []uint16) { + n := 32 + t.Helper() + forSliceTriple(t, uint16s, n, func(x, y, z []uint16) bool { + t.Helper() + a := simd.LoadUint16x32Slice(x) + b := simd.LoadUint16x32Slice(y) + c := simd.LoadUint16x32Slice(z) + g := make([]uint16, n) + f(a, b, c).StoreSlice(g) + w := want(x, y, z) + return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) + }) +} + +// testUint32x16Ternary tests the simd ternary method f against the expected behavior generated by want +func testUint32x16Ternary(t *testing.T, f func(_, _, _ simd.Uint32x16) simd.Uint32x16, want func(_, _, _ []uint32) []uint32) { + n := 16 + t.Helper() + forSliceTriple(t, uint32s, n, func(x, y, z []uint32) bool { + t.Helper() + a := simd.LoadUint32x16Slice(x) + b := simd.LoadUint32x16Slice(y) + c := simd.LoadUint32x16Slice(z) + g := make([]uint32, n) + f(a, b, c).StoreSlice(g) + w := want(x, y, z) + return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x); t.Logf("y=%v", y); t.Logf("z=%v", z) }) + }) +} + // testUint64x8Ternary tests the simd ternary method f against the expected behavior generated by want func testUint64x8Ternary(t *testing.T, f func(_, _, _ simd.Uint64x8) simd.Uint64x8, want func(_, _, _ []uint64) []uint64) { n := 8 diff --git a/src/simd/unary_helpers_test.go b/src/simd/unary_helpers_test.go index 2ee39b9a22..cdc5151a21 100644 --- a/src/simd/unary_helpers_test.go +++ b/src/simd/unary_helpers_test.go @@ -27,84 +27,84 @@ func testInt8x16Unary(t *testing.T, f func(_ simd.Int8x16) simd.Int8x16, want fu }) } -// testUint8x16Unary tests the simd unary method f against the expected behavior generated by want -func testUint8x16Unary(t *testing.T, f func(_ simd.Uint8x16) simd.Uint8x16, want func(_ []uint8) []uint8) { - n := 16 +// testInt16x8Unary tests the simd unary method f against the expected behavior generated by want +func testInt16x8Unary(t *testing.T, f func(_ simd.Int16x8) simd.Int16x8, want func(_ []int16) []int16) { + n := 8 t.Helper() - forSlice(t, uint8s, n, func(x []uint8) bool { + forSlice(t, int16s, n, func(x []int16) bool { t.Helper() - a := simd.LoadUint8x16Slice(x) - g := make([]uint8, n) + a := simd.LoadInt16x8Slice(x) + g := make([]int16, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testInt16x8Unary tests the simd unary method f against the expected behavior generated by want -func testInt16x8Unary(t *testing.T, f func(_ simd.Int16x8) simd.Int16x8, want func(_ []int16) []int16) { - n := 8 +// testInt32x4Unary tests the simd unary method f against the expected behavior generated by want +func testInt32x4Unary(t *testing.T, f func(_ simd.Int32x4) simd.Int32x4, want func(_ []int32) []int32) { + n := 4 t.Helper() - forSlice(t, int16s, n, func(x []int16) bool { + forSlice(t, int32s, n, func(x []int32) bool { t.Helper() - a := simd.LoadInt16x8Slice(x) - g := make([]int16, n) + a := simd.LoadInt32x4Slice(x) + g := make([]int32, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testUint16x8Unary tests the simd unary method f against the expected behavior generated by want -func testUint16x8Unary(t *testing.T, f func(_ simd.Uint16x8) simd.Uint16x8, want func(_ []uint16) []uint16) { - n := 8 +// testInt64x2Unary tests the simd unary method f against the expected behavior generated by want +func testInt64x2Unary(t *testing.T, f func(_ simd.Int64x2) simd.Int64x2, want func(_ []int64) []int64) { + n := 2 t.Helper() - forSlice(t, uint16s, n, func(x []uint16) bool { + forSlice(t, int64s, n, func(x []int64) bool { t.Helper() - a := simd.LoadUint16x8Slice(x) - g := make([]uint16, n) + a := simd.LoadInt64x2Slice(x) + g := make([]int64, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testInt32x4Unary tests the simd unary method f against the expected behavior generated by want -func testInt32x4Unary(t *testing.T, f func(_ simd.Int32x4) simd.Int32x4, want func(_ []int32) []int32) { - n := 4 +// testUint8x16Unary tests the simd unary method f against the expected behavior generated by want +func testUint8x16Unary(t *testing.T, f func(_ simd.Uint8x16) simd.Uint8x16, want func(_ []uint8) []uint8) { + n := 16 t.Helper() - forSlice(t, int32s, n, func(x []int32) bool { + forSlice(t, uint8s, n, func(x []uint8) bool { t.Helper() - a := simd.LoadInt32x4Slice(x) - g := make([]int32, n) + a := simd.LoadUint8x16Slice(x) + g := make([]uint8, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testUint32x4Unary tests the simd unary method f against the expected behavior generated by want -func testUint32x4Unary(t *testing.T, f func(_ simd.Uint32x4) simd.Uint32x4, want func(_ []uint32) []uint32) { - n := 4 +// testUint16x8Unary tests the simd unary method f against the expected behavior generated by want +func testUint16x8Unary(t *testing.T, f func(_ simd.Uint16x8) simd.Uint16x8, want func(_ []uint16) []uint16) { + n := 8 t.Helper() - forSlice(t, uint32s, n, func(x []uint32) bool { + forSlice(t, uint16s, n, func(x []uint16) bool { t.Helper() - a := simd.LoadUint32x4Slice(x) - g := make([]uint32, n) + a := simd.LoadUint16x8Slice(x) + g := make([]uint16, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testInt64x2Unary tests the simd unary method f against the expected behavior generated by want -func testInt64x2Unary(t *testing.T, f func(_ simd.Int64x2) simd.Int64x2, want func(_ []int64) []int64) { - n := 2 +// testUint32x4Unary tests the simd unary method f against the expected behavior generated by want +func testUint32x4Unary(t *testing.T, f func(_ simd.Uint32x4) simd.Uint32x4, want func(_ []uint32) []uint32) { + n := 4 t.Helper() - forSlice(t, int64s, n, func(x []int64) bool { + forSlice(t, uint32s, n, func(x []uint32) bool { t.Helper() - a := simd.LoadInt64x2Slice(x) - g := make([]int64, n) + a := simd.LoadUint32x4Slice(x) + g := make([]uint32, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) @@ -167,84 +167,84 @@ func testInt8x32Unary(t *testing.T, f func(_ simd.Int8x32) simd.Int8x32, want fu }) } -// testUint8x32Unary tests the simd unary method f against the expected behavior generated by want -func testUint8x32Unary(t *testing.T, f func(_ simd.Uint8x32) simd.Uint8x32, want func(_ []uint8) []uint8) { - n := 32 +// testInt16x16Unary tests the simd unary method f against the expected behavior generated by want +func testInt16x16Unary(t *testing.T, f func(_ simd.Int16x16) simd.Int16x16, want func(_ []int16) []int16) { + n := 16 t.Helper() - forSlice(t, uint8s, n, func(x []uint8) bool { + forSlice(t, int16s, n, func(x []int16) bool { t.Helper() - a := simd.LoadUint8x32Slice(x) - g := make([]uint8, n) + a := simd.LoadInt16x16Slice(x) + g := make([]int16, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testInt16x16Unary tests the simd unary method f against the expected behavior generated by want -func testInt16x16Unary(t *testing.T, f func(_ simd.Int16x16) simd.Int16x16, want func(_ []int16) []int16) { - n := 16 +// testInt32x8Unary tests the simd unary method f against the expected behavior generated by want +func testInt32x8Unary(t *testing.T, f func(_ simd.Int32x8) simd.Int32x8, want func(_ []int32) []int32) { + n := 8 t.Helper() - forSlice(t, int16s, n, func(x []int16) bool { + forSlice(t, int32s, n, func(x []int32) bool { t.Helper() - a := simd.LoadInt16x16Slice(x) - g := make([]int16, n) + a := simd.LoadInt32x8Slice(x) + g := make([]int32, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testUint16x16Unary tests the simd unary method f against the expected behavior generated by want -func testUint16x16Unary(t *testing.T, f func(_ simd.Uint16x16) simd.Uint16x16, want func(_ []uint16) []uint16) { - n := 16 +// testInt64x4Unary tests the simd unary method f against the expected behavior generated by want +func testInt64x4Unary(t *testing.T, f func(_ simd.Int64x4) simd.Int64x4, want func(_ []int64) []int64) { + n := 4 t.Helper() - forSlice(t, uint16s, n, func(x []uint16) bool { + forSlice(t, int64s, n, func(x []int64) bool { t.Helper() - a := simd.LoadUint16x16Slice(x) - g := make([]uint16, n) + a := simd.LoadInt64x4Slice(x) + g := make([]int64, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testInt32x8Unary tests the simd unary method f against the expected behavior generated by want -func testInt32x8Unary(t *testing.T, f func(_ simd.Int32x8) simd.Int32x8, want func(_ []int32) []int32) { - n := 8 +// testUint8x32Unary tests the simd unary method f against the expected behavior generated by want +func testUint8x32Unary(t *testing.T, f func(_ simd.Uint8x32) simd.Uint8x32, want func(_ []uint8) []uint8) { + n := 32 t.Helper() - forSlice(t, int32s, n, func(x []int32) bool { + forSlice(t, uint8s, n, func(x []uint8) bool { t.Helper() - a := simd.LoadInt32x8Slice(x) - g := make([]int32, n) + a := simd.LoadUint8x32Slice(x) + g := make([]uint8, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testUint32x8Unary tests the simd unary method f against the expected behavior generated by want -func testUint32x8Unary(t *testing.T, f func(_ simd.Uint32x8) simd.Uint32x8, want func(_ []uint32) []uint32) { - n := 8 +// testUint16x16Unary tests the simd unary method f against the expected behavior generated by want +func testUint16x16Unary(t *testing.T, f func(_ simd.Uint16x16) simd.Uint16x16, want func(_ []uint16) []uint16) { + n := 16 t.Helper() - forSlice(t, uint32s, n, func(x []uint32) bool { + forSlice(t, uint16s, n, func(x []uint16) bool { t.Helper() - a := simd.LoadUint32x8Slice(x) - g := make([]uint32, n) + a := simd.LoadUint16x16Slice(x) + g := make([]uint16, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testInt64x4Unary tests the simd unary method f against the expected behavior generated by want -func testInt64x4Unary(t *testing.T, f func(_ simd.Int64x4) simd.Int64x4, want func(_ []int64) []int64) { - n := 4 +// testUint32x8Unary tests the simd unary method f against the expected behavior generated by want +func testUint32x8Unary(t *testing.T, f func(_ simd.Uint32x8) simd.Uint32x8, want func(_ []uint32) []uint32) { + n := 8 t.Helper() - forSlice(t, int64s, n, func(x []int64) bool { + forSlice(t, uint32s, n, func(x []uint32) bool { t.Helper() - a := simd.LoadInt64x4Slice(x) - g := make([]int64, n) + a := simd.LoadUint32x8Slice(x) + g := make([]uint32, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) @@ -307,84 +307,84 @@ func testInt8x64Unary(t *testing.T, f func(_ simd.Int8x64) simd.Int8x64, want fu }) } -// testUint8x64Unary tests the simd unary method f against the expected behavior generated by want -func testUint8x64Unary(t *testing.T, f func(_ simd.Uint8x64) simd.Uint8x64, want func(_ []uint8) []uint8) { - n := 64 +// testInt16x32Unary tests the simd unary method f against the expected behavior generated by want +func testInt16x32Unary(t *testing.T, f func(_ simd.Int16x32) simd.Int16x32, want func(_ []int16) []int16) { + n := 32 t.Helper() - forSlice(t, uint8s, n, func(x []uint8) bool { + forSlice(t, int16s, n, func(x []int16) bool { t.Helper() - a := simd.LoadUint8x64Slice(x) - g := make([]uint8, n) + a := simd.LoadInt16x32Slice(x) + g := make([]int16, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testInt16x32Unary tests the simd unary method f against the expected behavior generated by want -func testInt16x32Unary(t *testing.T, f func(_ simd.Int16x32) simd.Int16x32, want func(_ []int16) []int16) { - n := 32 +// testInt32x16Unary tests the simd unary method f against the expected behavior generated by want +func testInt32x16Unary(t *testing.T, f func(_ simd.Int32x16) simd.Int32x16, want func(_ []int32) []int32) { + n := 16 t.Helper() - forSlice(t, int16s, n, func(x []int16) bool { + forSlice(t, int32s, n, func(x []int32) bool { t.Helper() - a := simd.LoadInt16x32Slice(x) - g := make([]int16, n) + a := simd.LoadInt32x16Slice(x) + g := make([]int32, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testUint16x32Unary tests the simd unary method f against the expected behavior generated by want -func testUint16x32Unary(t *testing.T, f func(_ simd.Uint16x32) simd.Uint16x32, want func(_ []uint16) []uint16) { - n := 32 +// testInt64x8Unary tests the simd unary method f against the expected behavior generated by want +func testInt64x8Unary(t *testing.T, f func(_ simd.Int64x8) simd.Int64x8, want func(_ []int64) []int64) { + n := 8 t.Helper() - forSlice(t, uint16s, n, func(x []uint16) bool { + forSlice(t, int64s, n, func(x []int64) bool { t.Helper() - a := simd.LoadUint16x32Slice(x) - g := make([]uint16, n) + a := simd.LoadInt64x8Slice(x) + g := make([]int64, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testInt32x16Unary tests the simd unary method f against the expected behavior generated by want -func testInt32x16Unary(t *testing.T, f func(_ simd.Int32x16) simd.Int32x16, want func(_ []int32) []int32) { - n := 16 +// testUint8x64Unary tests the simd unary method f against the expected behavior generated by want +func testUint8x64Unary(t *testing.T, f func(_ simd.Uint8x64) simd.Uint8x64, want func(_ []uint8) []uint8) { + n := 64 t.Helper() - forSlice(t, int32s, n, func(x []int32) bool { + forSlice(t, uint8s, n, func(x []uint8) bool { t.Helper() - a := simd.LoadInt32x16Slice(x) - g := make([]int32, n) + a := simd.LoadUint8x64Slice(x) + g := make([]uint8, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testUint32x16Unary tests the simd unary method f against the expected behavior generated by want -func testUint32x16Unary(t *testing.T, f func(_ simd.Uint32x16) simd.Uint32x16, want func(_ []uint32) []uint32) { - n := 16 +// testUint16x32Unary tests the simd unary method f against the expected behavior generated by want +func testUint16x32Unary(t *testing.T, f func(_ simd.Uint16x32) simd.Uint16x32, want func(_ []uint16) []uint16) { + n := 32 t.Helper() - forSlice(t, uint32s, n, func(x []uint32) bool { + forSlice(t, uint16s, n, func(x []uint16) bool { t.Helper() - a := simd.LoadUint32x16Slice(x) - g := make([]uint32, n) + a := simd.LoadUint16x32Slice(x) + g := make([]uint16, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) }) }) } -// testInt64x8Unary tests the simd unary method f against the expected behavior generated by want -func testInt64x8Unary(t *testing.T, f func(_ simd.Int64x8) simd.Int64x8, want func(_ []int64) []int64) { - n := 8 +// testUint32x16Unary tests the simd unary method f against the expected behavior generated by want +func testUint32x16Unary(t *testing.T, f func(_ simd.Uint32x16) simd.Uint32x16, want func(_ []uint32) []uint32) { + n := 16 t.Helper() - forSlice(t, int64s, n, func(x []int64) bool { + forSlice(t, uint32s, n, func(x []uint32) bool { t.Helper() - a := simd.LoadInt64x8Slice(x) - g := make([]int64, n) + a := simd.LoadUint32x16Slice(x) + g := make([]uint32, n) f(a).StoreSlice(g) w := want(x) return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })