|
20 | 20 | * THE SOFTWARE. |
21 | 21 | */ |
22 | 22 |
|
23 | | -#ifndef __CLC_MATH_H_ |
24 | | -#define __CLC_MATH_H_ |
| 23 | +#ifndef __CLC_MATH_MATH_H__ |
| 24 | +#define __CLC_MATH_MATH_H__ |
25 | 25 |
|
26 | | -#include "clc/clcfunc.h" |
27 | | -#include "clc/as_type.h" |
28 | | -#include "config.h" |
| 26 | +#include <clc/clc_as_type.h> |
| 27 | +#include <clc/clcfunc.h> |
| 28 | +#include <clc/math/clc_subnormal_config.h> |
29 | 29 |
|
30 | 30 | #define SNAN 0x001 |
31 | 31 | #define QNAN 0x002 |
@@ -54,64 +54,64 @@ bool __attribute__((noinline)) __clc_runtime_has_hw_fma32(void); |
54 | 54 | #define MATH_RECIP(X) (1.0f / (X)) |
55 | 55 | #define MATH_SQRT(X) sqrt(X) |
56 | 56 |
|
57 | | -#define SIGNBIT_SP32 0x80000000 |
58 | | -#define EXSIGNBIT_SP32 0x7fffffff |
59 | | -#define EXPBITS_SP32 0x7f800000 |
60 | | -#define MANTBITS_SP32 0x007fffff |
61 | | -#define ONEEXPBITS_SP32 0x3f800000 |
62 | | -#define TWOEXPBITS_SP32 0x40000000 |
63 | | -#define HALFEXPBITS_SP32 0x3f000000 |
64 | | -#define IMPBIT_SP32 0x00800000 |
65 | | -#define QNANBITPATT_SP32 0x7fc00000 |
| 57 | +#define SIGNBIT_SP32 0x80000000 |
| 58 | +#define EXSIGNBIT_SP32 0x7fffffff |
| 59 | +#define EXPBITS_SP32 0x7f800000 |
| 60 | +#define MANTBITS_SP32 0x007fffff |
| 61 | +#define ONEEXPBITS_SP32 0x3f800000 |
| 62 | +#define TWOEXPBITS_SP32 0x40000000 |
| 63 | +#define HALFEXPBITS_SP32 0x3f000000 |
| 64 | +#define IMPBIT_SP32 0x00800000 |
| 65 | +#define QNANBITPATT_SP32 0x7fc00000 |
66 | 66 | #define INDEFBITPATT_SP32 0xffc00000 |
67 | | -#define PINFBITPATT_SP32 0x7f800000 |
68 | | -#define NINFBITPATT_SP32 0xff800000 |
69 | | -#define EXPBIAS_SP32 127 |
| 67 | +#define PINFBITPATT_SP32 0x7f800000 |
| 68 | +#define NINFBITPATT_SP32 0xff800000 |
| 69 | +#define EXPBIAS_SP32 127 |
70 | 70 | #define EXPSHIFTBITS_SP32 23 |
71 | | -#define BIASEDEMIN_SP32 1 |
72 | | -#define EMIN_SP32 -126 |
73 | | -#define BIASEDEMAX_SP32 254 |
74 | | -#define EMAX_SP32 127 |
75 | | -#define LAMBDA_SP32 1.0e30 |
76 | | -#define MANTLENGTH_SP32 24 |
77 | | -#define BASEDIGITS_SP32 7 |
| 71 | +#define BIASEDEMIN_SP32 1 |
| 72 | +#define EMIN_SP32 -126 |
| 73 | +#define BIASEDEMAX_SP32 254 |
| 74 | +#define EMAX_SP32 127 |
| 75 | +#define LAMBDA_SP32 1.0e30 |
| 76 | +#define MANTLENGTH_SP32 24 |
| 77 | +#define BASEDIGITS_SP32 7 |
78 | 78 |
|
79 | | -_CLC_OVERLOAD _CLC_INLINE float __clc_flush_denormal_if_not_supported(float x) |
80 | | -{ |
81 | | - int ix = as_int(x); |
82 | | - if (!__clc_fp32_subnormals_supported() && |
83 | | - ((ix & EXPBITS_SP32) == 0) && ((ix & MANTBITS_SP32) != 0)) { |
84 | | - ix &= SIGNBIT_SP32; |
85 | | - x = as_float(ix); |
86 | | - } |
87 | | - return x; |
| 79 | +_CLC_OVERLOAD _CLC_INLINE float __clc_flush_denormal_if_not_supported(float x) { |
| 80 | + int ix = __clc_as_int(x); |
| 81 | + if (!__clc_fp32_subnormals_supported() && ((ix & EXPBITS_SP32) == 0) && |
| 82 | + ((ix & MANTBITS_SP32) != 0)) { |
| 83 | + ix &= SIGNBIT_SP32; |
| 84 | + x = __clc_as_float(ix); |
| 85 | + } |
| 86 | + return x; |
88 | 87 | } |
89 | 88 |
|
90 | 89 | #ifdef cl_khr_fp64 |
91 | 90 |
|
92 | | -#define SIGNBIT_DP64 0x8000000000000000L |
93 | | -#define EXSIGNBIT_DP64 0x7fffffffffffffffL |
94 | | -#define EXPBITS_DP64 0x7ff0000000000000L |
95 | | -#define MANTBITS_DP64 0x000fffffffffffffL |
96 | | -#define ONEEXPBITS_DP64 0x3ff0000000000000L |
97 | | -#define TWOEXPBITS_DP64 0x4000000000000000L |
98 | | -#define HALFEXPBITS_DP64 0x3fe0000000000000L |
99 | | -#define IMPBIT_DP64 0x0010000000000000L |
100 | | -#define QNANBITPATT_DP64 0x7ff8000000000000L |
| 91 | +#define SIGNBIT_DP64 0x8000000000000000L |
| 92 | +#define EXSIGNBIT_DP64 0x7fffffffffffffffL |
| 93 | +#define EXPBITS_DP64 0x7ff0000000000000L |
| 94 | +#define MANTBITS_DP64 0x000fffffffffffffL |
| 95 | +#define ONEEXPBITS_DP64 0x3ff0000000000000L |
| 96 | +#define TWOEXPBITS_DP64 0x4000000000000000L |
| 97 | +#define HALFEXPBITS_DP64 0x3fe0000000000000L |
| 98 | +#define IMPBIT_DP64 0x0010000000000000L |
| 99 | +#define QNANBITPATT_DP64 0x7ff8000000000000L |
101 | 100 | #define INDEFBITPATT_DP64 0xfff8000000000000L |
102 | | -#define PINFBITPATT_DP64 0x7ff0000000000000L |
103 | | -#define NINFBITPATT_DP64 0xfff0000000000000L |
104 | | -#define EXPBIAS_DP64 1023 |
| 101 | +#define PINFBITPATT_DP64 0x7ff0000000000000L |
| 102 | +#define NINFBITPATT_DP64 0xfff0000000000000L |
| 103 | +#define EXPBIAS_DP64 1023 |
105 | 104 | #define EXPSHIFTBITS_DP64 52 |
106 | | -#define BIASEDEMIN_DP64 1 |
107 | | -#define EMIN_DP64 -1022 |
108 | | -#define BIASEDEMAX_DP64 2046 /* 0x7fe */ |
109 | | -#define EMAX_DP64 1023 /* 0x3ff */ |
110 | | -#define LAMBDA_DP64 1.0e300 |
111 | | -#define MANTLENGTH_DP64 53 |
112 | | -#define BASEDIGITS_DP64 15 |
| 105 | +#define BIASEDEMIN_DP64 1 |
| 106 | +#define EMIN_DP64 -1022 |
| 107 | +#define BIASEDEMAX_DP64 2046 /* 0x7fe */ |
| 108 | +#define EMAX_DP64 1023 /* 0x3ff */ |
| 109 | +#define LAMBDA_DP64 1.0e300 |
| 110 | +#define MANTLENGTH_DP64 53 |
| 111 | +#define BASEDIGITS_DP64 15 |
113 | 112 |
|
114 | 113 | #endif // cl_khr_fp64 |
115 | 114 |
|
116 | | -#define ALIGNED(x) __attribute__((aligned(x))) |
117 | | -#endif // __CLC_MATH_H_ |
| 115 | +#define ALIGNED(x) __attribute__((aligned(x))) |
| 116 | + |
| 117 | +#endif // __CLC_MATH_MATH_H__ |
0 commit comments