util: add double_to_float16 helpers
authorIván Briano <ivan.briano@intel.com>
Tue, 19 Sep 2023 00:27:56 +0000 (17:27 -0700)
committerMarge Bot <emma+marge@anholt.net>
Mon, 9 Oct 2023 23:37:52 +0000 (23:37 +0000)
commit8382ee6e238dc05babcc24ebeab55e1ff981b213
tree1a3a863f937e9cade7e040b923108f915076301b
parent54498937c5abede433ba672e23559f5c3c2084b6
util: add double_to_float16 helpers

We convert from doubles to half by going through float in between, but
as noted in the comment in this commit, that can give wrong results in
some cases.

Add some helpers to ensure correct results based on rounding mode that
will be used in the next commit.

v2: Use fi/di from u_math.h (Ian)

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25281>
src/util/double.h