Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken assembly implementations #42

Closed
soypat opened this issue May 6, 2022 · 1 comment
Closed

Broken assembly implementations #42

soypat opened this issue May 6, 2022 · 1 comment

Comments

@soypat
Copy link
Collaborator

soypat commented May 6, 2022

Due to recent developments, some assembly implementations have been discovered to be broken.

An idea for 64bit assembly implementations

Disclaimer: I'm unsure if casting float64s is desirable. This is just a shot-in-the-dark idea.

Instead of us hosting the assembly implementation for 64 bit architectures we could provide an additional boolean build flag similar to haveArchFunc, but indicating that the Go standard library has the 64 bit implementation, thus we can just use a wrapper func style implementation.

This may be clearer if I illustrate with an example
Today The Sqrt implementation is as follows:

func Sqrt(x float32) float32 {
	if haveArchSqrt {
		return archSqrt(x)
	}
	return sqrt(x)
}

I propose adding a new constant haveStdlibSqrt and a new file sqrt_stdlib.go. The above code changes as follows

func Sqrt(x float32) float32 {
	if haveArchSqrt {
		return archSqrt(x)
	}
	if haveStdlibSqrt {
		return float32(math.Sqrt(float32(x)))
	}
	return sqrt(x)
}

The new file sqrt_stdlib.go has the following contents.

//go:build !noasm && (arm64 || risc64)
package math32

import "math"

const haveStdlibSqrt = true // set to false in _noasm and _asm files
@soypat
Copy link
Collaborator Author

soypat commented Aug 19, 2024

Fixed in v1.11.0

@soypat soypat closed this as completed Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant