From: Pan Xiuli <[email protected]> These functions are used with half float convert funcitons.
Signed-off-by: Pan Xiuli <[email protected]> --- utests/utest_helper.cpp | 10 ++++++++++ utests/utest_helper.hpp | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp index 3078a2f..c1c1318 100644 --- a/utests/utest_helper.cpp +++ b/utests/utest_helper.cpp @@ -1044,3 +1044,13 @@ uint16_t __float_to_half(uint32_t x) bits += m & 1; return bits; } +uint32_t as_uint(float f) { + union uint32_cast _tmp; + _tmp._float = f; + return _tmp._uint; +} +float as_float(uint32_t i) { + union uint32_cast _tmp; + _tmp._uint = i; + return _tmp._float; +} diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp index 561c2c4..5f2fea6 100644 --- a/utests/utest_helper.hpp +++ b/utests/utest_helper.hpp @@ -52,6 +52,11 @@ extern EGLContext eglContext; extern EGLSurface eglSurface; #endif +union uint32_cast { + uint32_t _uint; + float _float; +}; + #define OCL_THROW_ERROR(FN, STATUS) \ do { \ char msg[2048]; \ @@ -306,4 +311,6 @@ extern int cl_check_half(void); /* Helper function for half type numbers */ extern uint32_t __half_to_float(uint16_t h, bool* isInf = NULL, bool* infSign = NULL); extern uint16_t __float_to_half(uint32_t x); +extern float as_float(uint32_t i); +extern uint32_t as_uint(float f); #endif /* __UTEST_HELPER_HPP__ */ -- 2.5.0 _______________________________________________ Beignet mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/beignet
