golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.99k stars 17.54k forks source link

x/image/draw: BiLinear.Scale shows GOARCH-dependent behaviour due to float operation differences #67029

Closed kortschak closed 2 months ago

kortschak commented 4 months ago

Go version

go1.22

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/user/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/user/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.0.linux-arm64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/user/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.0.linux-arm64/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/user/src/github.com/kortschak/dex/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3886885416=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Run the tests in this change: https://github.com/kortschak/gifscaleissue/pull/1 or the same locally on a linux/arm64 device (this is the go env above).

What did you see happen?

A difference in encoded image between the ubuntu run and darwin (arm64 — darwin/amd64 shows no difference).

What did you expect to see?

The same encoding.

Additional comments

This is undoubtedly due to FMA differences between arm64 and amd64 and may well be something that is not worth "fixing", but I wanted to raise it in case others see this issue. It arose in testing, and in the original case, I am just duplicating the golden images with a GOARCH tag to differentiate them.

ianlancetaylor commented 4 months ago

CC @nigeltao

gopherbot commented 2 months ago

Change https://go.dev/cl/596816 mentions this issue: draw: avoid FMA (Fused Multiply Add)