| // Code generated by 'tmplgen'; DO NOT EDIT. |
| |
| //go:build goexperiment.simd && (amd64 || wasm || arm64) |
| |
| // 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/archsimd" |
| "testing" |
| ) |
| |
| // testInt8x16Unary tests the simd unary method f against the expected behavior generated by want |
| func testInt8x16Unary(t *testing.T, f func(_ archsimd.Int8x16) archsimd.Int8x16, want func(_ []int8) []int8) { |
| n := 16 |
| t.Helper() |
| forSlice(t, int8s, n, func(x []int8) bool { |
| t.Helper() |
| a := archsimd.LoadInt8x16(x) |
| g := make([]int8, n) |
| f(a).Store(g) |
| w := want(x) |
| return checkSlicesLogInput(t, g, w, 0.0, 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(_ archsimd.Int16x8) archsimd.Int16x8, want func(_ []int16) []int16) { |
| n := 8 |
| t.Helper() |
| forSlice(t, int16s, n, func(x []int16) bool { |
| t.Helper() |
| a := archsimd.LoadInt16x8(x) |
| g := make([]int16, n) |
| f(a).Store(g) |
| w := want(x) |
| return checkSlicesLogInput(t, g, w, 0.0, 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(_ archsimd.Int32x4) archsimd.Int32x4, want func(_ []int32) []int32) { |
| n := 4 |
| t.Helper() |
| forSlice(t, int32s, n, func(x []int32) bool { |
| t.Helper() |
| a := archsimd.LoadInt32x4(x) |
| g := make([]int32, n) |
| f(a).Store(g) |
| w := want(x) |
| return checkSlicesLogInput(t, g, w, 0.0, 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(_ archsimd.Int64x2) archsimd.Int64x2, want func(_ []int64) []int64) { |
| n := 2 |
| t.Helper() |
| forSlice(t, int64s, n, func(x []int64) bool { |
| t.Helper() |
| a := archsimd.LoadInt64x2(x) |
| g := make([]int64, n) |
| f(a).Store(g) |
| w := want(x) |
| return checkSlicesLogInput(t, g, w, 0.0, 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(_ archsimd.Uint8x16) archsimd.Uint8x16, want func(_ []uint8) []uint8) { |
| n := 16 |
| t.Helper() |
| forSlice(t, uint8s, n, func(x []uint8) bool { |
| t.Helper() |
| a := archsimd.LoadUint8x16(x) |
| g := make([]uint8, n) |
| f(a).Store(g) |
| w := want(x) |
| return checkSlicesLogInput(t, g, w, 0.0, 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(_ archsimd.Uint16x8) archsimd.Uint16x8, want func(_ []uint16) []uint16) { |
| n := 8 |
| t.Helper() |
| forSlice(t, uint16s, n, func(x []uint16) bool { |
| t.Helper() |
| a := archsimd.LoadUint16x8(x) |
| g := make([]uint16, n) |
| f(a).Store(g) |
| w := want(x) |
| return checkSlicesLogInput(t, g, w, 0.0, 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(_ archsimd.Uint32x4) archsimd.Uint32x4, want func(_ []uint32) []uint32) { |
| n := 4 |
| t.Helper() |
| forSlice(t, uint32s, n, func(x []uint32) bool { |
| t.Helper() |
| a := archsimd.LoadUint32x4(x) |
| g := make([]uint32, n) |
| f(a).Store(g) |
| w := want(x) |
| return checkSlicesLogInput(t, g, w, 0.0, 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(_ archsimd.Uint64x2) archsimd.Uint64x2, want func(_ []uint64) []uint64) { |
| n := 2 |
| t.Helper() |
| forSlice(t, uint64s, n, func(x []uint64) bool { |
| t.Helper() |
| a := archsimd.LoadUint64x2(x) |
| g := make([]uint64, n) |
| f(a).Store(g) |
| w := want(x) |
| return checkSlicesLogInput(t, g, w, 0.0, 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(_ archsimd.Float32x4) archsimd.Float32x4, want func(_ []float32) []float32) { |
| n := 4 |
| t.Helper() |
| forSlice(t, float32s, n, func(x []float32) bool { |
| t.Helper() |
| a := archsimd.LoadFloat32x4(x) |
| g := make([]float32, n) |
| f(a).Store(g) |
| w := want(x) |
| return checkSlicesLogInput(t, g, w, 0.0, 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(_ archsimd.Float64x2) archsimd.Float64x2, want func(_ []float64) []float64) { |
| n := 2 |
| t.Helper() |
| forSlice(t, float64s, n, func(x []float64) bool { |
| t.Helper() |
| a := archsimd.LoadFloat64x2(x) |
| g := make([]float64, n) |
| f(a).Store(g) |
| w := want(x) |
| return checkSlicesLogInput(t, g, w, 0.0, func() { t.Helper(); t.Logf("x=%v", x) }) |
| }) |
| } |