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
proposal: float16 native type #32022
Comments
Can you just treat these values as a Without CPU support for |
To detail the answer above, you could probably use a type alias to solve your problem, namely package "something/something/gpu"
//
type Float16 = int16
// or, perhaps, for easy addressing
type Float16Bytes = [2]byte |
ianlancetaylor. Without CPU support for float16 I would be worried that the type would be a trap. You are probably correct. It could easily lead to issues if it was made into a standard type. beoran. Bitshifting ain't easy! ;) I guess my proposal should have been: |
I would suggest that you make a package with those functions and open
source it. While I agree GPU is important, not everything has to go inside
the Go standard library.
|
What about adding |
@gjvnq I don't understand what problem that would solve. |
It seems like the missing piece (besides actually adding a |
I just did a benchmark comparison between casting a float64 -> float32 and float32 -> float16. The float16 conversion is based on: https://github.com/h2so5/half/blob/master/float16.go BenchmarkFloat64CastToFloat32-8 2000000000 0.34 ns/op Note: Conversion/Casting happens in a function call and benched on i7-6820HQ with GC disabled. The float16 conversion is not that slow, although it could be faster. Any thoughts on improving it? @griesemer I guess that depends on the situation. If bandwidth is an issue, then spending some more time on CPU conversion isn't necessarily a bad thing, especially if you have some time left over before sending the data to the GPU. |
Thanks for replying quickly. It looks like software As @ianlancetaylor mentioned, without widespread CPU support for 16bit floats, having a |
We aren't going to add this type to the language without widespread hardware support for it. |
One year ago i began building a massive RTS game in Go and it has been an incredible journey so far! For most cases i really do not need the precision of a float32 and using a float16(half precision) has incredible performance advantages.
Benefits
Use case
I am planning to run most of the pathfinding and collision detection on the servers GPU's with Vulkan and for this, float16's would work wonders.
Any chance this can be added?
The text was updated successfully, but these errors were encountered: