summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorHomer Hsing <homer.xing@intel.com>2013-07-16 14:34:19 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2013-07-16 14:52:13 +0800
commit3ae63be802a7dac3e40812dd3526f47de33fd6ce (patch)
treeb8b16b31812e21481a524f7ada6ac219aad4da98 /backend
parenta0d61d39e287adb95c4513eda453b14fabd0cd0d (diff)
downloadbeignet-3ae63be802a7dac3e40812dd3526f47de33fd6ce.tar.gz
add built-in function "frexp"
Signed-off-by: Homer Hsing <homer.xing@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'backend')
-rw-r--r--backend/src/ocl_stdlib.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/backend/src/ocl_stdlib.h b/backend/src/ocl_stdlib.h
index fbdc7034..adbd1079 100644
--- a/backend/src/ocl_stdlib.h
+++ b/backend/src/ocl_stdlib.h
@@ -5174,6 +5174,40 @@ DEF(16)
#undef DEC8
#undef DEC16
+INLINE_OVERLOADABLE float frexp(float x, int *exp) {
+ uint u = as_uint(x);
+ if ((u & 0x7FFFFFFFu) == 0) {
+ *exp = 0;
+ return x;
+ }
+ int e = (u >> 23) & 255;
+ if (e == 255)
+ return x;
+ *exp = e - 126;
+ u = (u & (0x807FFFFFu)) | 0x3F000000;
+ return as_float(u);
+}
+
+INLINE_OVERLOADABLE float2 frexp(float2 x, int2 *exp) {
+ return (float2)(frexp(x.s0, (int *)exp), frexp(x.s1, 1 + (int *)exp));
+}
+
+INLINE_OVERLOADABLE float3 frexp(float3 x, int3 *exp) {
+ return (float3)(frexp(x.s0, (int *)exp), frexp(x.s1, 1 + (int *)exp), frexp(x.s2, 2 + (int *)exp));
+}
+
+INLINE_OVERLOADABLE float4 frexp(float4 x, int4 *exp) {
+ return (float4)(frexp(x.s0, (int *)exp), frexp(x.s1, 1 + (int *)exp), frexp(x.s2, 2 + (int *)exp), frexp(x.s3, 3 + (int *)exp));
+}
+
+INLINE_OVERLOADABLE float8 frexp(float8 x, int8 *exp) {
+ return (float8)(frexp(x.s0, (int *)exp), frexp(x.s1, 1 + (int *)exp), frexp(x.s2, 2 + (int *)exp), frexp(x.s3, 3 + (int *)exp), frexp(x.s4, 4 + (int *)exp), frexp(x.s5, 5 + (int *)exp), frexp(x.s6, 6 + (int *)exp), frexp(x.s7, 7 + (int *)exp));
+}
+
+INLINE_OVERLOADABLE float16 frexp(float16 x, int16 *exp) {
+ return (float16)(frexp(x.s0, (int *)exp), frexp(x.s1, 1 + (int *)exp), frexp(x.s2, 2 + (int *)exp), frexp(x.s3, 3 + (int *)exp), frexp(x.s4, 4 + (int *)exp), frexp(x.s5, 5 + (int *)exp), frexp(x.s6, 6 + (int *)exp), frexp(x.s7, 7 + (int *)exp), frexp(x.s8, 8 + (int *)exp), frexp(x.s9, 9 + (int *)exp), frexp(x.sa, 10 + (int *)exp), frexp(x.sb, 11 + (int *)exp), frexp(x.sc, 12 + (int *)exp), frexp(x.sd, 13 + (int *)exp), frexp(x.se, 14 + (int *)exp), frexp(x.sf, 15 + (int *)exp));
+}
+
INLINE_OVERLOADABLE float degrees(float radians) { return (180 / M_PI_F) * radians; }
INLINE_OVERLOADABLE float2 degrees(float2 r) { return (float2)(degrees(r.s0), degrees(r.s1)); }
INLINE_OVERLOADABLE float3 degrees(float3 r) { return (float3)(degrees(r.s0), degrees(r.s1), degrees(r.s2)); }