Skip to content

Commit 599b1b9

Browse files
authored
[SYCL][libdevice] Add type cast functions between half and float/integral type (#6930)
Signed-off-by: jinge90 <[email protected]>
1 parent 430c722 commit 599b1b9

File tree

9 files changed

+1528
-41
lines changed

9 files changed

+1528
-41
lines changed

libdevice/device.h

+9
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,13 @@
4040
#define DEVICE_EXTERN_C_INLINE DEVICE_EXTERN_C __attribute__((always_inline))
4141
#endif // __LIBDEVICE_HOST_IMPL__
4242

43+
// Rounding mode are used internally by type convert functions in imf libdevice
44+
// and we don't want to include system's fenv.h, so we define ourselves'.
45+
typedef enum {
46+
__IML_RTE, // round to nearest-even
47+
__IML_RTZ, // round to zero
48+
__IML_RTP, // round to +inf
49+
__IML_RTN, // round to -inf
50+
} __iml_rounding_mode;
51+
4352
#endif // __LIBDEVICE_DEVICE_H__

libdevice/device_imf.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ static inline TyFP __integral2FP_host(TyINT x, int rdMode) {
9090
fesetround(roundingOriginal);
9191
return res;
9292
}
93+
#pragma STDC FENV_ACCESS OFF
9394
#endif // __LIBDEVICE_HOST_IMPL__
9495

9596
template <typename Ty> static inline Ty __imax(Ty x, Ty y) {

0 commit comments

Comments
 (0)