]> Cypherpunks repositories - gostls13.git/commit
[dev.simd] simd: move test generation into Go repo
authorDavid Chase <drchase@google.com>
Mon, 7 Jul 2025 21:48:24 +0000 (17:48 -0400)
committerDavid Chase <drchase@google.com>
Fri, 1 Aug 2025 20:08:31 +0000 (13:08 -0700)
commit88568519b416190d264f5e5f02c41b5a139498b2
tree93b1b13bb16233682d3bb6d99d914f32c0f35efc
parent6f7a1164e797f694c535ebf5f2c9722845a732cd
[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>
18 files changed:
src/simd/binary_helpers_test.go [new file with mode: 0644]
src/simd/binary_test.go [new file with mode: 0644]
src/simd/compare_helpers_test.go [new file with mode: 0644]
src/simd/compare_test.go [new file with mode: 0644]
src/simd/comparemasked_helpers_test.go [new file with mode: 0644]
src/simd/genfiles.go [new file with mode: 0644]
src/simd/genslice.go [deleted file]
src/simd/helpers_test.go [new file with mode: 0644]
src/simd/no_tag.go
src/simd/simd_test.go
src/simd/simd_wrapped_test.go [deleted file]
src/simd/simulation_helpers_test.go [new file with mode: 0644]
src/simd/slice_amd64.go
src/simd/slicepart_test.go
src/simd/ternary_helpers_test.go [new file with mode: 0644]
src/simd/ternary_test.go [new file with mode: 0644]
src/simd/unary_helpers_test.go [new file with mode: 0644]
src/simd/unary_test.go [new file with mode: 0644]