blob: 02e5e0eb051602421df6f4ccc459697eca07e39e [file]
// Code generated by 'tmplgen'; DO NOT EDIT.
//go:build goexperiment.simd && arm64
// This file contains functions testing simd reduce methods.
// Each function in this file is specialized for a
// particular simd type <BaseType><Width>x<Count>.
package simd_test
import (
"math"
"simd/archsimd"
"testing"
)
func testInt8x16Reduce(t *testing.T, f func(_ archsimd.Int8x16) int8, want func(_ []int8) int8) {
n := 16
t.Helper()
forSlice(t, int8s, n, func(x []int8) bool {
t.Helper()
a := archsimd.LoadInt8x16(x)
g := f(a)
w := want(x)
if g != w {
t.Errorf("got %v, want %v, input %v", g, w, x)
return false
}
return true
})
}
func testInt16x8Reduce(t *testing.T, f func(_ archsimd.Int16x8) int16, want func(_ []int16) int16) {
n := 8
t.Helper()
forSlice(t, int16s, n, func(x []int16) bool {
t.Helper()
a := archsimd.LoadInt16x8(x)
g := f(a)
w := want(x)
if g != w {
t.Errorf("got %v, want %v, input %v", g, w, x)
return false
}
return true
})
}
func testInt32x4Reduce(t *testing.T, f func(_ archsimd.Int32x4) int32, want func(_ []int32) int32) {
n := 4
t.Helper()
forSlice(t, int32s, n, func(x []int32) bool {
t.Helper()
a := archsimd.LoadInt32x4(x)
g := f(a)
w := want(x)
if g != w {
t.Errorf("got %v, want %v, input %v", g, w, x)
return false
}
return true
})
}
func testUint8x16Reduce(t *testing.T, f func(_ archsimd.Uint8x16) uint8, want func(_ []uint8) uint8) {
n := 16
t.Helper()
forSlice(t, uint8s, n, func(x []uint8) bool {
t.Helper()
a := archsimd.LoadUint8x16(x)
g := f(a)
w := want(x)
if g != w {
t.Errorf("got %v, want %v, input %v", g, w, x)
return false
}
return true
})
}
func testUint16x8Reduce(t *testing.T, f func(_ archsimd.Uint16x8) uint16, want func(_ []uint16) uint16) {
n := 8
t.Helper()
forSlice(t, uint16s, n, func(x []uint16) bool {
t.Helper()
a := archsimd.LoadUint16x8(x)
g := f(a)
w := want(x)
if g != w {
t.Errorf("got %v, want %v, input %v", g, w, x)
return false
}
return true
})
}
func testUint32x4Reduce(t *testing.T, f func(_ archsimd.Uint32x4) uint32, want func(_ []uint32) uint32) {
n := 4
t.Helper()
forSlice(t, uint32s, n, func(x []uint32) bool {
t.Helper()
a := archsimd.LoadUint32x4(x)
g := f(a)
w := want(x)
if g != w {
t.Errorf("got %v, want %v, input %v", g, w, x)
return false
}
return true
})
}
func testFloat32x4Reduce(t *testing.T, f func(_ archsimd.Float32x4) float32, want func(_ []float32) float32) {
n := 4
t.Helper()
forSlice(t, float32s, n, func(x []float32) bool {
t.Helper()
a := archsimd.LoadFloat32x4(x)
g := f(a)
w := want(x)
if g != w && !(math.IsNaN(float64(g)) && math.IsNaN(float64(w))) {
t.Errorf("got %v, want %v, input %v", g, w, x)
return false
}
return true
})
}