Commit graph

2 commits

Author SHA1 Message Date
David Chase
a24ffe3379 [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 <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-08-01 14:14:47 -07:00
David Chase
88568519b4 [dev.simd] simd: move test generation into Go repo
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>
2025-08-01 13:08:31 -07:00