[Beignet] [PATCH] backend: add double constants defined by spec

rander.wang rander.wang at intel.com
Thu Apr 20 08:24:17 UTC 2017


Signed-off-by: rander.wang <rander.wang at intel.com>
---
 backend/src/libocl/include/ocl_float.h | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/backend/src/libocl/include/ocl_float.h b/backend/src/libocl/include/ocl_float.h
index 77b78bb..443ec9e 100644
--- a/backend/src/libocl/include/ocl_float.h
+++ b/backend/src/libocl/include/ocl_float.h
@@ -33,6 +33,18 @@
 #define FLT_MIN 0x1.0p-126f
 #define FLT_EPSILON 0x1.0p-23f
 
+#define DBL_DIG 15
+#define DBL_MANT_DIG 53
+#define DBL_MAX_10_EXP +308
+#define DBL_MAX_EXP +1024
+#define DBL_MIN_10_EXP -307
+#define DBL_MIN_EXP -1021
+#define DBL_RADIX 2
+#define DBL_ONE 1.0000000000e+00
+#define DBL_MAX 0x1.fffffffffffffp1023
+#define DBL_MIN 0x1.0p-1022
+#define DBL_EPSILON 0x1.0p-52
+
 #define MAXFLOAT     3.40282347e38F
 INLINE_OVERLOADABLE float __ocl_inff(void) {
   union { uint u; float f; } u;
@@ -96,6 +108,20 @@ INLINE_OVERLOADABLE int __ocl_finitef (float x){
 #define FP_ILOGB0    (-0x7FFFFFFF-1)
 #define FP_ILOGBNAN  FP_ILOGB0
 
+#define M_E      2.718281828459045
+#define M_LOG2E  1.442695040888963387
+#define M_LOG10E 0.434294481903251816668
+#define M_LN2    0.693147180559945286227
+#define M_LN10   2.30258509299404590109
+#define M_PI     3.141592653589793116
+#define M_PI_2   1.570796326794896558
+#define M_PI_4   0.785398163397448278999
+#define M_1_PI   0.318309886183790691216
+#define M_2_PI   0.636619772367581382433
+#define M_2_SQRTPI 1.12837916709551255856
+#define M_SQRT2   1.41421356237309514547
+#define M_SQRT1_2 0.707106781186547572737
+
 #define DF_EXP_MASK 0x7FF0000000000000UL
 #define DF_MAX_NORMAL 0x7FF0000000000000UL
 #define DF_MAN_MASK 0xFFFFFFFFFFFFFUL
@@ -112,6 +138,10 @@ INLINE_OVERLOADABLE int __ocl_finitef (float x){
 #define SF_POSITIVE_INF 0x7F800000
 #define SF_NAN 0x7FFFFFFF
 
-#define M_PI 3.141592653589793238462643383279
-
+INLINE_OVERLOADABLE double __ocl_huge(void) {
+  union { ulong u; double d; } u;
+  u.u = 0x7FF0000000000000UL;
+  return u.d;
+}
+#define HUGE_VAL (__ocl_huge())
 #endif /* __OCL_FLOAT_H__ */
-- 
2.7.4



More information about the Beignet mailing list