From 55c031c6ae16f4f227073a2ddf90516cd6870870 Mon Sep 17 00:00:00 2001 From: Mauri de Souza Meneguzzo Date: Tue, 3 Nov 2026 19:36:03 -0300 Subject: [PATCH] testdata: compare activation_functions.txt with the same machine's scalar build activation_functions.txt hashes float bits and compares both builds with testmain/output, which was recorded on amd64. It passes on arm64 only because its loops pass the input NaN through and never create one: with an alpha of 0, LeakyReLU computes 0 times -Inf, whose NaN has the sign bit set on amd64 and clear on arm64, and the script then fails on arm64 against the recording. It now compares the recording only on amd64 and the simd build with the scalar build of the same machine, as #8 did for three other scripts. Those three scripts also compared the simd build with the recording on amd64. That adds nothing, since the scalar build matches the recording there and the simd build matches the scalar build, and as the last comparison it is the one -update recorded, so a simd build that differed from the scalar one would have been written into the recording. Only the scalar build is compared with the recording now. Their comments also named the square root of a negative number in two scripts that have no square root. --- testdata/abs_sqrt.txt | 7 +++---- testdata/activation_functions.txt | 11 +++++++++-- testdata/activation_temp.txt | 9 ++++----- testdata/invariant_call.txt | 9 ++++----- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/testdata/abs_sqrt.txt b/testdata/abs_sqrt.txt index d6368e2..5a44e70 100644 --- a/testdata/abs_sqrt.txt +++ b/testdata/abs_sqrt.txt @@ -5,9 +5,9 @@ # output is compared bit for bit. # testmain/output was recorded on amd64: a NaN that an operation creates (the square -# root of a negative number, 0 times infinity) has the sign bit set there and clear -# on arm64, so the recording is compared only on amd64, and on every target the -# simd build is compared with the scalar build of the same machine. +# root of a negative number) has the sign bit set there and clear on arm64, so only +# the scalar build is compared with the recording, and only on amd64. On every +# target the simd build is compared with the scalar build of the same machine. # The scalar program is the reference behavior. exec go run ./testmain @@ -24,7 +24,6 @@ cmp ops.go ops.go.guarded # The simd build must behave identically. env GOEXPERIMENT=simd exec go run ./testmain -[GOARCH:amd64] cmp stdout testmain/output cmp stdout scalar.out -- go.mod -- diff --git a/testdata/activation_functions.txt b/testdata/activation_functions.txt index d9cbac6..621bf43 100644 --- a/testdata/activation_functions.txt +++ b/testdata/activation_functions.txt @@ -3,9 +3,16 @@ # Both branches are computed for every lane, and the results must still match the # scalar loop for NaN, infinities and signed zeros, which compare the way Go does. +# testmain/output was recorded on amd64. These loops only pass the input NaN +# through, but a NaN that an operation creates (an alpha of 0 times an infinity) +# has the sign bit set there and clear on arm64, so only the scalar build is +# compared with the recording, and only on amd64. On every target the simd build +# is compared with the scalar build of the same machine. + # The scalar program is the reference behavior. exec go run ./testmain -cmp stdout testmain/output +[GOARCH:amd64] cmp stdout testmain/output +cp stdout scalar.out cp ops.go ops.go.orig loopvec -split . @@ -17,7 +24,7 @@ cmp ops.go ops.go.guarded # The simd build must behave identically. env GOEXPERIMENT=simd exec go run ./testmain -cmp stdout testmain/output +cmp stdout scalar.out -- go.mod -- module example.com/test diff --git a/testdata/activation_temp.txt b/testdata/activation_temp.txt index 5526f8d..6b65c05 100644 --- a/testdata/activation_temp.txt +++ b/testdata/activation_temp.txt @@ -4,10 +4,10 @@ # if/else if, then use it. Results must match the scalar loop bit for bit, NaN, # infinities and signed zeros included. -# testmain/output was recorded on amd64: a NaN that an operation creates (the square -# root of a negative number, 0 times infinity) has the sign bit set there and clear -# on arm64, so the recording is compared only on amd64, and on every target the -# simd build is compared with the scalar build of the same machine. +# testmain/output was recorded on amd64: a NaN that an operation creates (0 times +# infinity) has the sign bit set there and clear on arm64, so only the scalar build +# is compared with the recording, and only on amd64. On every target the simd build +# is compared with the scalar build of the same machine. exec go run ./testmain [GOARCH:amd64] cmp stdout testmain/output @@ -22,7 +22,6 @@ cmp ops.go ops.go.guarded env GOEXPERIMENT=simd exec go run ./testmain -[GOARCH:amd64] cmp stdout testmain/output cmp stdout scalar.out -- go.mod -- diff --git a/testdata/invariant_call.txt b/testdata/invariant_call.txt index 3f1fcf5..eafaef1 100644 --- a/testdata/invariant_call.txt +++ b/testdata/invariant_call.txt @@ -3,10 +3,10 @@ # the call is evaluated once before the loop. The results must match the scalar loop # bit for bit, which is the only way to compare NaN and negative zero. -# testmain/output was recorded on amd64: a NaN that an operation creates (the square -# root of a negative number, 0 times infinity) has the sign bit set there and clear -# on arm64, so the recording is compared only on amd64, and on every target the -# simd build is compared with the scalar build of the same machine. +# testmain/output was recorded on amd64: a NaN that an operation creates (0 times +# infinity) has the sign bit set there and clear on arm64, so only the scalar build +# is compared with the recording, and only on amd64. On every target the simd build +# is compared with the scalar build of the same machine. exec go run ./testmain [GOARCH:amd64] cmp stdout testmain/output @@ -21,7 +21,6 @@ cmp ops.go ops.go.guarded env GOEXPERIMENT=simd exec go run ./testmain -[GOARCH:amd64] cmp stdout testmain/output cmp stdout scalar.out -- go.mod --