mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.simd] simd: add tests for simd conversions to Int32/Uint32.
Change-Id: I71a6c6708e19d210f1fbdc72379f8215356ff02e Reviewed-on: https://go-review.googlesource.com/c/go/+/689718 Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
a24ffe3379
commit
09ff25e350
4 changed files with 145 additions and 3 deletions
|
|
@ -43,7 +43,7 @@ var allShapes = &shapes{
|
|||
|
||||
// these are the shapes that are currently converted to int32
|
||||
// (not all conversions are available, yet)
|
||||
var toInt32Shapes = &shapes{
|
||||
var convert32Shapes = &shapes{
|
||||
vecs: []int{128, 256, 512},
|
||||
floats: []int{32},
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ func test{{.Vec}}Unary(t *testing.T, f func(_ simd.{{.Vec}}) simd.{{.Vec}}, want
|
|||
}
|
||||
`)
|
||||
|
||||
var unaryTemplateToInt32 = shapedTemplateOf(toInt32Shapes, "unary_int32_helpers", `
|
||||
var unaryTemplateToInt32 = shapedTemplateOf(convert32Shapes, "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}}
|
||||
|
|
@ -203,6 +203,22 @@ func test{{.Vec}}UnaryToInt32(t *testing.T, f func(x simd.{{.Vec}}) simd.Int32x{
|
|||
}
|
||||
`)
|
||||
|
||||
var unaryTemplateToUint32 = shapedTemplateOf(convert32Shapes, "unary_uint32_helpers", `
|
||||
// test{{.Vec}}Unary tests the simd unary method f against the expected behavior generated by want
|
||||
func test{{.Vec}}UnaryToUint32(t *testing.T, f func(x simd.{{.Vec}}) simd.Uint32x{{.Count}}, want func(x []{{.Type}}) []uint32) {
|
||||
n := {{.Count}}
|
||||
t.Helper()
|
||||
forSlice(t, {{.Type}}s, n, func(x []{{.Type}}) bool {
|
||||
t.Helper()
|
||||
a := simd.Load{{.Vec}}Slice(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)})
|
||||
})
|
||||
}
|
||||
`)
|
||||
|
||||
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}}) {
|
||||
|
|
@ -295,7 +311,7 @@ func main() {
|
|||
one(*sl, prologue, sliceTemplate)
|
||||
}
|
||||
if *uh != "" {
|
||||
one(*uh, curryTestPrologue("unary simd methods"), unaryTemplate)
|
||||
one(*uh, curryTestPrologue("unary simd methods"), unaryTemplate, unaryTemplateToInt32, unaryTemplateToUint32)
|
||||
}
|
||||
if *bh != "" {
|
||||
one(*bh, curryTestPrologue("binary simd methods"), binaryTemplate)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue