mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
This pairs with CL 689275 which removes test generation from simdgen
This uses generics and attempts to encode the tests as compactly as
possible.
Some files, *_helpers_test.go, are generated.
Use t.Helper() to get the line number right for a failure.
Adds helper error return values and early exits to only report a
single test failure per operations and vector shape, for the
generated test failures.
Include the entire got and wanted vectors for that failure.
Provide an option to include the input vectors to failures, also
report the type of the test.
Sample failure test output (obtained by intentionally breaking
the "want" value for AndNot):
=== RUN TestAndNot
binary_test.go:214: For int16 vector elements:
binary_test.go:214: got =[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
binary_test.go:214: want=[-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1]
binary_test.go:214: x=[1 -1 0 2 4 8 1024 3 5 7 11 13 3000 5555 7777 11111]
binary_test.go:214: y=[1 -1 0 2 4 8 1024 3 5 7 11 13 3000 5555 7777 11111]
binary_test.go:214: at index 0, got=0, want=-1
binary_test.go:215: For int16 vector elements:
binary_test.go:215: got =[0 0 0 0 0 0 0 0]
binary_test.go:215: want=[-1 -1 -1 -1 -1 -1 -1 -1]
binary_test.go:215: x=[1 -1 0 2 4 8 1024 3]
binary_test.go:215: y=[1 -1 0 2 4 8 1024 3]
binary_test.go:215: at index 0, got=0, want=-1
binary_test.go:216: For int32 vector elements:
binary_test.go:216: got =[0 0 0 0]
binary_test.go:216: want=[-1 -1 -1 -1]
binary_test.go:216: x=[1 -1 0 2]
binary_test.go:216: y=[1 -1 0 2]
binary_test.go:216: at index 0, got=0, want=-1
(etc)
Change-Id: I0f6ee8390ebe7a2333002e9415b4d71527fa3c38
Reviewed-on: https://go-review.googlesource.com/c/go/+/686057
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
434 lines
14 KiB
Go
434 lines
14 KiB
Go
// Code generated by 'go run genfiles.go'; DO NOT EDIT.
|
|
|
|
//go:build goexperiment.simd
|
|
|
|
// This file contains functions testing unary simd methods.
|
|
// Each function in this file is specialized for a
|
|
// particular simd type <BaseType><Width>x<Count>.
|
|
|
|
package simd_test
|
|
|
|
import (
|
|
"simd"
|
|
"testing"
|
|
)
|
|
|
|
// testInt8x16Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testInt8x16Unary(t *testing.T, f func(_ simd.Int8x16) simd.Int8x16, want func(_ []int8) []int8) {
|
|
n := 16
|
|
t.Helper()
|
|
forSlice(t, int8s, n, func(x []int8) bool {
|
|
t.Helper()
|
|
a := simd.LoadInt8x16Slice(x)
|
|
g := make([]int8, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// 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, uint8s, n, func(x []uint8) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, int16s, n, func(x []int16) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, uint16s, n, func(x []uint16) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, int32s, n, func(x []int32) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, uint32s, n, func(x []uint32) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, int64s, n, func(x []int64) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// testUint64x2Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testUint64x2Unary(t *testing.T, f func(_ simd.Uint64x2) simd.Uint64x2, want func(_ []uint64) []uint64) {
|
|
n := 2
|
|
t.Helper()
|
|
forSlice(t, uint64s, n, func(x []uint64) bool {
|
|
t.Helper()
|
|
a := simd.LoadUint64x2Slice(x)
|
|
g := make([]uint64, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// testFloat32x4Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testFloat32x4Unary(t *testing.T, f func(_ simd.Float32x4) simd.Float32x4, want func(_ []float32) []float32) {
|
|
n := 4
|
|
t.Helper()
|
|
forSlice(t, float32s, n, func(x []float32) bool {
|
|
t.Helper()
|
|
a := simd.LoadFloat32x4Slice(x)
|
|
g := make([]float32, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// testFloat64x2Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testFloat64x2Unary(t *testing.T, f func(_ simd.Float64x2) simd.Float64x2, want func(_ []float64) []float64) {
|
|
n := 2
|
|
t.Helper()
|
|
forSlice(t, float64s, n, func(x []float64) bool {
|
|
t.Helper()
|
|
a := simd.LoadFloat64x2Slice(x)
|
|
g := make([]float64, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// testInt8x32Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testInt8x32Unary(t *testing.T, f func(_ simd.Int8x32) simd.Int8x32, want func(_ []int8) []int8) {
|
|
n := 32
|
|
t.Helper()
|
|
forSlice(t, int8s, n, func(x []int8) bool {
|
|
t.Helper()
|
|
a := simd.LoadInt8x32Slice(x)
|
|
g := make([]int8, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// 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, uint8s, n, func(x []uint8) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, int16s, n, func(x []int16) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, uint16s, n, func(x []uint16) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, int32s, n, func(x []int32) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, uint32s, n, func(x []uint32) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, int64s, n, func(x []int64) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// testUint64x4Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testUint64x4Unary(t *testing.T, f func(_ simd.Uint64x4) simd.Uint64x4, want func(_ []uint64) []uint64) {
|
|
n := 4
|
|
t.Helper()
|
|
forSlice(t, uint64s, n, func(x []uint64) bool {
|
|
t.Helper()
|
|
a := simd.LoadUint64x4Slice(x)
|
|
g := make([]uint64, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// testFloat32x8Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testFloat32x8Unary(t *testing.T, f func(_ simd.Float32x8) simd.Float32x8, want func(_ []float32) []float32) {
|
|
n := 8
|
|
t.Helper()
|
|
forSlice(t, float32s, n, func(x []float32) bool {
|
|
t.Helper()
|
|
a := simd.LoadFloat32x8Slice(x)
|
|
g := make([]float32, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// testFloat64x4Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testFloat64x4Unary(t *testing.T, f func(_ simd.Float64x4) simd.Float64x4, want func(_ []float64) []float64) {
|
|
n := 4
|
|
t.Helper()
|
|
forSlice(t, float64s, n, func(x []float64) bool {
|
|
t.Helper()
|
|
a := simd.LoadFloat64x4Slice(x)
|
|
g := make([]float64, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// testInt8x64Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testInt8x64Unary(t *testing.T, f func(_ simd.Int8x64) simd.Int8x64, want func(_ []int8) []int8) {
|
|
n := 64
|
|
t.Helper()
|
|
forSlice(t, int8s, n, func(x []int8) bool {
|
|
t.Helper()
|
|
a := simd.LoadInt8x64Slice(x)
|
|
g := make([]int8, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// 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, uint8s, n, func(x []uint8) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, int16s, n, func(x []int16) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, uint16s, n, func(x []uint16) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, int32s, n, func(x []int32) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, uint32s, n, func(x []uint32) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// 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, int64s, n, func(x []int64) bool {
|
|
t.Helper()
|
|
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) })
|
|
})
|
|
}
|
|
|
|
// testUint64x8Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testUint64x8Unary(t *testing.T, f func(_ simd.Uint64x8) simd.Uint64x8, want func(_ []uint64) []uint64) {
|
|
n := 8
|
|
t.Helper()
|
|
forSlice(t, uint64s, n, func(x []uint64) bool {
|
|
t.Helper()
|
|
a := simd.LoadUint64x8Slice(x)
|
|
g := make([]uint64, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// testFloat32x16Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testFloat32x16Unary(t *testing.T, f func(_ simd.Float32x16) simd.Float32x16, want func(_ []float32) []float32) {
|
|
n := 16
|
|
t.Helper()
|
|
forSlice(t, float32s, n, func(x []float32) bool {
|
|
t.Helper()
|
|
a := simd.LoadFloat32x16Slice(x)
|
|
g := make([]float32, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|
|
|
|
// testFloat64x8Unary tests the simd unary method f against the expected behavior generated by want
|
|
func testFloat64x8Unary(t *testing.T, f func(_ simd.Float64x8) simd.Float64x8, want func(_ []float64) []float64) {
|
|
n := 8
|
|
t.Helper()
|
|
forSlice(t, float64s, n, func(x []float64) bool {
|
|
t.Helper()
|
|
a := simd.LoadFloat64x8Slice(x)
|
|
g := make([]float64, n)
|
|
f(a).StoreSlice(g)
|
|
w := want(x)
|
|
return checkSlicesLogInput(t, g, w, func() { t.Helper(); t.Logf("x=%v", x) })
|
|
})
|
|
}
|